wulf.js 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/changelog.md +10 -0
  2. package/dist/focus-trap.esm.js +88 -30
  3. package/dist/focus-trap.esm.js.map +2 -2
  4. package/dist/focus-trap.global.js +88 -30
  5. package/dist/focus-trap.global.js.map +2 -2
  6. package/dist/focus-trap.global.min.js +2 -2
  7. package/dist/focus-trap.global.min.js.map +3 -3
  8. package/dist/index.esm.js +541 -162
  9. package/dist/index.esm.js.map +2 -2
  10. package/dist/index.global.js +541 -162
  11. package/dist/index.global.js.map +2 -2
  12. package/dist/index.global.min.js +2 -2
  13. package/dist/index.global.min.js.map +3 -3
  14. package/dist/mask.esm.js +4 -4
  15. package/dist/mask.esm.js.map +2 -2
  16. package/dist/mask.global.js +4 -4
  17. package/dist/mask.global.js.map +2 -2
  18. package/dist/mask.global.min.js +2 -2
  19. package/dist/mask.global.min.js.map +3 -3
  20. package/dist/masonry.esm.js +153 -62
  21. package/dist/masonry.esm.js.map +2 -2
  22. package/dist/masonry.global.js +153 -62
  23. package/dist/masonry.global.js.map +2 -2
  24. package/dist/masonry.global.min.js +3 -3
  25. package/dist/masonry.global.min.js.map +3 -3
  26. package/dist/scroll.css +1 -1
  27. package/dist/scroll.css.map +2 -2
  28. package/dist/scroll.esm.js +108 -31
  29. package/dist/scroll.esm.js.map +2 -2
  30. package/dist/scroll.global.js +108 -31
  31. package/dist/scroll.global.js.map +2 -2
  32. package/dist/scroll.global.min.js +2 -2
  33. package/dist/scroll.global.min.js.map +3 -3
  34. package/dist/scroll.layered.css +1 -1
  35. package/dist/scroll.layered.css.map +2 -2
  36. package/dist/shortcut.esm.js +182 -22
  37. package/dist/shortcut.esm.js.map +3 -3
  38. package/dist/shortcut.global.js +182 -22
  39. package/dist/shortcut.global.js.map +3 -3
  40. package/dist/shortcut.global.min.js +4 -1
  41. package/dist/shortcut.global.min.js.map +4 -4
  42. package/dist/toast.css +1 -1
  43. package/dist/toast.css.map +2 -2
  44. package/dist/toast.esm.js +92 -13
  45. package/dist/toast.esm.js.map +2 -2
  46. package/dist/toast.global.js +92 -13
  47. package/dist/toast.global.js.map +2 -2
  48. package/dist/toast.global.min.js +3 -3
  49. package/dist/toast.global.min.js.map +3 -3
  50. package/dist/toast.layered.css +1 -1
  51. package/dist/toast.layered.css.map +2 -2
  52. package/dist/types/common/dom.d.ts +5 -0
  53. package/dist/types/focus-trap/FocusTrap.d.ts +5 -2
  54. package/dist/types/mask/paste.d.ts +2 -5
  55. package/dist/types/masonry/Masonry.d.ts +2 -0
  56. package/dist/types/scroll/ScrollBlock.d.ts +2 -0
  57. package/dist/types/shortcut/ShortcutManager.d.ts +14 -3
  58. package/dist/types/toast/ToastManager.d.ts +2 -0
  59. package/package.json +1 -1
@@ -104,6 +104,10 @@ var __WulfIIFE = (() => {
104
104
  }
105
105
  return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
106
106
  }
107
+ function stripBidiAndInvisibles(raw, maxLength = 4096) {
108
+ const safeLimit = Math.max(0, maxLength);
109
+ return String(raw ?? "").slice(0, safeLimit).replace(/[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, "");
110
+ }
107
111
  function getDeepActiveElement(root) {
108
112
  if (typeof document === "undefined") return null;
109
113
  let active = (root ?? document).activeElement;
@@ -252,10 +256,6 @@ var __WulfIIFE = (() => {
252
256
 
253
257
  // src/mask/paste.ts
254
258
  var MAX_PASTE_LENGTH = 4096;
255
- function stripBidiAndInvisibles(raw, maxLength = MAX_PASTE_LENGTH) {
256
- const safeLimit = Math.max(0, maxLength);
257
- return String(raw ?? "").slice(0, safeLimit).replace(/[\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, "");
258
- }
259
259
  function sanitizePastedText(raw, maxLength = MAX_PASTE_LENGTH) {
260
260
  return stripBidiAndInvisibles(raw, maxLength).replace(/[\u00A0\u202F\u2007]/g, " ").replace(/[\u2013\u2014\u2212]/g, "-").trim();
261
261
  }
@@ -6489,6 +6489,8 @@ var __WulfIIFE = (() => {
6489
6489
  trackX;
6490
6490
  thumbX;
6491
6491
  resizeObserver;
6492
+ mutationObserver;
6493
+ observedChildren = /* @__PURE__ */ new Set();
6492
6494
  hideTimer;
6493
6495
  scrollEndFallbackTimer;
6494
6496
  rafId = null;
@@ -6540,7 +6542,7 @@ var __WulfIIFE = (() => {
6540
6542
  this.root = resolvedElement;
6541
6543
  this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
6542
6544
  const rawDelay = options?.autoHideDelay;
6543
- const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? rawDelay : 1e3;
6545
+ const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? Math.min(rawDelay, 2147483647) : 1e3;
6544
6546
  const rawMinThumb = options?.minThumbSize;
6545
6547
  const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
6546
6548
  const rawEdge = options?.edgeThreshold;
@@ -6837,22 +6839,28 @@ var __WulfIIFE = (() => {
6837
6839
  * Initialise le ResizeObserver réactif.
6838
6840
  */
6839
6841
  setupObserver() {
6840
- if (typeof ResizeObserver !== "undefined") {
6841
- this.resizeObserver = new ResizeObserver(() => {
6842
- if (this.isDestroyed || this.resizeRafId !== null) return;
6843
- this.resizeRafId = window.requestAnimationFrame(() => {
6844
- this.resizeRafId = null;
6845
- if (!this.isDestroyed) {
6846
- this.update();
6847
- }
6848
- });
6842
+ const scheduleUpdate = () => {
6843
+ if (this.isDestroyed || this.resizeRafId !== null) return;
6844
+ this.resizeRafId = window.requestAnimationFrame(() => {
6845
+ this.resizeRafId = null;
6846
+ if (!this.isDestroyed) {
6847
+ this.update();
6848
+ }
6849
6849
  });
6850
+ };
6851
+ if (typeof ResizeObserver !== "undefined") {
6852
+ this.resizeObserver = new ResizeObserver(scheduleUpdate);
6850
6853
  this.resizeObserver.observe(this.root);
6851
6854
  this.resizeObserver.observe(this.viewport);
6852
- if (this.viewport.firstElementChild) {
6853
- this.resizeObserver.observe(this.viewport.firstElementChild);
6855
+ for (const child of Array.from(this.viewport.children)) {
6856
+ this.resizeObserver.observe(child);
6857
+ this.observedChildren.add(child);
6854
6858
  }
6855
6859
  }
6860
+ if (typeof MutationObserver !== "undefined") {
6861
+ this.mutationObserver = new MutationObserver(scheduleUpdate);
6862
+ this.mutationObserver.observe(this.viewport, { childList: true });
6863
+ }
6856
6864
  }
6857
6865
  /**
6858
6866
  * Déplacement lors du glissement du curseur.
@@ -6928,16 +6936,28 @@ var __WulfIIFE = (() => {
6928
6936
  this.scheduleSyncThumbs();
6929
6937
  const info = this.getScrollInfo();
6930
6938
  const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
6931
- this.options.onScroll(info);
6939
+ try {
6940
+ this.options.onScroll(info);
6941
+ } catch (err) {
6942
+ console.error("[Wulf.Scroll] Erreur dans onScroll:", err);
6943
+ }
6932
6944
  const threshold = this.options.edgeThreshold;
6933
6945
  if (maxTop > 0) {
6934
6946
  const nowBottom = scrollTop >= maxTop - threshold;
6935
6947
  const nowTop = scrollTop <= threshold;
6936
6948
  if (nowBottom && !this.atBottom) {
6937
- this.options.onTotalScroll("bottom");
6949
+ try {
6950
+ this.options.onTotalScroll("bottom");
6951
+ } catch (err) {
6952
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
6953
+ }
6938
6954
  }
6939
6955
  if (nowTop && !this.atTop) {
6940
- this.options.onTotalScrollBack("top");
6956
+ try {
6957
+ this.options.onTotalScrollBack("top");
6958
+ } catch (err) {
6959
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
6960
+ }
6941
6961
  }
6942
6962
  this.atBottom = nowBottom;
6943
6963
  this.atTop = nowTop;
@@ -6947,10 +6967,18 @@ var __WulfIIFE = (() => {
6947
6967
  const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
6948
6968
  const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
6949
6969
  if (nowRight && !this.atRight) {
6950
- this.options.onTotalScroll("right");
6970
+ try {
6971
+ this.options.onTotalScroll("right");
6972
+ } catch (err) {
6973
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
6974
+ }
6951
6975
  }
6952
6976
  if (nowLeft && !this.atLeft) {
6953
- this.options.onTotalScrollBack("left");
6977
+ try {
6978
+ this.options.onTotalScrollBack("left");
6979
+ } catch (err) {
6980
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
6981
+ }
6954
6982
  }
6955
6983
  this.atRight = nowRight;
6956
6984
  this.atLeft = nowLeft;
@@ -6976,7 +7004,11 @@ var __WulfIIFE = (() => {
6976
7004
  * Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
6977
7005
  */
6978
7006
  handleScrollEnd() {
6979
- this.options.onScrollEnd(this.getScrollInfo());
7007
+ try {
7008
+ this.options.onScrollEnd(this.getScrollInfo());
7009
+ } catch (err) {
7010
+ console.error("[Wulf.Scroll] Erreur dans onScrollEnd:", err);
7011
+ }
6980
7012
  if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
6981
7013
  this.scheduleAutoHide();
6982
7014
  }
@@ -7003,24 +7035,34 @@ var __WulfIIFE = (() => {
7003
7035
  if (this.thumbY && this.trackY) {
7004
7036
  const maxScrollY = this.cachedMaxTop;
7005
7037
  const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
7006
- if (maxScrollY > 0 && maxTravelY > 0) {
7038
+ if (maxScrollY > 0) {
7007
7039
  const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
7008
- const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
7009
- this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
7010
7040
  this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
7041
+ if (maxTravelY > 0) {
7042
+ const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
7043
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
7044
+ }
7045
+ } else {
7046
+ this.thumbY.setAttribute("aria-valuenow", "0");
7047
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", "0px");
7011
7048
  }
7012
7049
  }
7013
7050
  if (this.thumbX && this.trackX) {
7014
7051
  const maxScrollX = this.cachedMaxLeft;
7015
7052
  const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
7016
- if (maxScrollX > 0 && maxTravelX > 0) {
7053
+ if (maxScrollX > 0) {
7017
7054
  const rtl = this.isRtl();
7018
7055
  const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
7019
7056
  const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
7020
- const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
7021
- const signedPosX = rtl ? -posX : posX;
7022
- this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
7023
7057
  this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
7058
+ if (maxTravelX > 0) {
7059
+ const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
7060
+ const signedPosX = rtl ? -posX : posX;
7061
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
7062
+ }
7063
+ } else {
7064
+ this.thumbX.setAttribute("aria-valuenow", "0");
7065
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", "0px");
7024
7066
  }
7025
7067
  }
7026
7068
  }
@@ -7058,6 +7100,21 @@ var __WulfIIFE = (() => {
7058
7100
  update() {
7059
7101
  if (this.isDestroyed) return;
7060
7102
  this.syncAccessibilityLabels();
7103
+ if (this.resizeObserver) {
7104
+ const currentChildren = new Set(Array.from(this.viewport.children));
7105
+ for (const prev of this.observedChildren) {
7106
+ if (!currentChildren.has(prev)) {
7107
+ this.resizeObserver.unobserve(prev);
7108
+ this.observedChildren.delete(prev);
7109
+ }
7110
+ }
7111
+ for (const child of currentChildren) {
7112
+ if (!this.observedChildren.has(child)) {
7113
+ this.resizeObserver.observe(child);
7114
+ this.observedChildren.add(child);
7115
+ }
7116
+ }
7117
+ }
7061
7118
  const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
7062
7119
  const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
7063
7120
  const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
@@ -7176,10 +7233,12 @@ var __WulfIIFE = (() => {
7176
7233
  }
7177
7234
  }
7178
7235
  } else if (target instanceof HTMLElement) {
7179
- const vpRect = this.viewport.getBoundingClientRect();
7180
- const elRect = target.getBoundingClientRect();
7181
- targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
7182
- targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
7236
+ if (target.isConnected && this.viewport.contains(target)) {
7237
+ const vpRect = this.viewport.getBoundingClientRect();
7238
+ const elRect = target.getBoundingClientRect();
7239
+ targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
7240
+ targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
7241
+ }
7183
7242
  } else if (typeof target === "object" && target !== null) {
7184
7243
  targetTop = target.top;
7185
7244
  targetLeft = target.left;
@@ -7250,8 +7309,8 @@ var __WulfIIFE = (() => {
7250
7309
  */
7251
7310
  audit() {
7252
7311
  const warnings = [];
7253
- const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
7254
- const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
7312
+ const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings, true);
7313
+ const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
7255
7314
  const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
7256
7315
  const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
7257
7316
  const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
@@ -7265,6 +7324,16 @@ var __WulfIIFE = (() => {
7265
7324
  `Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
7266
7325
  );
7267
7326
  }
7327
+ if (this.root.tabIndex > 0 || this.viewport.tabIndex > 0) {
7328
+ warnings.push(
7329
+ 'Attribut tabindex > 0 d\xE9tect\xE9 sur la zone d\xE9filable : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).'
7330
+ );
7331
+ }
7332
+ if (this.root.getAttribute("role") === "region" && this.viewport.getAttribute("role") === "region") {
7333
+ warnings.push(
7334
+ 'Landmark role="region" redondant : \xE9vitez de d\xE9clarer role="region" \xE0 la fois sur le conteneur racine et sur le viewport interne.'
7335
+ );
7336
+ }
7268
7337
  return warnings;
7269
7338
  }
7270
7339
  getAuditPrefix() {
@@ -7278,6 +7347,9 @@ var __WulfIIFE = (() => {
7278
7347
  */
7279
7348
  destroy() {
7280
7349
  if (this.isDestroyed) return;
7350
+ if (this.isDragging) {
7351
+ this.handlePointerUp();
7352
+ }
7281
7353
  this.isDestroyed = true;
7282
7354
  this.clearAutoHideTimer();
7283
7355
  if (this.scrollEndFallbackTimer !== void 0) {
@@ -7300,6 +7372,11 @@ var __WulfIIFE = (() => {
7300
7372
  if (this.resizeObserver) {
7301
7373
  this.resizeObserver.disconnect();
7302
7374
  }
7375
+ if (this.mutationObserver) {
7376
+ this.mutationObserver.disconnect();
7377
+ this.mutationObserver = void 0;
7378
+ }
7379
+ this.observedChildren.clear();
7303
7380
  this.trackY?.remove();
7304
7381
  this.trackX?.remove();
7305
7382
  this.root.classList.remove(
@@ -7484,9 +7561,10 @@ var __WulfIIFE = (() => {
7484
7561
  const colHeights = new Array(cols).fill(0);
7485
7562
  const positions = [];
7486
7563
  const itemHeights = items.map((item) => {
7487
- const h = item.getBoundingClientRect().height;
7564
+ const h = item.classList.contains("wulf-masonry-item--hidden") && item.offsetHeight > 0 ? item.offsetHeight : item.getBoundingClientRect().height;
7488
7565
  return h > 0 ? h : 50;
7489
7566
  });
7567
+ const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
7490
7568
  let currentHCol = 0;
7491
7569
  for (let i = 0; i < items.length; i++) {
7492
7570
  const item = items[i];
@@ -7537,7 +7615,6 @@ var __WulfIIFE = (() => {
7537
7615
  }
7538
7616
  }
7539
7617
  const itemW = span * colWidth + (span - 1) * gutterX;
7540
- const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
7541
7618
  const effectiveWidth = fittedWidth !== void 0 ? fittedWidth : containerWidth;
7542
7619
  const rawX = targetCol * (colWidth + gutterX);
7543
7620
  const targetX = isRtl ? Math.max(0, effectiveWidth - rawX - itemW) : rawX;
@@ -7592,6 +7669,7 @@ var __WulfIIFE = (() => {
7592
7669
  });
7593
7670
 
7594
7671
  // src/masonry/Masonry.ts
7672
+ var NATIVE_STRUCTURAL_TAGS = /* @__PURE__ */ new Set(["UL", "OL", "MAIN", "NAV", "ASIDE", "ARTICLE", "SECTION"]);
7595
7673
  var Masonry = class extends LocalizedComponent {
7596
7674
  static _i18n = masonryI18n;
7597
7675
  static i18n = masonryI18n;
@@ -7603,9 +7681,11 @@ var __WulfIIFE = (() => {
7603
7681
  itemResizeObserver = null;
7604
7682
  observedItems = /* @__PURE__ */ new Set();
7605
7683
  observedItemHeights = /* @__PURE__ */ new WeakMap();
7606
- removingItems = /* @__PURE__ */ new WeakSet();
7684
+ removingItems = /* @__PURE__ */ new Set();
7607
7685
  layoutRafId = null;
7686
+ lastObservedWidth = 0;
7608
7687
  isDestroyed = false;
7688
+ hasExplicitAriaRole = false;
7609
7689
  wasRoleInferred = false;
7610
7690
  wasAriaLabelInferred = false;
7611
7691
  hasExplicitAriaLabel = false;
@@ -7635,6 +7715,7 @@ var __WulfIIFE = (() => {
7635
7715
  height: this.root.style.height,
7636
7716
  width: this.root.style.width
7637
7717
  };
7718
+ this.hasExplicitAriaRole = Boolean(options.ariaRole);
7638
7719
  this.hasExplicitAriaLabel = Boolean(options.ariaLabel || options.i18n?.gallery);
7639
7720
  this.options = {
7640
7721
  itemSelector: options.itemSelector || "> *",
@@ -7680,7 +7761,7 @@ var __WulfIIFE = (() => {
7680
7761
  * Initialise les attributs WAI-ARIA du conteneur.
7681
7762
  */
7682
7763
  initAccessibility() {
7683
- if (this.options.ariaRole && !this.root.hasAttribute("role")) {
7764
+ if (this.options.ariaRole && !this.root.hasAttribute("role") && (this.hasExplicitAriaRole || !NATIVE_STRUCTURAL_TAGS.has(this.root.tagName))) {
7684
7765
  this.root.setAttribute("role", this.options.ariaRole);
7685
7766
  this.wasRoleInferred = true;
7686
7767
  }
@@ -7712,9 +7793,10 @@ var __WulfIIFE = (() => {
7712
7793
  const dur = this.options.transitionDuration;
7713
7794
  let durValue = "300ms";
7714
7795
  if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
7715
- durValue = `${dur}ms`;
7796
+ durValue = `${Math.min(dur, 6e4)}ms`;
7716
7797
  } else if (typeof dur === "string" && /^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(dur)) {
7717
- durValue = dur.trim();
7798
+ const parsedMs = parseCssDurationMs(dur, 300, 6e4);
7799
+ durValue = parsedMs >= 6e4 ? "60000ms" : dur.trim();
7718
7800
  }
7719
7801
  this.root.style.setProperty("--wulf-masonry-duration", durValue);
7720
7802
  }
@@ -7765,12 +7847,12 @@ var __WulfIIFE = (() => {
7765
7847
  */
7766
7848
  initObservers() {
7767
7849
  if (!this.options.resize || typeof ResizeObserver === "undefined") return;
7768
- let prevWidth = this.root.getBoundingClientRect().width;
7850
+ this.lastObservedWidth = this.root.getBoundingClientRect().width;
7769
7851
  this.resizeObserver = new ResizeObserver((entries) => {
7770
7852
  for (const entry of entries) {
7771
7853
  const currentWidth = entry.contentRect.width;
7772
- if (Math.abs(currentWidth - prevWidth) >= 1) {
7773
- prevWidth = currentWidth;
7854
+ if (Math.abs(currentWidth - this.lastObservedWidth) >= 1) {
7855
+ this.lastObservedWidth = currentWidth;
7774
7856
  this.scheduleLayout();
7775
7857
  }
7776
7858
  }
@@ -7812,15 +7894,23 @@ var __WulfIIFE = (() => {
7812
7894
  this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
7813
7895
  }
7814
7896
  } else if (typeof this.options.columnWidth === "string" && this.options.columnWidth.trim()) {
7815
- try {
7816
- const el = this.root.querySelector(this.options.columnWidth);
7817
- if (el) {
7818
- const w = el.getBoundingClientRect().width;
7819
- if (w > 0) {
7820
- this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
7897
+ const trimmed = this.options.columnWidth.trim();
7898
+ if (/^\d+(\.\d+)?(px|%)?$/i.test(trimmed)) {
7899
+ const w = LayoutEngine.resolveColumnWidth(this.root, null, trimmed);
7900
+ if (w > 0) {
7901
+ this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
7902
+ }
7903
+ } else {
7904
+ try {
7905
+ const el = this.root.querySelector(trimmed);
7906
+ if (el) {
7907
+ const w = el.getBoundingClientRect().width;
7908
+ if (w > 0) {
7909
+ this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
7910
+ }
7821
7911
  }
7912
+ } catch {
7822
7913
  }
7823
- } catch {
7824
7914
  }
7825
7915
  }
7826
7916
  }
@@ -7874,60 +7964,80 @@ var __WulfIIFE = (() => {
7874
7964
  for (const el of this._items) {
7875
7965
  el.classList.remove("wulf-masonry-item--hidden");
7876
7966
  }
7877
- this.options.onLayout([]);
7967
+ try {
7968
+ this.options.onLayout([]);
7969
+ } catch (err) {
7970
+ console.error("[Wulf.Masonry] Erreur dans onLayout:", err);
7971
+ }
7878
7972
  return;
7879
7973
  }
7880
7974
  this.root.setAttribute("aria-busy", "true");
7881
- if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
7882
- this.root.style.width = "";
7883
- }
7884
- const result = LayoutEngine.calculate(this.root, this._items, this.options);
7885
- this.root.style.height = `${result.containerHeight}px`;
7886
- if (this.options.fitWidth && result.fittedWidth !== void 0) {
7887
- this.root.style.width = `${result.fittedWidth}px`;
7888
- this.root.classList.add("wulf-masonry--fit-width");
7889
- } else {
7890
- this.root.classList.remove("wulf-masonry--fit-width");
7891
- }
7892
- const stagger = this.options.stagger;
7893
- const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
7894
- if (validStagger) {
7895
- this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
7896
- } else {
7897
- this.root.style.removeProperty("--wulf-masonry-stagger");
7898
- }
7899
- const hasIgnoredChildren = this._items.length !== this.root.children.length;
7900
- const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
7901
- const usePercent = this.options.percentPosition && result.containerWidth > 0;
7902
- for (let i = 0; i < result.positions.length; i++) {
7903
- const pos = result.positions[i];
7904
- const item = pos.element;
7905
- if (usePercent) {
7906
- const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
7907
- item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
7975
+ let positionsResult = [];
7976
+ try {
7977
+ if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
7978
+ this.root.style.width = "";
7979
+ }
7980
+ const result = LayoutEngine.calculate(this.root, this._items, this.options);
7981
+ positionsResult = result.positions;
7982
+ this.root.style.height = `${result.containerHeight}px`;
7983
+ if (this.options.fitWidth && result.fittedWidth !== void 0) {
7984
+ this.root.style.width = `${result.fittedWidth}px`;
7985
+ this.lastObservedWidth = result.fittedWidth;
7986
+ this.root.classList.add("wulf-masonry--fit-width");
7908
7987
  } else {
7909
- item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
7988
+ this.root.classList.remove("wulf-masonry--fit-width");
7910
7989
  }
7911
- item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
7912
- item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
7913
- if (validStagger && !supportsSiblingIndex) {
7914
- item.style.setProperty("--wulf-masonry-index", String(i));
7990
+ const stagger = this.options.stagger;
7991
+ const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
7992
+ if (validStagger) {
7993
+ this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
7915
7994
  } else {
7916
- item.style.removeProperty("--wulf-masonry-index");
7995
+ this.root.style.removeProperty("--wulf-masonry-stagger");
7996
+ }
7997
+ const hasIgnoredChildren = this._items.length !== this.root.children.length;
7998
+ const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
7999
+ const usePercent = this.options.percentPosition && result.containerWidth > 0;
8000
+ for (let i = 0; i < result.positions.length; i++) {
8001
+ const pos = result.positions[i];
8002
+ const item = pos.element;
8003
+ if (usePercent) {
8004
+ const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
8005
+ item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
8006
+ } else {
8007
+ item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
8008
+ }
8009
+ item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
8010
+ item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
8011
+ if (validStagger && !supportsSiblingIndex) {
8012
+ item.style.setProperty("--wulf-masonry-index", String(i));
8013
+ } else {
8014
+ item.style.removeProperty("--wulf-masonry-index");
8015
+ }
8016
+ item.classList.remove("wulf-masonry-item--hidden");
8017
+ this.observedItemHeights.set(item, pos.height);
8018
+ try {
8019
+ this.options.onItemPlaced(item, pos);
8020
+ } catch (err) {
8021
+ console.error("[Wulf.Masonry] Erreur dans onItemPlaced:", err);
8022
+ }
7917
8023
  }
7918
- item.classList.remove("wulf-masonry-item--hidden");
7919
- this.observedItemHeights.set(item, pos.height);
7920
- this.options.onItemPlaced(item, pos);
8024
+ } finally {
8025
+ this.root.setAttribute("aria-busy", "false");
8026
+ }
8027
+ try {
8028
+ this.options.onLayout(positionsResult);
8029
+ } catch (err) {
8030
+ console.error("[Wulf.Masonry] Erreur dans onLayout:", err);
7921
8031
  }
7922
- this.root.setAttribute("aria-busy", "false");
7923
- this.options.onLayout(result.positions);
7924
8032
  }
7925
8033
  /**
7926
8034
  * Ajoute de nouveaux éléments à la fin du conteneur.
7927
8035
  */
7928
8036
  append(elements) {
7929
8037
  if (this.isDestroyed) return;
7930
- const list = Array.isArray(elements) ? elements : [elements];
8038
+ const list = (Array.isArray(elements) ? elements : [elements]).filter(
8039
+ (el) => el instanceof HTMLElement && !el.contains(this.root)
8040
+ );
7931
8041
  if (list.length === 0) return;
7932
8042
  const frag = document.createDocumentFragment();
7933
8043
  for (const el of list) {
@@ -7948,7 +8058,9 @@ var __WulfIIFE = (() => {
7948
8058
  */
7949
8059
  prepend(elements) {
7950
8060
  if (this.isDestroyed) return;
7951
- const list = Array.isArray(elements) ? elements : [elements];
8061
+ const list = (Array.isArray(elements) ? elements : [elements]).filter(
8062
+ (el) => el instanceof HTMLElement && !el.contains(this.root)
8063
+ );
7952
8064
  if (list.length === 0) return;
7953
8065
  const first = this.root.firstChild;
7954
8066
  const frag = document.createDocumentFragment();
@@ -7970,7 +8082,9 @@ var __WulfIIFE = (() => {
7970
8082
  */
7971
8083
  remove(elements) {
7972
8084
  if (this.isDestroyed) return;
7973
- const list = Array.isArray(elements) ? elements : [elements];
8085
+ const list = (Array.isArray(elements) ? elements : [elements]).filter(
8086
+ (el) => el instanceof HTMLElement
8087
+ );
7974
8088
  if (list.length === 0) return;
7975
8089
  const finalizeRemoval = () => {
7976
8090
  if (this.isDestroyed) return;
@@ -7988,11 +8102,34 @@ var __WulfIIFE = (() => {
7988
8102
  this.reloadItems();
7989
8103
  this.layout();
7990
8104
  };
8105
+ const activeEl = getDeepActiveElement();
8106
+ if (activeEl && list.some((el) => el.contains(activeEl))) {
8107
+ const removeSet = new Set(list);
8108
+ const firstRemovedIdx = this._items.findIndex((item) => removeSet.has(item));
8109
+ const survivorsAfter = firstRemovedIdx >= 0 ? this._items.slice(firstRemovedIdx + 1).filter((item) => !removeSet.has(item)) : [];
8110
+ const survivorsBefore = firstRemovedIdx > 0 ? this._items.slice(0, firstRemovedIdx).filter((item) => !removeSet.has(item)).reverse() : [];
8111
+ const candidateItem = survivorsAfter[0] || survivorsBefore[0] || null;
8112
+ let handoffDone = false;
8113
+ if (candidateItem) {
8114
+ const focusableChild = candidateItem.querySelector(
8115
+ 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
8116
+ );
8117
+ const focusTarget = focusableChild || (candidateItem.tabIndex >= 0 ? candidateItem : null);
8118
+ if (focusTarget) {
8119
+ try {
8120
+ focusTarget.focus({ preventScroll: true });
8121
+ handoffDone = true;
8122
+ } catch {
8123
+ handoffDone = false;
8124
+ }
8125
+ }
8126
+ }
8127
+ if (!handoffDone) {
8128
+ activeEl.blur?.();
8129
+ }
8130
+ }
7991
8131
  for (const el of list) {
7992
8132
  this.removingItems.add(el);
7993
- if (typeof document !== "undefined" && document.activeElement && el.contains(document.activeElement)) {
7994
- document.activeElement.blur?.();
7995
- }
7996
8133
  el.setAttribute("inert", "");
7997
8134
  el.style.transitionDelay = "0ms";
7998
8135
  el.classList.add("wulf-masonry-item--hidden");
@@ -8018,7 +8155,7 @@ var __WulfIIFE = (() => {
8018
8155
  */
8019
8156
  audit() {
8020
8157
  const warnings = [];
8021
- const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
8158
+ const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
8022
8159
  const hasCustomRootAriaLabel = !this.wasAriaLabelInferred && Boolean(this.root.getAttribute("aria-label")?.trim());
8023
8160
  if (!this.hasExplicitAriaLabel && !hasCustomRootAriaLabel && !hasValidLabelledby) {
8024
8161
  warnings.push(
@@ -8033,6 +8170,19 @@ var __WulfIIFE = (() => {
8033
8170
  `${imagesWithoutAlt.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`
8034
8171
  );
8035
8172
  }
8173
+ const positiveTabIndexEls = Array.from(this.root.querySelectorAll("[tabindex]")).filter(
8174
+ (el) => el.tabIndex > 0
8175
+ );
8176
+ if (positiveTabIndexEls.length > 0) {
8177
+ warnings.push(
8178
+ `${positiveTabIndexEls.length} \xE9l\xE9ment(s) avec tabindex > 0 d\xE9tect\xE9(s) : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).`
8179
+ );
8180
+ }
8181
+ if (!this.options.horizontalOrder && this.root.querySelector('a[href], button, input, select, textarea, [tabindex="0"]') !== null) {
8182
+ warnings.push(
8183
+ "Grille interactive avec horizontalOrder: false : l'ordre visuel peut diverger de l'ordre de tabulation ; envisagez horizontalOrder: true (WCAG 1.3.2 / 2.4.3)."
8184
+ );
8185
+ }
8036
8186
  return warnings;
8037
8187
  }
8038
8188
  getAuditPrefix() {
@@ -8083,6 +8233,16 @@ var __WulfIIFE = (() => {
8083
8233
  } else {
8084
8234
  this.root.style.removeProperty("width");
8085
8235
  }
8236
+ for (const item of this.removingItems) {
8237
+ item.removeAttribute("inert");
8238
+ item.style.removeProperty("transition-delay");
8239
+ item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
8240
+ item.style.removeProperty("--wulf-masonry-w");
8241
+ item.style.removeProperty("--wulf-masonry-x");
8242
+ item.style.removeProperty("--wulf-masonry-y");
8243
+ item.style.removeProperty("--wulf-masonry-index");
8244
+ }
8245
+ this.removingItems.clear();
8086
8246
  for (const item of this._items) {
8087
8247
  item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
8088
8248
  item.style.removeProperty("--wulf-masonry-w");
@@ -8140,17 +8300,18 @@ var __WulfIIFE = (() => {
8140
8300
  // src/toast/ToastInstance.ts
8141
8301
  var nextToastId = 1;
8142
8302
  var DEFAULT_TOAST_DURATION = 5e3;
8303
+ var SAFE_COLOR_FALLBACK_RE = /^(?:#[0-9a-f]{3,8}|(?:rgb|rgba|hsl|hsla|oklch|oklab|lch|lab)\([^;{}<>\\]+\)|[a-z]{3,20})$/i;
8143
8304
  function isSafeCssValue(val) {
8144
8305
  if (!val || typeof val !== "string" || val.length > 128) return false;
8145
8306
  const trimmed = val.trim();
8146
8307
  if (!trimmed) return false;
8147
- if (/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env)\s*\(/i.test(trimmed)) {
8308
+ if (/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env|var)\s*\(/i.test(trimmed)) {
8148
8309
  return false;
8149
8310
  }
8150
8311
  if (typeof CSS !== "undefined" && typeof CSS.supports === "function") {
8151
8312
  return CSS.supports("color", trimmed) || CSS.supports("background-color", trimmed);
8152
8313
  }
8153
- return true;
8314
+ return SAFE_COLOR_FALLBACK_RE.test(trimmed);
8154
8315
  }
8155
8316
  function sanitizeIconClasses(icon) {
8156
8317
  return icon.slice(0, 128).trim().split(/\s+/).filter((token) => /^[a-zA-Z0-9_-]+$/.test(token) && !token.startsWith("wulf-toast")).slice(0, 8).join(" ");
@@ -8179,7 +8340,7 @@ var __WulfIIFE = (() => {
8179
8340
  this.id = `wulf-toast-${nextToastId++}`;
8180
8341
  this.options = Object.freeze({ ...options });
8181
8342
  this.onDismissCallback = onDismiss;
8182
- this.previousActiveElement = typeof document !== "undefined" && document.activeElement instanceof HTMLElement ? document.activeElement : null;
8343
+ this.previousActiveElement = getDeepActiveElement();
8183
8344
  const duration = options.duration === void 0 ? DEFAULT_TOAST_DURATION : options.duration;
8184
8345
  if (typeof duration === "number" && Number.isFinite(duration) && duration > 0) {
8185
8346
  this.remainingTime = Math.min(duration, 2147483647);
@@ -8266,7 +8427,30 @@ var __WulfIIFE = (() => {
8266
8427
  }
8267
8428
  }
8268
8429
  const content = document.createElement("div");
8269
- content.className = "wulf-toast-content";
8430
+ const isInteractiveContent = Boolean(this.options.onClick || this.options.closeOnClick);
8431
+ content.className = isInteractiveContent ? "wulf-toast-content wulf-toast-content--interactive" : "wulf-toast-content";
8432
+ if (isInteractiveContent) {
8433
+ content.setAttribute("role", "button");
8434
+ content.setAttribute("tabindex", "0");
8435
+ content.addEventListener("keydown", (e) => {
8436
+ if (isImeComposing(e)) return;
8437
+ if (e.key === "Enter") {
8438
+ e.preventDefault();
8439
+ e.stopPropagation();
8440
+ content.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
8441
+ } else if (e.key === " ") {
8442
+ e.preventDefault();
8443
+ e.stopPropagation();
8444
+ }
8445
+ }, { signal: this.eventsAbortController.signal });
8446
+ content.addEventListener("keyup", (e) => {
8447
+ if (e.key === " ") {
8448
+ e.preventDefault();
8449
+ e.stopPropagation();
8450
+ content.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
8451
+ }
8452
+ }, { signal: this.eventsAbortController.signal });
8453
+ }
8270
8454
  if (this.options.title && this.options.title.trim() !== "") {
8271
8455
  const titleEl = document.createElement("div");
8272
8456
  titleEl.className = "wulf-toast-title";
@@ -8310,7 +8494,7 @@ var __WulfIIFE = (() => {
8310
8494
  * Injection de texte sécurisée gérant nativement les retours à la ligne (\n et \r\n).
8311
8495
  */
8312
8496
  appendTextWithLineBreaks(container, text) {
8313
- const safeText = String(text ?? "").slice(0, 4096);
8497
+ const safeText = stripBidiAndInvisibles(String(text ?? ""), 4096);
8314
8498
  const lines = safeText.split(/\r\n|\r|\n/).slice(0, 100);
8315
8499
  lines.forEach((line, index) => {
8316
8500
  if (index > 0) {
@@ -8326,7 +8510,11 @@ var __WulfIIFE = (() => {
8326
8510
  const { signal } = this.eventsAbortController;
8327
8511
  this.element.addEventListener("click", (e) => {
8328
8512
  if (this.options.onClick) {
8329
- this.options.onClick(this, e);
8513
+ try {
8514
+ this.options.onClick(this, e);
8515
+ } catch (err) {
8516
+ console.error("[Wulf.Toast] Erreur dans le callback onClick:", err);
8517
+ }
8330
8518
  }
8331
8519
  if (this.options.closeOnClick) {
8332
8520
  this.close("toast-click");
@@ -8349,6 +8537,7 @@ var __WulfIIFE = (() => {
8349
8537
  }, { signal });
8350
8538
  this.element.addEventListener("keydown", (e) => {
8351
8539
  if (e.key === "Escape" && (this.options.closable ?? true)) {
8540
+ if (isImeComposing(e)) return;
8352
8541
  e.stopPropagation();
8353
8542
  this.close("close-button");
8354
8543
  }
@@ -8383,7 +8572,8 @@ var __WulfIIFE = (() => {
8383
8572
  this.timerStartTime = performance.now();
8384
8573
  this.timerId = window.setTimeout(() => {
8385
8574
  this.timerId = null;
8386
- if (typeof document !== "undefined" && this.element.contains(document.activeElement)) {
8575
+ const active = getDeepActiveElement();
8576
+ if (active && this.element.contains(active)) {
8387
8577
  this.isPendingFocusDismiss = true;
8388
8578
  return;
8389
8579
  }
@@ -8423,7 +8613,8 @@ var __WulfIIFE = (() => {
8423
8613
  this.isPausedByFocus = false;
8424
8614
  } else if (source === "hover") {
8425
8615
  this.isPausedByHover = false;
8426
- if (typeof document !== "undefined" && this.element.contains(document.activeElement)) {
8616
+ const active = getDeepActiveElement();
8617
+ if (active && this.element.contains(active)) {
8427
8618
  this.isPausedByFocus = true;
8428
8619
  }
8429
8620
  } else {
@@ -8449,7 +8640,11 @@ var __WulfIIFE = (() => {
8449
8640
  this.element.parentNode.removeChild(this.element);
8450
8641
  }
8451
8642
  if (this.options.onClose) {
8452
- this.options.onClose(this, reason);
8643
+ try {
8644
+ this.options.onClose(this, reason);
8645
+ } catch (err) {
8646
+ console.error("[Wulf.Toast] Erreur dans le callback onClose:", err);
8647
+ }
8453
8648
  }
8454
8649
  }
8455
8650
  /**
@@ -8509,6 +8704,7 @@ var __WulfIIFE = (() => {
8509
8704
  var ToastManager = class _ToastManager {
8510
8705
  static instance = null;
8511
8706
  containers = /* @__PURE__ */ new Map();
8707
+ containerBaseLabels = /* @__PURE__ */ new WeakMap();
8512
8708
  activeToasts = /* @__PURE__ */ new Map();
8513
8709
  announcerEl = null;
8514
8710
  politeRegion = null;
@@ -8630,7 +8826,7 @@ var __WulfIIFE = (() => {
8630
8826
  * Annonce la notification sur un canal unique pour éviter les doubles lectures AT.
8631
8827
  */
8632
8828
  announce(toast) {
8633
- const parts = [toast.options.title, toast.options.message].filter((val) => typeof val === "string" && val.trim().length > 0).map((val) => val.trim());
8829
+ const parts = [toast.options.title, toast.options.message].filter((val) => typeof val === "string" && val.trim().length > 0).map((val) => stripBidiAndInvisibles(val, 512).trim()).filter(Boolean);
8634
8830
  if (parts.length === 0) return;
8635
8831
  const rawText = parts.join(". ");
8636
8832
  const text = rawText.length > 512 ? `${rawText.slice(0, 509)}...` : rawText;
@@ -8742,7 +8938,8 @@ var __WulfIIFE = (() => {
8742
8938
  * Transfère le focus avant de retirer un toast focalisé pour éviter que le focus ne retombe sur <body>.
8743
8939
  */
8744
8940
  handleFocusHandoff(toast, list) {
8745
- if (!toast.element.contains(document.activeElement)) {
8941
+ const active = getDeepActiveElement();
8942
+ if (!active || !toast.element.contains(active)) {
8746
8943
  return;
8747
8944
  }
8748
8945
  for (let i = list.length - 1; i >= 0; i--) {
@@ -8755,7 +8952,15 @@ var __WulfIIFE = (() => {
8755
8952
  }
8756
8953
  }
8757
8954
  const prev = toast.getPreviousActiveElement();
8758
- if (prev && prev.isConnected && typeof prev.focus === "function" && !prev.disabled && !prev.closest("[inert]") && prev.getAttribute("aria-hidden") !== "true") {
8955
+ if (prev && prev.isConnected && typeof prev.focus === "function" && !prev.disabled && !prev.hidden && !prev.closest("[hidden]") && !prev.closest("[inert]") && prev.getAttribute("aria-hidden") !== "true" && (prev.tabIndex >= 0 || prev.getAttribute("tabindex") !== null)) {
8956
+ const prevWithCheck = prev;
8957
+ if (typeof prevWithCheck.checkVisibility === "function" && !prevWithCheck.checkVisibility({
8958
+ checkOpacity: false,
8959
+ checkVisibilityCSS: true,
8960
+ visibilityProperty: true
8961
+ })) {
8962
+ return;
8963
+ }
8759
8964
  try {
8760
8965
  prev.focus();
8761
8966
  } catch {
@@ -8783,6 +8988,7 @@ var __WulfIIFE = (() => {
8783
8988
  this.disposeContainer(container);
8784
8989
  this.containers.delete(position);
8785
8990
  this.activeToasts.delete(position);
8991
+ this.syncContainerRegionLabels();
8786
8992
  }
8787
8993
  }
8788
8994
  } else if (toast.element.parentNode) {
@@ -8821,6 +9027,7 @@ var __WulfIIFE = (() => {
8821
9027
  this.disposeContainer(container);
8822
9028
  this.containers.delete(position);
8823
9029
  this.activeToasts.delete(position);
9030
+ this.syncContainerRegionLabels();
8824
9031
  }
8825
9032
  }
8826
9033
  } else {
@@ -8853,6 +9060,7 @@ var __WulfIIFE = (() => {
8853
9060
  this.activeToasts.delete(pos);
8854
9061
  }
8855
9062
  }
9063
+ this.syncContainerRegionLabels();
8856
9064
  }
8857
9065
  });
8858
9066
  }
@@ -8864,6 +9072,10 @@ var __WulfIIFE = (() => {
8864
9072
  window.clearTimeout(timerId);
8865
9073
  }
8866
9074
  this.announceTimers = [];
9075
+ this.politeAnnounceTimerId = null;
9076
+ this.assertiveAnnounceTimerId = null;
9077
+ this.politeClearTimerId = null;
9078
+ this.assertiveClearTimerId = null;
8867
9079
  for (const list of Array.from(this.activeToasts.values())) {
8868
9080
  for (const toast of [...list]) {
8869
9081
  toast.destroyImmediate("programmatic");
@@ -8884,6 +9096,13 @@ var __WulfIIFE = (() => {
8884
9096
  }
8885
9097
  _ToastManager.instance = null;
8886
9098
  }
9099
+ syncContainerRegionLabels() {
9100
+ const useSuffix = this.containers.size > 1;
9101
+ for (const [pos, container] of this.containers.entries()) {
9102
+ const baseLabel = this.containerBaseLabels.get(container) || toastI18n.t("notificationsRegion");
9103
+ container.setAttribute("aria-label", useSuffix ? `${baseLabel} (${pos})` : baseLabel);
9104
+ }
9105
+ }
8887
9106
  /**
8888
9107
  * Récupère ou crée le conteneur DOM pour une position d'affichage.
8889
9108
  */
@@ -8893,12 +9112,15 @@ var __WulfIIFE = (() => {
8893
9112
  container = document.createElement("div");
8894
9113
  container.className = `wulf-toast-container wulf-toast-${position}`;
8895
9114
  container.setAttribute("role", "region");
8896
- container.setAttribute("aria-label", toastI18n.t("notificationsRegion", toast.options.i18n));
9115
+ const baseLabel = toastI18n.t("notificationsRegion", toast.options.i18n);
9116
+ this.containerBaseLabels.set(container, baseLabel);
9117
+ container.setAttribute("aria-label", baseLabel);
8897
9118
  if (useTopLayer && typeof container.showPopover === "function") {
8898
9119
  container.setAttribute("popover", "manual");
8899
9120
  }
8900
9121
  document.body.appendChild(container);
8901
9122
  this.containers.set(position, container);
9123
+ this.syncContainerRegionLabels();
8902
9124
  }
8903
9125
  return container;
8904
9126
  }
@@ -9036,9 +9258,8 @@ var __WulfIIFE = (() => {
9036
9258
  return false;
9037
9259
  }
9038
9260
  }
9039
- isElementFocusableBase(el) {
9261
+ isElementVisibleAndEnabled(el) {
9040
9262
  if (!el || !el.isConnected) return false;
9041
- if (el.tabIndex < 0) return false;
9042
9263
  if (el.disabled) return false;
9043
9264
  try {
9044
9265
  if (el.matches(":disabled")) return false;
@@ -9066,6 +9287,14 @@ var __WulfIIFE = (() => {
9066
9287
  }
9067
9288
  return true;
9068
9289
  }
9290
+ isElementFocusableBase(el) {
9291
+ if (!el || el.tabIndex < 0) return false;
9292
+ return this.isElementVisibleAndEnabled(el);
9293
+ }
9294
+ isProgrammaticallyFocusable(el) {
9295
+ if (!el || !this.isElementVisibleAndEnabled(el)) return false;
9296
+ return el.tabIndex >= 0 || el.getAttribute("tabindex") !== null;
9297
+ }
9069
9298
  /**
9070
9299
  * Vérifie si un élément est réellement focusable, visible et actif dans le DOM.
9071
9300
  */
@@ -9119,9 +9348,16 @@ var __WulfIIFE = (() => {
9119
9348
  document.addEventListener("touchstart", this.handleClickOutsideBound, { capture: true, signal });
9120
9349
  document.addEventListener("click", this.handleClickOutsideBound, { capture: true, signal });
9121
9350
  }
9351
+ if (this.isNativeDialogElement()) {
9352
+ this.element.addEventListener("close", () => this.deactivate(), { signal });
9353
+ }
9122
9354
  this.applyInitialFocus();
9123
9355
  this.runAuditWarning(this.options.audit);
9124
- this.options.onActivate();
9356
+ try {
9357
+ this.options.onActivate();
9358
+ } catch (err) {
9359
+ console.error("[Wulf.FocusTrap] Erreur dans onActivate:", err);
9360
+ }
9125
9361
  return this;
9126
9362
  }
9127
9363
  /**
@@ -9129,6 +9365,7 @@ var __WulfIIFE = (() => {
9129
9365
  */
9130
9366
  deactivate() {
9131
9367
  if (!this.active) return this;
9368
+ const wasTop = trapStack[trapStack.length - 1] === this;
9132
9369
  this.active = false;
9133
9370
  this.paused = false;
9134
9371
  const index = trapStack.indexOf(this);
@@ -9142,15 +9379,21 @@ var __WulfIIFE = (() => {
9142
9379
  this.element.removeAttribute("tabindex");
9143
9380
  this.addedContainerTabIndex = false;
9144
9381
  }
9145
- const nextTop = trapStack[trapStack.length - 1];
9146
- if (nextTop) {
9147
- nextTop.unpause();
9148
- }
9149
- if (this.options.returnFocus) {
9150
- this.restoreFocus();
9382
+ if (wasTop) {
9383
+ const nextTop = trapStack[trapStack.length - 1];
9384
+ if (nextTop) {
9385
+ nextTop.unpause();
9386
+ }
9387
+ if (this.options.returnFocus) {
9388
+ this.restoreFocus();
9389
+ }
9151
9390
  }
9152
9391
  this.previousActiveElement = null;
9153
- this.options.onDeactivate();
9392
+ try {
9393
+ this.options.onDeactivate();
9394
+ } catch (err) {
9395
+ console.error("[Wulf.FocusTrap] Erreur dans onDeactivate:", err);
9396
+ }
9154
9397
  return this;
9155
9398
  }
9156
9399
  /**
@@ -9216,12 +9459,23 @@ var __WulfIIFE = (() => {
9216
9459
  }
9217
9460
  }
9218
9461
  const ariaLabel = this.element.getAttribute("aria-label")?.trim();
9219
- const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings);
9462
+ const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings, true);
9220
9463
  if (!ariaLabel && !hasValidLabelledby) {
9221
9464
  warnings.push(
9222
9465
  'Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'
9223
9466
  );
9224
9467
  }
9468
+ if (this.element.hasAttribute("aria-describedby")) {
9469
+ this.checkAriaIdReferences(this.element, "aria-describedby", warnings, true);
9470
+ }
9471
+ const positiveTabIndexEls = Array.from(this.element.querySelectorAll("[tabindex]")).filter(
9472
+ (el) => el.tabIndex > 0
9473
+ );
9474
+ if (positiveTabIndexEls.length > 0) {
9475
+ warnings.push(
9476
+ `${positiveTabIndexEls.length} \xE9l\xE9ment(s) avec tabindex > 0 d\xE9tect\xE9(s) : utilisez uniquement tabindex="0" ou "-1" pour pr\xE9server l'ordre s\xE9quentiel de tabulation (WCAG 2.4.3).`
9477
+ );
9478
+ }
9225
9479
  return warnings;
9226
9480
  }
9227
9481
  getAuditPrefix() {
@@ -9251,7 +9505,8 @@ var __WulfIIFE = (() => {
9251
9505
  }
9252
9506
  isInsideToastContainer(target) {
9253
9507
  if (!target || !(target instanceof Element)) return false;
9254
- return Boolean(target.closest(".wulf-toast-container"));
9508
+ const container = target.closest(".wulf-toast-container");
9509
+ return Boolean(container && container.parentElement === document.body && !this.element.contains(container));
9255
9510
  }
9256
9511
  ensureContainerTabIndex() {
9257
9512
  if (this.element.getAttribute("tabindex") === null) {
@@ -9266,11 +9521,16 @@ var __WulfIIFE = (() => {
9266
9521
  return;
9267
9522
  }
9268
9523
  if (e.key === "Escape" && this.options.escapeDeactivates) {
9269
- if (isImeComposing(e)) return;
9270
- if (!this.isNativeModalDialog()) {
9271
- e.preventDefault();
9272
- e.stopPropagation();
9524
+ if (e.defaultPrevented || e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || isImeComposing(e)) return;
9525
+ const deepActive = getDeepActiveElement(document);
9526
+ if (this.isInsideToastContainer(deepActive) || this.isInsideToastContainer(e.target)) {
9527
+ return;
9528
+ }
9529
+ if (this.isNativeModalDialog()) {
9530
+ return;
9273
9531
  }
9532
+ e.preventDefault();
9533
+ e.stopPropagation();
9274
9534
  this.deactivate();
9275
9535
  return;
9276
9536
  }
@@ -9339,22 +9599,38 @@ var __WulfIIFE = (() => {
9339
9599
  }
9340
9600
  }
9341
9601
  /**
9342
- * Applique `inert` sur les éléments frères à chaque niveau hiérarchique jusqu'à <body>,
9343
- * en préservant les conteneurs de notifications Toast en Top Layer.
9602
+ * Applique `inert` sur les éléments frères à chaque niveau hiérarchique jusqu'à <body>
9603
+ * (y compris en remontant à travers les ShadowRoot.host), en préservant les conteneurs
9604
+ * de notifications Toast en Top Layer enfants directs de <body>.
9344
9605
  */
9345
9606
  applyInert() {
9346
9607
  this.removeInert();
9347
9608
  let current = this.element;
9348
9609
  const ignoredTags = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "LINK", "META", "NOSCRIPT"]);
9349
- while (current && current !== document.body && current.parentElement) {
9610
+ while (current && current !== document.body) {
9350
9611
  const parent = current.parentElement;
9351
- for (const sibling of Array.from(parent.children)) {
9352
- if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert") && !sibling.matches(".wulf-toast-container, .wulf-toast-announcer")) {
9353
- sibling.setAttribute("inert", "");
9354
- this.inertSiblings.push(sibling);
9612
+ if (parent) {
9613
+ for (const sibling of Array.from(parent.children)) {
9614
+ if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert") && !(parent === document.body && sibling.matches(".wulf-toast-container, .wulf-toast-announcer"))) {
9615
+ sibling.setAttribute("inert", "");
9616
+ this.inertSiblings.push(sibling);
9617
+ }
9618
+ }
9619
+ current = parent;
9620
+ } else {
9621
+ const root = typeof current.getRootNode === "function" ? current.getRootNode() : null;
9622
+ if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot) {
9623
+ for (const sibling of Array.from(root.children)) {
9624
+ if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert")) {
9625
+ sibling.setAttribute("inert", "");
9626
+ this.inertSiblings.push(sibling);
9627
+ }
9628
+ }
9629
+ current = root.host instanceof HTMLElement ? root.host : null;
9630
+ } else {
9631
+ break;
9355
9632
  }
9356
9633
  }
9357
- current = parent;
9358
9634
  }
9359
9635
  }
9360
9636
  removeInert() {
@@ -9367,11 +9643,15 @@ var __WulfIIFE = (() => {
9367
9643
  if (typeof this.options.initialFocus === "string") {
9368
9644
  targetEl = safeQuerySelector(this.element, this.options.initialFocus);
9369
9645
  } else if (this.options.initialFocus instanceof HTMLElement) {
9370
- targetEl = this.options.initialFocus;
9646
+ targetEl = this.element.contains(this.options.initialFocus) ? this.options.initialFocus : null;
9371
9647
  }
9372
- if (targetEl && this.isFocusable(targetEl)) {
9373
- targetEl.focus();
9374
- return;
9648
+ if (targetEl) {
9649
+ const isRadio = targetEl instanceof HTMLInputElement && targetEl.type === "radio" && Boolean(targetEl.name);
9650
+ const canFocus = isRadio && targetEl.tabIndex >= 0 ? this.isFocusable(targetEl) : this.isProgrammaticallyFocusable(targetEl);
9651
+ if (canFocus) {
9652
+ targetEl.focus();
9653
+ return;
9654
+ }
9375
9655
  }
9376
9656
  const focusables = this.getFocusableElements();
9377
9657
  if (focusables.length > 0) {
@@ -9382,13 +9662,13 @@ var __WulfIIFE = (() => {
9382
9662
  }
9383
9663
  }
9384
9664
  restoreFocus() {
9385
- if (this.previousActiveElement && this.previousActiveElement.isConnected && this.isElementFocusableBase(this.previousActiveElement)) {
9665
+ if (this.previousActiveElement && this.previousActiveElement.isConnected && this.isProgrammaticallyFocusable(this.previousActiveElement)) {
9386
9666
  this.previousActiveElement.focus();
9387
9667
  return;
9388
9668
  }
9389
9669
  if (this.options.fallbackReturnFocus) {
9390
9670
  const fallback = typeof this.options.fallbackReturnFocus === "string" ? safeQuerySelector(document, this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
9391
- if (fallback && fallback.isConnected && this.isElementFocusableBase(fallback)) {
9671
+ if (fallback && fallback.isConnected && this.isProgrammaticallyFocusable(fallback)) {
9392
9672
  fallback.focus();
9393
9673
  }
9394
9674
  }
@@ -9669,7 +9949,7 @@ var __WulfIIFE = (() => {
9669
9949
  case "backspace":
9670
9950
  return isApple ? "\u232B" : "Backspace";
9671
9951
  case "delete":
9672
- return isApple ? "\u2326" : "Suppr";
9952
+ return isApple ? "\u2326" : "Delete";
9673
9953
  case "arrowup":
9674
9954
  return "\u2191";
9675
9955
  case "arrowdown":
@@ -9685,7 +9965,14 @@ var __WulfIIFE = (() => {
9685
9965
  };
9686
9966
 
9687
9967
  // src/shortcut/ShortcutManager.ts
9688
- var ShortcutManager = class _ShortcutManager {
9968
+ var SENSITIVE_AUTOCOMPLETE_TOKENS = /* @__PURE__ */ new Set([
9969
+ "current-password",
9970
+ "new-password",
9971
+ "one-time-code",
9972
+ "cc-number",
9973
+ "cc-csc"
9974
+ ]);
9975
+ var ShortcutManager = class _ShortcutManager extends AuditableComponent {
9689
9976
  options;
9690
9977
  shortcuts = /* @__PURE__ */ new Map();
9691
9978
  scopeStack = [];
@@ -9696,6 +9983,7 @@ var __WulfIIFE = (() => {
9696
9983
  abortController = null;
9697
9984
  idCounter = 0;
9698
9985
  constructor(options) {
9986
+ super();
9699
9987
  const rawTimeout = options?.sequenceTimeout;
9700
9988
  const sequenceTimeout = typeof rawTimeout === "number" && Number.isFinite(rawTimeout) && rawTimeout > 0 ? Math.min(rawTimeout, 1e4) : 800;
9701
9989
  this.options = {
@@ -9725,10 +10013,11 @@ var __WulfIIFE = (() => {
9725
10013
  if (tagName === "TEXTAREA" || tagName === "SELECT") {
9726
10014
  return true;
9727
10015
  }
9728
- if (el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "plaintext-only" || el.getAttribute("contenteditable") === "") {
10016
+ const contentEditable = el.getAttribute?.("contenteditable")?.toLowerCase();
10017
+ if (el.isContentEditable || contentEditable === "true" || contentEditable === "plaintext-only" || contentEditable === "") {
9729
10018
  return true;
9730
10019
  }
9731
- const role = el.getAttribute("role");
10020
+ const role = el.getAttribute?.("role");
9732
10021
  if (role === "textbox" || role === "searchbox" || role === "combobox" || role === "spinbutton") {
9733
10022
  return true;
9734
10023
  }
@@ -9743,14 +10032,45 @@ var __WulfIIFE = (() => {
9743
10032
  return false;
9744
10033
  }
9745
10034
  /**
9746
- * Vérifie si la cible est un champ de mot de passe (sanctuaire anti-keylogging).
10035
+ * Vérifie si la cible appartient à un widget composite à typeahead clavier (listbox, menu, tree, grid).
10036
+ */
10037
+ static isTypeaheadWidget(target) {
10038
+ if (!target || typeof target.tagName !== "string") {
10039
+ return false;
10040
+ }
10041
+ const el = target;
10042
+ const role = el.getAttribute?.("role");
10043
+ if (role === "listbox" || role === "menu" || role === "menubar" || role === "tree" || role === "grid") {
10044
+ return true;
10045
+ }
10046
+ if (typeof el.closest === "function") {
10047
+ return Boolean(el.closest('[role="listbox"], [role="menu"], [role="menubar"], [role="tree"], [role="grid"]'));
10048
+ }
10049
+ return false;
10050
+ }
10051
+ /**
10052
+ * Vérifie si la cible est un champ sensible (password, data-mask-sensitive, autocomplete sensible).
9747
10053
  */
9748
- static isPasswordField(target) {
10054
+ static isSensitiveField(target) {
9749
10055
  if (!target || typeof target.tagName !== "string") {
9750
10056
  return false;
9751
10057
  }
9752
10058
  const el = target;
9753
- return el.tagName.toUpperCase() === "INPUT" && (el.type || "").toLowerCase() === "password";
10059
+ if (el.tagName.toUpperCase() === "INPUT" && (el.type || "").toLowerCase() === "password") {
10060
+ return true;
10061
+ }
10062
+ const sensitiveAttr = el.getAttribute?.("data-mask-sensitive");
10063
+ if (sensitiveAttr !== null && sensitiveAttr !== void 0 && sensitiveAttr !== "false") {
10064
+ return true;
10065
+ }
10066
+ const ac = el.getAttribute?.("autocomplete");
10067
+ if (ac) {
10068
+ const tokens = ac.trim().toLowerCase().split(/\s+/);
10069
+ if (tokens.some((tok) => SENSITIVE_AUTOCOMPLETE_TOKENS.has(tok))) {
10070
+ return true;
10071
+ }
10072
+ }
10073
+ return false;
9754
10074
  }
9755
10075
  /**
9756
10076
  * Enregistre un ou plusieurs raccourcis clavier.
@@ -9763,8 +10083,11 @@ var __WulfIIFE = (() => {
9763
10083
  if (!def.combo || typeof def.handler !== "function") {
9764
10084
  continue;
9765
10085
  }
9766
- const id = `wulf_shortcut_${++this.idCounter}`;
9767
10086
  const normalizedSteps = ShortcutFormatter.parseCombo(def.combo);
10087
+ if (normalizedSteps.length === 0 || normalizedSteps.some((step) => !step.key)) {
10088
+ continue;
10089
+ }
10090
+ const id = `wulf_shortcut_${++this.idCounter}`;
9768
10091
  const isSequence = normalizedSteps.length > 1;
9769
10092
  const formattedCombo = ShortcutFormatter.format(def.combo);
9770
10093
  const registered = {
@@ -9883,11 +10206,47 @@ var __WulfIIFE = (() => {
9883
10206
  const list = [];
9884
10207
  for (const shortcut of this.shortcuts.values()) {
9885
10208
  if (!scope || shortcut.scope === scope || shortcut.scope === "*") {
9886
- list.push({ ...shortcut });
10209
+ list.push({
10210
+ ...shortcut,
10211
+ normalizedSteps: shortcut.normalizedSteps.map((step) => ({ ...step }))
10212
+ });
9887
10213
  }
9888
10214
  }
9889
10215
  return list;
9890
10216
  }
10217
+ /**
10218
+ * Audite le registre des raccourcis vis-à-vis de WCAG 2.1.4 et de l'Axiome Primordial.
10219
+ */
10220
+ audit() {
10221
+ const warnings = [];
10222
+ const criticalEditKeys = /* @__PURE__ */ new Set(["c", "v", "x", "a", "z"]);
10223
+ for (const shortcut of this.shortcuts.values()) {
10224
+ const isSingleCharWithoutMod = shortcut.normalizedSteps.length > 0 && shortcut.normalizedSteps.every(
10225
+ (step) => !step.ctrl && !step.alt && !step.meta && step.key.length === 1
10226
+ );
10227
+ if (isSingleCharWithoutMod) {
10228
+ warnings.push(
10229
+ `Raccourci mono-caract\xE8re sans modificateur "${shortcut.combo}" : pr\xE9voyez une option pour le d\xE9sactiver ou le reconfigurer (WCAG 2.1.4).`
10230
+ );
10231
+ }
10232
+ if (shortcut.allowInEditable && !shortcut.isSequence && shortcut.normalizedSteps.length === 1) {
10233
+ const s = shortcut.normalizedSteps[0];
10234
+ const isPrimaryModOnly = !s.alt && !s.shift && (s.ctrl && !s.meta || s.meta && !s.ctrl);
10235
+ if (isPrimaryModOnly && criticalEditKeys.has(s.key)) {
10236
+ warnings.push(
10237
+ `Raccourci "${shortcut.combo}" avec allowInEditable: true risque d'\xE9craser une commande d'\xE9dition native (Ctrl/Cmd+${s.key.toUpperCase()}).`
10238
+ );
10239
+ }
10240
+ }
10241
+ }
10242
+ return warnings;
10243
+ }
10244
+ getAuditPrefix() {
10245
+ return "Wulf.Shortcut";
10246
+ }
10247
+ getAuditTargetLabel() {
10248
+ return `${this.shortcuts.size} raccourci(s)`;
10249
+ }
9891
10250
  /**
9892
10251
  * Associe l'attribut standard WAI-ARIA `aria-keyshortcuts` sur un élément DOM.
9893
10252
  */
@@ -9954,9 +10313,15 @@ var __WulfIIFE = (() => {
9954
10313
  }
9955
10314
  const currentScope = this.getScope();
9956
10315
  const composed = typeof event.composedPath === "function" ? event.composedPath() : [];
9957
- const actualTarget = composed.length > 0 ? composed[0] : event.target;
9958
- const isEditable = _ShortcutManager.isEditable(actualTarget) || _ShortcutManager.isEditable(event.target);
9959
- const isPasswordInput = _ShortcutManager.isPasswordField(actualTarget) || _ShortcutManager.isPasswordField(event.target);
10316
+ const pathTargets = composed.length > 0 ? composed : event.target ? [event.target] : [];
10317
+ let isEditable = _ShortcutManager.isEditable(event.target);
10318
+ let isSensitiveInput = _ShortcutManager.isSensitiveField(event.target);
10319
+ let isTypeahead = _ShortcutManager.isTypeaheadWidget(event.target);
10320
+ for (const node of pathTargets) {
10321
+ if (!isEditable && _ShortcutManager.isEditable(node)) isEditable = true;
10322
+ if (!isSensitiveInput && _ShortcutManager.isSensitiveField(node)) isSensitiveInput = true;
10323
+ if (!isTypeahead && _ShortcutManager.isTypeaheadWidget(node)) isTypeahead = true;
10324
+ }
9960
10325
  const currentStep = {
9961
10326
  ctrl: event.ctrlKey,
9962
10327
  alt: event.altKey,
@@ -9964,14 +10329,14 @@ var __WulfIIFE = (() => {
9964
10329
  meta: event.metaKey,
9965
10330
  key: ShortcutFormatter.normalizeKeyName(event.key || "")
9966
10331
  };
9967
- const now = event.timeStamp > 0 ? event.timeStamp : typeof performance !== "undefined" ? performance.now() : Date.now();
10332
+ const now = typeof performance !== "undefined" ? performance.now() : Date.now();
9968
10333
  if (this.sequenceBuffer.length > 0) {
9969
10334
  const last = this.sequenceBuffer[this.sequenceBuffer.length - 1];
9970
10335
  if (now - last.timestamp > this.options.sequenceTimeout) {
9971
10336
  this.clearSequenceBuffer();
9972
10337
  }
9973
10338
  }
9974
- const activeCandidates = this.getActiveShortcuts(currentScope, isEditable, isPasswordInput);
10339
+ const activeCandidates = this.getActiveShortcuts(currentScope, isEditable, isSensitiveInput, isTypeahead);
9975
10340
  const proposedSequence = [...this.sequenceBuffer.map((b) => b.step), currentStep];
9976
10341
  const matchingSequence = this.findMatchingSequence(activeCandidates, proposedSequence);
9977
10342
  if (matchingSequence) {
@@ -9982,7 +10347,7 @@ var __WulfIIFE = (() => {
9982
10347
  if (this.isPrefixOfAnySequence(activeCandidates, proposedSequence)) {
9983
10348
  this.sequenceBuffer.push({ step: currentStep, timestamp: now });
9984
10349
  this.resetSequenceTimer();
9985
- if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !isEditable) {
10350
+ if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !isEditable && !isTypeahead) {
9986
10351
  event.preventDefault();
9987
10352
  }
9988
10353
  return;
@@ -9993,7 +10358,7 @@ var __WulfIIFE = (() => {
9993
10358
  this.executeShortcut(matchingChord, event, currentScope, false);
9994
10359
  }
9995
10360
  }
9996
- getActiveShortcuts(currentScope, isEditable, isPasswordInput = false) {
10361
+ getActiveShortcuts(currentScope, isEditable, isSensitiveInput = false, isTypeahead = false) {
9997
10362
  const list = [];
9998
10363
  for (const shortcut of this.shortcuts.values()) {
9999
10364
  if (shortcut.scope !== currentScope && shortcut.scope !== "*") {
@@ -10002,15 +10367,25 @@ var __WulfIIFE = (() => {
10002
10367
  if (isEditable && !shortcut.allowInEditable) {
10003
10368
  continue;
10004
10369
  }
10005
- if (isPasswordInput) {
10370
+ if (isTypeahead) {
10371
+ const firstStep = shortcut.normalizedSteps[0];
10372
+ if (firstStep && !firstStep.ctrl && !firstStep.alt && !firstStep.meta && firstStep.key.length === 1) {
10373
+ continue;
10374
+ }
10375
+ }
10376
+ if (isSensitiveInput) {
10006
10377
  if (shortcut.isSequence) {
10007
10378
  continue;
10008
10379
  }
10009
10380
  const firstStep = shortcut.normalizedSteps[0];
10010
- if (firstStep && firstStep.key.length === 1) {
10011
- const isUntouchedChar = !firstStep.ctrl && !firstStep.alt && !firstStep.meta;
10012
- const isAltGrOrOptionChar = firstStep.ctrl && firstStep.alt && !firstStep.meta || firstStep.alt && !firstStep.ctrl && !firstStep.meta;
10013
- if (isUntouchedChar || isAltGrOrOptionChar) {
10381
+ if (firstStep) {
10382
+ if (firstStep.key.length === 1) {
10383
+ const isUntouchedChar = !firstStep.ctrl && !firstStep.alt && !firstStep.meta;
10384
+ const isAltGrOrOptionChar = firstStep.ctrl && firstStep.alt && !firstStep.meta || firstStep.alt && !firstStep.ctrl && !firstStep.meta;
10385
+ if (isUntouchedChar || isAltGrOrOptionChar) {
10386
+ continue;
10387
+ }
10388
+ } else if (!firstStep.ctrl && !firstStep.alt && !firstStep.meta && (firstStep.key === "backspace" || firstStep.key === "delete" || firstStep.key === "dead")) {
10014
10389
  continue;
10015
10390
  }
10016
10391
  }
@@ -10103,7 +10478,11 @@ var __WulfIIFE = (() => {
10103
10478
  shortcut.handler(event, info);
10104
10479
  } catch (err) {
10105
10480
  if (this.options.onError) {
10106
- this.options.onError(err instanceof Error ? err : new Error(String(err)), shortcut.combo);
10481
+ try {
10482
+ this.options.onError(err instanceof Error ? err : new Error(String(err)), shortcut.combo);
10483
+ } catch (onErrException) {
10484
+ console.error("[Wulf.Shortcut] Erreur dans le callback onError:", onErrException);
10485
+ }
10107
10486
  } else {
10108
10487
  console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${shortcut.combo}":`, err);
10109
10488
  }