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
package/dist/index.esm.js CHANGED
@@ -43,6 +43,10 @@ function safeCssEscape(value) {
43
43
  }
44
44
  return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
45
45
  }
46
+ function stripBidiAndInvisibles(raw, maxLength = 4096) {
47
+ const safeLimit = Math.max(0, maxLength);
48
+ return String(raw ?? "").slice(0, safeLimit).replace(/[\u061C\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, "");
49
+ }
46
50
  function getDeepActiveElement(root) {
47
51
  if (typeof document === "undefined") return null;
48
52
  let active = (root ?? document).activeElement;
@@ -191,10 +195,6 @@ var AuditableComponent = class {
191
195
 
192
196
  // src/mask/paste.ts
193
197
  var MAX_PASTE_LENGTH = 4096;
194
- function stripBidiAndInvisibles(raw, maxLength = MAX_PASTE_LENGTH) {
195
- const safeLimit = Math.max(0, maxLength);
196
- return String(raw ?? "").slice(0, safeLimit).replace(/[\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, "");
197
- }
198
198
  function sanitizePastedText(raw, maxLength = MAX_PASTE_LENGTH) {
199
199
  return stripBidiAndInvisibles(raw, maxLength).replace(/[\u00A0\u202F\u2007]/g, " ").replace(/[\u2013\u2014\u2212]/g, "-").trim();
200
200
  }
@@ -6428,6 +6428,8 @@ var ScrollBlock = class extends LocalizedComponent {
6428
6428
  trackX;
6429
6429
  thumbX;
6430
6430
  resizeObserver;
6431
+ mutationObserver;
6432
+ observedChildren = /* @__PURE__ */ new Set();
6431
6433
  hideTimer;
6432
6434
  scrollEndFallbackTimer;
6433
6435
  rafId = null;
@@ -6479,7 +6481,7 @@ var ScrollBlock = class extends LocalizedComponent {
6479
6481
  this.root = resolvedElement;
6480
6482
  this.hasExplicitAriaLabel = Boolean(options?.ariaLabel || options?.i18n?.viewport);
6481
6483
  const rawDelay = options?.autoHideDelay;
6482
- const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? rawDelay : 1e3;
6484
+ const safeAutoHideDelay = typeof rawDelay === "number" && Number.isFinite(rawDelay) && rawDelay >= 0 ? Math.min(rawDelay, 2147483647) : 1e3;
6483
6485
  const rawMinThumb = options?.minThumbSize;
6484
6486
  const safeMinThumbSize = typeof rawMinThumb === "number" && Number.isFinite(rawMinThumb) && rawMinThumb > 0 ? rawMinThumb : 24;
6485
6487
  const rawEdge = options?.edgeThreshold;
@@ -6776,22 +6778,28 @@ var ScrollBlock = class extends LocalizedComponent {
6776
6778
  * Initialise le ResizeObserver réactif.
6777
6779
  */
6778
6780
  setupObserver() {
6779
- if (typeof ResizeObserver !== "undefined") {
6780
- this.resizeObserver = new ResizeObserver(() => {
6781
- if (this.isDestroyed || this.resizeRafId !== null) return;
6782
- this.resizeRafId = window.requestAnimationFrame(() => {
6783
- this.resizeRafId = null;
6784
- if (!this.isDestroyed) {
6785
- this.update();
6786
- }
6787
- });
6781
+ const scheduleUpdate = () => {
6782
+ if (this.isDestroyed || this.resizeRafId !== null) return;
6783
+ this.resizeRafId = window.requestAnimationFrame(() => {
6784
+ this.resizeRafId = null;
6785
+ if (!this.isDestroyed) {
6786
+ this.update();
6787
+ }
6788
6788
  });
6789
+ };
6790
+ if (typeof ResizeObserver !== "undefined") {
6791
+ this.resizeObserver = new ResizeObserver(scheduleUpdate);
6789
6792
  this.resizeObserver.observe(this.root);
6790
6793
  this.resizeObserver.observe(this.viewport);
6791
- if (this.viewport.firstElementChild) {
6792
- this.resizeObserver.observe(this.viewport.firstElementChild);
6794
+ for (const child of Array.from(this.viewport.children)) {
6795
+ this.resizeObserver.observe(child);
6796
+ this.observedChildren.add(child);
6793
6797
  }
6794
6798
  }
6799
+ if (typeof MutationObserver !== "undefined") {
6800
+ this.mutationObserver = new MutationObserver(scheduleUpdate);
6801
+ this.mutationObserver.observe(this.viewport, { childList: true });
6802
+ }
6795
6803
  }
6796
6804
  /**
6797
6805
  * Déplacement lors du glissement du curseur.
@@ -6867,16 +6875,28 @@ var ScrollBlock = class extends LocalizedComponent {
6867
6875
  this.scheduleSyncThumbs();
6868
6876
  const info = this.getScrollInfo();
6869
6877
  const { top: scrollTop, left: scrollLeft, maxTop, maxLeft } = info;
6870
- this.options.onScroll(info);
6878
+ try {
6879
+ this.options.onScroll(info);
6880
+ } catch (err) {
6881
+ console.error("[Wulf.Scroll] Erreur dans onScroll:", err);
6882
+ }
6871
6883
  const threshold = this.options.edgeThreshold;
6872
6884
  if (maxTop > 0) {
6873
6885
  const nowBottom = scrollTop >= maxTop - threshold;
6874
6886
  const nowTop = scrollTop <= threshold;
6875
6887
  if (nowBottom && !this.atBottom) {
6876
- this.options.onTotalScroll("bottom");
6888
+ try {
6889
+ this.options.onTotalScroll("bottom");
6890
+ } catch (err) {
6891
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
6892
+ }
6877
6893
  }
6878
6894
  if (nowTop && !this.atTop) {
6879
- this.options.onTotalScrollBack("top");
6895
+ try {
6896
+ this.options.onTotalScrollBack("top");
6897
+ } catch (err) {
6898
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
6899
+ }
6880
6900
  }
6881
6901
  this.atBottom = nowBottom;
6882
6902
  this.atTop = nowTop;
@@ -6886,10 +6906,18 @@ var ScrollBlock = class extends LocalizedComponent {
6886
6906
  const nowRight = rtl ? scrollLeft >= -threshold : scrollLeft >= maxLeft - threshold;
6887
6907
  const nowLeft = rtl ? scrollLeft <= -maxLeft + threshold : scrollLeft <= threshold;
6888
6908
  if (nowRight && !this.atRight) {
6889
- this.options.onTotalScroll("right");
6909
+ try {
6910
+ this.options.onTotalScroll("right");
6911
+ } catch (err) {
6912
+ console.error("[Wulf.Scroll] Erreur dans onTotalScroll:", err);
6913
+ }
6890
6914
  }
6891
6915
  if (nowLeft && !this.atLeft) {
6892
- this.options.onTotalScrollBack("left");
6916
+ try {
6917
+ this.options.onTotalScrollBack("left");
6918
+ } catch (err) {
6919
+ console.error("[Wulf.Scroll] Erreur dans onTotalScrollBack:", err);
6920
+ }
6893
6921
  }
6894
6922
  this.atRight = nowRight;
6895
6923
  this.atLeft = nowLeft;
@@ -6915,7 +6943,11 @@ var ScrollBlock = class extends LocalizedComponent {
6915
6943
  * Gestionnaire de fin de défilement (`scrollend` natif ou repli temporisé).
6916
6944
  */
6917
6945
  handleScrollEnd() {
6918
- this.options.onScrollEnd(this.getScrollInfo());
6946
+ try {
6947
+ this.options.onScrollEnd(this.getScrollInfo());
6948
+ } catch (err) {
6949
+ console.error("[Wulf.Scroll] Erreur dans onScrollEnd:", err);
6950
+ }
6919
6951
  if (this.options.mode !== "native" && this.options.autoHide && !this.options.alwaysVisible) {
6920
6952
  this.scheduleAutoHide();
6921
6953
  }
@@ -6942,24 +6974,34 @@ var ScrollBlock = class extends LocalizedComponent {
6942
6974
  if (this.thumbY && this.trackY) {
6943
6975
  const maxScrollY = this.cachedMaxTop;
6944
6976
  const maxTravelY = this.cachedTrackHeight - this.cachedThumbHeight;
6945
- if (maxScrollY > 0 && maxTravelY > 0) {
6977
+ if (maxScrollY > 0) {
6946
6978
  const ratioY = Math.max(0, Math.min(1, scrollTop / maxScrollY));
6947
- const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
6948
- this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
6949
6979
  this.thumbY.setAttribute("aria-valuenow", String(Math.round(ratioY * 100)));
6980
+ if (maxTravelY > 0) {
6981
+ const posY = Math.max(0, Math.min(maxTravelY, ratioY * maxTravelY));
6982
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", `${posY}px`);
6983
+ }
6984
+ } else {
6985
+ this.thumbY.setAttribute("aria-valuenow", "0");
6986
+ this.thumbY.style.setProperty("--scrollblock-thumb-y", "0px");
6950
6987
  }
6951
6988
  }
6952
6989
  if (this.thumbX && this.trackX) {
6953
6990
  const maxScrollX = this.cachedMaxLeft;
6954
6991
  const maxTravelX = this.cachedTrackWidth - this.cachedThumbWidth;
6955
- if (maxScrollX > 0 && maxTravelX > 0) {
6992
+ if (maxScrollX > 0) {
6956
6993
  const rtl = this.isRtl();
6957
6994
  const logicalLeft = rtl ? Math.max(0, -scrollLeft) : Math.max(0, scrollLeft);
6958
6995
  const ratioX = Math.max(0, Math.min(1, logicalLeft / maxScrollX));
6959
- const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
6960
- const signedPosX = rtl ? -posX : posX;
6961
- this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
6962
6996
  this.thumbX.setAttribute("aria-valuenow", String(Math.round(ratioX * 100)));
6997
+ if (maxTravelX > 0) {
6998
+ const posX = Math.max(0, Math.min(maxTravelX, ratioX * maxTravelX));
6999
+ const signedPosX = rtl ? -posX : posX;
7000
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", `${signedPosX}px`);
7001
+ }
7002
+ } else {
7003
+ this.thumbX.setAttribute("aria-valuenow", "0");
7004
+ this.thumbX.style.setProperty("--scrollblock-thumb-x", "0px");
6963
7005
  }
6964
7006
  }
6965
7007
  }
@@ -6997,6 +7039,21 @@ var ScrollBlock = class extends LocalizedComponent {
6997
7039
  update() {
6998
7040
  if (this.isDestroyed) return;
6999
7041
  this.syncAccessibilityLabels();
7042
+ if (this.resizeObserver) {
7043
+ const currentChildren = new Set(Array.from(this.viewport.children));
7044
+ for (const prev of this.observedChildren) {
7045
+ if (!currentChildren.has(prev)) {
7046
+ this.resizeObserver.unobserve(prev);
7047
+ this.observedChildren.delete(prev);
7048
+ }
7049
+ }
7050
+ for (const child of currentChildren) {
7051
+ if (!this.observedChildren.has(child)) {
7052
+ this.resizeObserver.observe(child);
7053
+ this.observedChildren.add(child);
7054
+ }
7055
+ }
7056
+ }
7000
7057
  const { scrollHeight, clientHeight, scrollWidth, clientWidth } = this.viewport;
7001
7058
  const trackHeight = this.trackY ? this.trackY.clientHeight : 0;
7002
7059
  const trackWidth = this.trackX ? this.trackX.clientWidth : 0;
@@ -7115,10 +7172,12 @@ var ScrollBlock = class extends LocalizedComponent {
7115
7172
  }
7116
7173
  }
7117
7174
  } else if (target instanceof HTMLElement) {
7118
- const vpRect = this.viewport.getBoundingClientRect();
7119
- const elRect = target.getBoundingClientRect();
7120
- targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
7121
- targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
7175
+ if (target.isConnected && this.viewport.contains(target)) {
7176
+ const vpRect = this.viewport.getBoundingClientRect();
7177
+ const elRect = target.getBoundingClientRect();
7178
+ targetTop = elRect.top - vpRect.top - this.viewport.clientTop + scrollTop;
7179
+ targetLeft = elRect.left - vpRect.left - this.viewport.clientLeft + scrollLeft;
7180
+ }
7122
7181
  } else if (typeof target === "object" && target !== null) {
7123
7182
  targetTop = target.top;
7124
7183
  targetLeft = target.left;
@@ -7189,8 +7248,8 @@ var ScrollBlock = class extends LocalizedComponent {
7189
7248
  */
7190
7249
  audit() {
7191
7250
  const warnings = [];
7192
- const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings);
7193
- const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
7251
+ const hasViewportLabelledby = this.checkAriaIdReferences(this.viewport, "aria-labelledby", warnings, true);
7252
+ const hasRootLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
7194
7253
  const hasValidLabelledby = hasViewportLabelledby || hasRootLabelledby;
7195
7254
  const rootAriaLabel = this.root.getAttribute("aria-label")?.trim();
7196
7255
  const hasCustomViewportAriaLabel = !this.wasAriaLabelInferred && Boolean(this.viewport.getAttribute("aria-label")?.trim());
@@ -7204,6 +7263,16 @@ var ScrollBlock = class extends LocalizedComponent {
7204
7263
  `Taille minimale du curseur insuffisante (minThumbSize: ${this.options.minThumbSize}px) : utilisez au moins 24px pour respecter WCAG 2.5.8.`
7205
7264
  );
7206
7265
  }
7266
+ if (this.root.tabIndex > 0 || this.viewport.tabIndex > 0) {
7267
+ warnings.push(
7268
+ 'Attribut tabindex > 0 d\xE9tect\xE9 sur la zone d\xE9filable : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).'
7269
+ );
7270
+ }
7271
+ if (this.root.getAttribute("role") === "region" && this.viewport.getAttribute("role") === "region") {
7272
+ warnings.push(
7273
+ 'Landmark role="region" redondant : \xE9vitez de d\xE9clarer role="region" \xE0 la fois sur le conteneur racine et sur le viewport interne.'
7274
+ );
7275
+ }
7207
7276
  return warnings;
7208
7277
  }
7209
7278
  getAuditPrefix() {
@@ -7217,6 +7286,9 @@ var ScrollBlock = class extends LocalizedComponent {
7217
7286
  */
7218
7287
  destroy() {
7219
7288
  if (this.isDestroyed) return;
7289
+ if (this.isDragging) {
7290
+ this.handlePointerUp();
7291
+ }
7220
7292
  this.isDestroyed = true;
7221
7293
  this.clearAutoHideTimer();
7222
7294
  if (this.scrollEndFallbackTimer !== void 0) {
@@ -7239,6 +7311,11 @@ var ScrollBlock = class extends LocalizedComponent {
7239
7311
  if (this.resizeObserver) {
7240
7312
  this.resizeObserver.disconnect();
7241
7313
  }
7314
+ if (this.mutationObserver) {
7315
+ this.mutationObserver.disconnect();
7316
+ this.mutationObserver = void 0;
7317
+ }
7318
+ this.observedChildren.clear();
7242
7319
  this.trackY?.remove();
7243
7320
  this.trackX?.remove();
7244
7321
  this.root.classList.remove(
@@ -7423,9 +7500,10 @@ var LayoutEngine = class {
7423
7500
  const colHeights = new Array(cols).fill(0);
7424
7501
  const positions = [];
7425
7502
  const itemHeights = items.map((item) => {
7426
- const h = item.getBoundingClientRect().height;
7503
+ const h = item.classList.contains("wulf-masonry-item--hidden") && item.offsetHeight > 0 ? item.offsetHeight : item.getBoundingClientRect().height;
7427
7504
  return h > 0 ? h : 50;
7428
7505
  });
7506
+ const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
7429
7507
  let currentHCol = 0;
7430
7508
  for (let i = 0; i < items.length; i++) {
7431
7509
  const item = items[i];
@@ -7476,7 +7554,6 @@ var LayoutEngine = class {
7476
7554
  }
7477
7555
  }
7478
7556
  const itemW = span * colWidth + (span - 1) * gutterX;
7479
- const isRtl = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(container).direction === "rtl";
7480
7557
  const effectiveWidth = fittedWidth !== void 0 ? fittedWidth : containerWidth;
7481
7558
  const rawX = targetCol * (colWidth + gutterX);
7482
7559
  const targetX = isRtl ? Math.max(0, effectiveWidth - rawX - itemW) : rawX;
@@ -7531,6 +7608,7 @@ var masonryI18n = createI18nManager("fr", {
7531
7608
  });
7532
7609
 
7533
7610
  // src/masonry/Masonry.ts
7611
+ var NATIVE_STRUCTURAL_TAGS = /* @__PURE__ */ new Set(["UL", "OL", "MAIN", "NAV", "ASIDE", "ARTICLE", "SECTION"]);
7534
7612
  var Masonry = class extends LocalizedComponent {
7535
7613
  static _i18n = masonryI18n;
7536
7614
  static i18n = masonryI18n;
@@ -7542,9 +7620,11 @@ var Masonry = class extends LocalizedComponent {
7542
7620
  itemResizeObserver = null;
7543
7621
  observedItems = /* @__PURE__ */ new Set();
7544
7622
  observedItemHeights = /* @__PURE__ */ new WeakMap();
7545
- removingItems = /* @__PURE__ */ new WeakSet();
7623
+ removingItems = /* @__PURE__ */ new Set();
7546
7624
  layoutRafId = null;
7625
+ lastObservedWidth = 0;
7547
7626
  isDestroyed = false;
7627
+ hasExplicitAriaRole = false;
7548
7628
  wasRoleInferred = false;
7549
7629
  wasAriaLabelInferred = false;
7550
7630
  hasExplicitAriaLabel = false;
@@ -7574,6 +7654,7 @@ var Masonry = class extends LocalizedComponent {
7574
7654
  height: this.root.style.height,
7575
7655
  width: this.root.style.width
7576
7656
  };
7657
+ this.hasExplicitAriaRole = Boolean(options.ariaRole);
7577
7658
  this.hasExplicitAriaLabel = Boolean(options.ariaLabel || options.i18n?.gallery);
7578
7659
  this.options = {
7579
7660
  itemSelector: options.itemSelector || "> *",
@@ -7619,7 +7700,7 @@ var Masonry = class extends LocalizedComponent {
7619
7700
  * Initialise les attributs WAI-ARIA du conteneur.
7620
7701
  */
7621
7702
  initAccessibility() {
7622
- if (this.options.ariaRole && !this.root.hasAttribute("role")) {
7703
+ if (this.options.ariaRole && !this.root.hasAttribute("role") && (this.hasExplicitAriaRole || !NATIVE_STRUCTURAL_TAGS.has(this.root.tagName))) {
7623
7704
  this.root.setAttribute("role", this.options.ariaRole);
7624
7705
  this.wasRoleInferred = true;
7625
7706
  }
@@ -7651,9 +7732,10 @@ var Masonry = class extends LocalizedComponent {
7651
7732
  const dur = this.options.transitionDuration;
7652
7733
  let durValue = "300ms";
7653
7734
  if (typeof dur === "number" && Number.isFinite(dur) && dur >= 0) {
7654
- durValue = `${dur}ms`;
7735
+ durValue = `${Math.min(dur, 6e4)}ms`;
7655
7736
  } else if (typeof dur === "string" && /^\s*(?:\d+(?:\.\d+)?|\.\d+)(ms|s)\s*$/i.test(dur)) {
7656
- durValue = dur.trim();
7737
+ const parsedMs = parseCssDurationMs(dur, 300, 6e4);
7738
+ durValue = parsedMs >= 6e4 ? "60000ms" : dur.trim();
7657
7739
  }
7658
7740
  this.root.style.setProperty("--wulf-masonry-duration", durValue);
7659
7741
  }
@@ -7704,12 +7786,12 @@ var Masonry = class extends LocalizedComponent {
7704
7786
  */
7705
7787
  initObservers() {
7706
7788
  if (!this.options.resize || typeof ResizeObserver === "undefined") return;
7707
- let prevWidth = this.root.getBoundingClientRect().width;
7789
+ this.lastObservedWidth = this.root.getBoundingClientRect().width;
7708
7790
  this.resizeObserver = new ResizeObserver((entries) => {
7709
7791
  for (const entry of entries) {
7710
7792
  const currentWidth = entry.contentRect.width;
7711
- if (Math.abs(currentWidth - prevWidth) >= 1) {
7712
- prevWidth = currentWidth;
7793
+ if (Math.abs(currentWidth - this.lastObservedWidth) >= 1) {
7794
+ this.lastObservedWidth = currentWidth;
7713
7795
  this.scheduleLayout();
7714
7796
  }
7715
7797
  }
@@ -7751,15 +7833,23 @@ var Masonry = class extends LocalizedComponent {
7751
7833
  this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
7752
7834
  }
7753
7835
  } else if (typeof this.options.columnWidth === "string" && this.options.columnWidth.trim()) {
7754
- try {
7755
- const el = this.root.querySelector(this.options.columnWidth);
7756
- if (el) {
7757
- const w = el.getBoundingClientRect().width;
7758
- if (w > 0) {
7759
- this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
7836
+ const trimmed = this.options.columnWidth.trim();
7837
+ if (/^\d+(\.\d+)?(px|%)?$/i.test(trimmed)) {
7838
+ const w = LayoutEngine.resolveColumnWidth(this.root, null, trimmed);
7839
+ if (w > 0) {
7840
+ this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
7841
+ }
7842
+ } else {
7843
+ try {
7844
+ const el = this.root.querySelector(trimmed);
7845
+ if (el) {
7846
+ const w = el.getBoundingClientRect().width;
7847
+ if (w > 0) {
7848
+ this.root.style.setProperty("--wulf-masonry-col-min", `${w}px`);
7849
+ }
7760
7850
  }
7851
+ } catch {
7761
7852
  }
7762
- } catch {
7763
7853
  }
7764
7854
  }
7765
7855
  }
@@ -7813,60 +7903,80 @@ var Masonry = class extends LocalizedComponent {
7813
7903
  for (const el of this._items) {
7814
7904
  el.classList.remove("wulf-masonry-item--hidden");
7815
7905
  }
7816
- this.options.onLayout([]);
7906
+ try {
7907
+ this.options.onLayout([]);
7908
+ } catch (err) {
7909
+ console.error("[Wulf.Masonry] Erreur dans onLayout:", err);
7910
+ }
7817
7911
  return;
7818
7912
  }
7819
7913
  this.root.setAttribute("aria-busy", "true");
7820
- if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
7821
- this.root.style.width = "";
7822
- }
7823
- const result = LayoutEngine.calculate(this.root, this._items, this.options);
7824
- this.root.style.height = `${result.containerHeight}px`;
7825
- if (this.options.fitWidth && result.fittedWidth !== void 0) {
7826
- this.root.style.width = `${result.fittedWidth}px`;
7827
- this.root.classList.add("wulf-masonry--fit-width");
7828
- } else {
7829
- this.root.classList.remove("wulf-masonry--fit-width");
7830
- }
7831
- const stagger = this.options.stagger;
7832
- const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
7833
- if (validStagger) {
7834
- this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
7835
- } else {
7836
- this.root.style.removeProperty("--wulf-masonry-stagger");
7837
- }
7838
- const hasIgnoredChildren = this._items.length !== this.root.children.length;
7839
- const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
7840
- const usePercent = this.options.percentPosition && result.containerWidth > 0;
7841
- for (let i = 0; i < result.positions.length; i++) {
7842
- const pos = result.positions[i];
7843
- const item = pos.element;
7844
- if (usePercent) {
7845
- const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
7846
- item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
7914
+ let positionsResult = [];
7915
+ try {
7916
+ if (this.options.fitWidth && this.root.classList.contains("wulf-masonry--fit-width")) {
7917
+ this.root.style.width = "";
7918
+ }
7919
+ const result = LayoutEngine.calculate(this.root, this._items, this.options);
7920
+ positionsResult = result.positions;
7921
+ this.root.style.height = `${result.containerHeight}px`;
7922
+ if (this.options.fitWidth && result.fittedWidth !== void 0) {
7923
+ this.root.style.width = `${result.fittedWidth}px`;
7924
+ this.lastObservedWidth = result.fittedWidth;
7925
+ this.root.classList.add("wulf-masonry--fit-width");
7847
7926
  } else {
7848
- item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
7927
+ this.root.classList.remove("wulf-masonry--fit-width");
7849
7928
  }
7850
- item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
7851
- item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
7852
- if (validStagger && !supportsSiblingIndex) {
7853
- item.style.setProperty("--wulf-masonry-index", String(i));
7929
+ const stagger = this.options.stagger;
7930
+ const validStagger = typeof stagger === "number" && Number.isFinite(stagger) && stagger > 0;
7931
+ if (validStagger) {
7932
+ this.root.style.setProperty("--wulf-masonry-stagger", `${stagger}ms`);
7854
7933
  } else {
7855
- item.style.removeProperty("--wulf-masonry-index");
7934
+ this.root.style.removeProperty("--wulf-masonry-stagger");
7935
+ }
7936
+ const hasIgnoredChildren = this._items.length !== this.root.children.length;
7937
+ const supportsSiblingIndex = !hasIgnoredChildren && typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("transition-delay", "calc(sibling-index() * 1ms)");
7938
+ const usePercent = this.options.percentPosition && result.containerWidth > 0;
7939
+ for (let i = 0; i < result.positions.length; i++) {
7940
+ const pos = result.positions[i];
7941
+ const item = pos.element;
7942
+ if (usePercent) {
7943
+ const wPct = Number((pos.width / result.containerWidth * 100).toFixed(4));
7944
+ item.style.setProperty("--wulf-masonry-w", `${wPct}%`);
7945
+ } else {
7946
+ item.style.setProperty("--wulf-masonry-w", `${pos.width}px`);
7947
+ }
7948
+ item.style.setProperty("--wulf-masonry-x", `${pos.x}px`);
7949
+ item.style.setProperty("--wulf-masonry-y", `${pos.y}px`);
7950
+ if (validStagger && !supportsSiblingIndex) {
7951
+ item.style.setProperty("--wulf-masonry-index", String(i));
7952
+ } else {
7953
+ item.style.removeProperty("--wulf-masonry-index");
7954
+ }
7955
+ item.classList.remove("wulf-masonry-item--hidden");
7956
+ this.observedItemHeights.set(item, pos.height);
7957
+ try {
7958
+ this.options.onItemPlaced(item, pos);
7959
+ } catch (err) {
7960
+ console.error("[Wulf.Masonry] Erreur dans onItemPlaced:", err);
7961
+ }
7856
7962
  }
7857
- item.classList.remove("wulf-masonry-item--hidden");
7858
- this.observedItemHeights.set(item, pos.height);
7859
- this.options.onItemPlaced(item, pos);
7963
+ } finally {
7964
+ this.root.setAttribute("aria-busy", "false");
7965
+ }
7966
+ try {
7967
+ this.options.onLayout(positionsResult);
7968
+ } catch (err) {
7969
+ console.error("[Wulf.Masonry] Erreur dans onLayout:", err);
7860
7970
  }
7861
- this.root.setAttribute("aria-busy", "false");
7862
- this.options.onLayout(result.positions);
7863
7971
  }
7864
7972
  /**
7865
7973
  * Ajoute de nouveaux éléments à la fin du conteneur.
7866
7974
  */
7867
7975
  append(elements) {
7868
7976
  if (this.isDestroyed) return;
7869
- const list = Array.isArray(elements) ? elements : [elements];
7977
+ const list = (Array.isArray(elements) ? elements : [elements]).filter(
7978
+ (el) => el instanceof HTMLElement && !el.contains(this.root)
7979
+ );
7870
7980
  if (list.length === 0) return;
7871
7981
  const frag = document.createDocumentFragment();
7872
7982
  for (const el of list) {
@@ -7887,7 +7997,9 @@ var Masonry = class extends LocalizedComponent {
7887
7997
  */
7888
7998
  prepend(elements) {
7889
7999
  if (this.isDestroyed) return;
7890
- const list = Array.isArray(elements) ? elements : [elements];
8000
+ const list = (Array.isArray(elements) ? elements : [elements]).filter(
8001
+ (el) => el instanceof HTMLElement && !el.contains(this.root)
8002
+ );
7891
8003
  if (list.length === 0) return;
7892
8004
  const first = this.root.firstChild;
7893
8005
  const frag = document.createDocumentFragment();
@@ -7909,7 +8021,9 @@ var Masonry = class extends LocalizedComponent {
7909
8021
  */
7910
8022
  remove(elements) {
7911
8023
  if (this.isDestroyed) return;
7912
- const list = Array.isArray(elements) ? elements : [elements];
8024
+ const list = (Array.isArray(elements) ? elements : [elements]).filter(
8025
+ (el) => el instanceof HTMLElement
8026
+ );
7913
8027
  if (list.length === 0) return;
7914
8028
  const finalizeRemoval = () => {
7915
8029
  if (this.isDestroyed) return;
@@ -7927,11 +8041,34 @@ var Masonry = class extends LocalizedComponent {
7927
8041
  this.reloadItems();
7928
8042
  this.layout();
7929
8043
  };
8044
+ const activeEl = getDeepActiveElement();
8045
+ if (activeEl && list.some((el) => el.contains(activeEl))) {
8046
+ const removeSet = new Set(list);
8047
+ const firstRemovedIdx = this._items.findIndex((item) => removeSet.has(item));
8048
+ const survivorsAfter = firstRemovedIdx >= 0 ? this._items.slice(firstRemovedIdx + 1).filter((item) => !removeSet.has(item)) : [];
8049
+ const survivorsBefore = firstRemovedIdx > 0 ? this._items.slice(0, firstRemovedIdx).filter((item) => !removeSet.has(item)).reverse() : [];
8050
+ const candidateItem = survivorsAfter[0] || survivorsBefore[0] || null;
8051
+ let handoffDone = false;
8052
+ if (candidateItem) {
8053
+ const focusableChild = candidateItem.querySelector(
8054
+ 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
8055
+ );
8056
+ const focusTarget = focusableChild || (candidateItem.tabIndex >= 0 ? candidateItem : null);
8057
+ if (focusTarget) {
8058
+ try {
8059
+ focusTarget.focus({ preventScroll: true });
8060
+ handoffDone = true;
8061
+ } catch {
8062
+ handoffDone = false;
8063
+ }
8064
+ }
8065
+ }
8066
+ if (!handoffDone) {
8067
+ activeEl.blur?.();
8068
+ }
8069
+ }
7930
8070
  for (const el of list) {
7931
8071
  this.removingItems.add(el);
7932
- if (typeof document !== "undefined" && document.activeElement && el.contains(document.activeElement)) {
7933
- document.activeElement.blur?.();
7934
- }
7935
8072
  el.setAttribute("inert", "");
7936
8073
  el.style.transitionDelay = "0ms";
7937
8074
  el.classList.add("wulf-masonry-item--hidden");
@@ -7957,7 +8094,7 @@ var Masonry = class extends LocalizedComponent {
7957
8094
  */
7958
8095
  audit() {
7959
8096
  const warnings = [];
7960
- const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings);
8097
+ const hasValidLabelledby = this.checkAriaIdReferences(this.root, "aria-labelledby", warnings, true);
7961
8098
  const hasCustomRootAriaLabel = !this.wasAriaLabelInferred && Boolean(this.root.getAttribute("aria-label")?.trim());
7962
8099
  if (!this.hasExplicitAriaLabel && !hasCustomRootAriaLabel && !hasValidLabelledby) {
7963
8100
  warnings.push(
@@ -7972,6 +8109,19 @@ var Masonry = class extends LocalizedComponent {
7972
8109
  `${imagesWithoutAlt.length} image(s) <img> d\xE9pourvue(s) d'attribut alt : renseignez alt="description" (ou alt="" si d\xE9corative) (WCAG 1.1.1).`
7973
8110
  );
7974
8111
  }
8112
+ const positiveTabIndexEls = Array.from(this.root.querySelectorAll("[tabindex]")).filter(
8113
+ (el) => el.tabIndex > 0
8114
+ );
8115
+ if (positiveTabIndexEls.length > 0) {
8116
+ warnings.push(
8117
+ `${positiveTabIndexEls.length} \xE9l\xE9ment(s) avec tabindex > 0 d\xE9tect\xE9(s) : utilisez uniquement tabindex="0" ou "-1" (WCAG 2.4.3).`
8118
+ );
8119
+ }
8120
+ if (!this.options.horizontalOrder && this.root.querySelector('a[href], button, input, select, textarea, [tabindex="0"]') !== null) {
8121
+ warnings.push(
8122
+ "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)."
8123
+ );
8124
+ }
7975
8125
  return warnings;
7976
8126
  }
7977
8127
  getAuditPrefix() {
@@ -8022,6 +8172,16 @@ var Masonry = class extends LocalizedComponent {
8022
8172
  } else {
8023
8173
  this.root.style.removeProperty("width");
8024
8174
  }
8175
+ for (const item of this.removingItems) {
8176
+ item.removeAttribute("inert");
8177
+ item.style.removeProperty("transition-delay");
8178
+ item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
8179
+ item.style.removeProperty("--wulf-masonry-w");
8180
+ item.style.removeProperty("--wulf-masonry-x");
8181
+ item.style.removeProperty("--wulf-masonry-y");
8182
+ item.style.removeProperty("--wulf-masonry-index");
8183
+ }
8184
+ this.removingItems.clear();
8025
8185
  for (const item of this._items) {
8026
8186
  item.classList.remove("wulf-masonry-item", "wulf-masonry-item--hidden");
8027
8187
  item.style.removeProperty("--wulf-masonry-w");
@@ -8079,17 +8239,18 @@ var toastI18n = createI18nManager("fr", {
8079
8239
  // src/toast/ToastInstance.ts
8080
8240
  var nextToastId = 1;
8081
8241
  var DEFAULT_TOAST_DURATION = 5e3;
8242
+ var SAFE_COLOR_FALLBACK_RE = /^(?:#[0-9a-f]{3,8}|(?:rgb|rgba|hsl|hsla|oklch|oklab|lch|lab)\([^;{}<>\\]+\)|[a-z]{3,20})$/i;
8082
8243
  function isSafeCssValue(val) {
8083
8244
  if (!val || typeof val !== "string" || val.length > 128) return false;
8084
8245
  const trimmed = val.trim();
8085
8246
  if (!trimmed) return false;
8086
- if (/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env)\s*\(/i.test(trimmed)) {
8247
+ if (/[\u0000-\u001F\u007F;{}<>\\]|(?:url|image-set|-webkit-image-set|image|src|expression|attr|env|var)\s*\(/i.test(trimmed)) {
8087
8248
  return false;
8088
8249
  }
8089
8250
  if (typeof CSS !== "undefined" && typeof CSS.supports === "function") {
8090
8251
  return CSS.supports("color", trimmed) || CSS.supports("background-color", trimmed);
8091
8252
  }
8092
- return true;
8253
+ return SAFE_COLOR_FALLBACK_RE.test(trimmed);
8093
8254
  }
8094
8255
  function sanitizeIconClasses(icon) {
8095
8256
  return icon.slice(0, 128).trim().split(/\s+/).filter((token) => /^[a-zA-Z0-9_-]+$/.test(token) && !token.startsWith("wulf-toast")).slice(0, 8).join(" ");
@@ -8118,7 +8279,7 @@ var ToastInstance = class extends AuditableComponent {
8118
8279
  this.id = `wulf-toast-${nextToastId++}`;
8119
8280
  this.options = Object.freeze({ ...options });
8120
8281
  this.onDismissCallback = onDismiss;
8121
- this.previousActiveElement = typeof document !== "undefined" && document.activeElement instanceof HTMLElement ? document.activeElement : null;
8282
+ this.previousActiveElement = getDeepActiveElement();
8122
8283
  const duration = options.duration === void 0 ? DEFAULT_TOAST_DURATION : options.duration;
8123
8284
  if (typeof duration === "number" && Number.isFinite(duration) && duration > 0) {
8124
8285
  this.remainingTime = Math.min(duration, 2147483647);
@@ -8205,7 +8366,30 @@ var ToastInstance = class extends AuditableComponent {
8205
8366
  }
8206
8367
  }
8207
8368
  const content = document.createElement("div");
8208
- content.className = "wulf-toast-content";
8369
+ const isInteractiveContent = Boolean(this.options.onClick || this.options.closeOnClick);
8370
+ content.className = isInteractiveContent ? "wulf-toast-content wulf-toast-content--interactive" : "wulf-toast-content";
8371
+ if (isInteractiveContent) {
8372
+ content.setAttribute("role", "button");
8373
+ content.setAttribute("tabindex", "0");
8374
+ content.addEventListener("keydown", (e) => {
8375
+ if (isImeComposing(e)) return;
8376
+ if (e.key === "Enter") {
8377
+ e.preventDefault();
8378
+ e.stopPropagation();
8379
+ content.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
8380
+ } else if (e.key === " ") {
8381
+ e.preventDefault();
8382
+ e.stopPropagation();
8383
+ }
8384
+ }, { signal: this.eventsAbortController.signal });
8385
+ content.addEventListener("keyup", (e) => {
8386
+ if (e.key === " ") {
8387
+ e.preventDefault();
8388
+ e.stopPropagation();
8389
+ content.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
8390
+ }
8391
+ }, { signal: this.eventsAbortController.signal });
8392
+ }
8209
8393
  if (this.options.title && this.options.title.trim() !== "") {
8210
8394
  const titleEl = document.createElement("div");
8211
8395
  titleEl.className = "wulf-toast-title";
@@ -8249,7 +8433,7 @@ var ToastInstance = class extends AuditableComponent {
8249
8433
  * Injection de texte sécurisée gérant nativement les retours à la ligne (\n et \r\n).
8250
8434
  */
8251
8435
  appendTextWithLineBreaks(container, text) {
8252
- const safeText = String(text ?? "").slice(0, 4096);
8436
+ const safeText = stripBidiAndInvisibles(String(text ?? ""), 4096);
8253
8437
  const lines = safeText.split(/\r\n|\r|\n/).slice(0, 100);
8254
8438
  lines.forEach((line, index) => {
8255
8439
  if (index > 0) {
@@ -8265,7 +8449,11 @@ var ToastInstance = class extends AuditableComponent {
8265
8449
  const { signal } = this.eventsAbortController;
8266
8450
  this.element.addEventListener("click", (e) => {
8267
8451
  if (this.options.onClick) {
8268
- this.options.onClick(this, e);
8452
+ try {
8453
+ this.options.onClick(this, e);
8454
+ } catch (err) {
8455
+ console.error("[Wulf.Toast] Erreur dans le callback onClick:", err);
8456
+ }
8269
8457
  }
8270
8458
  if (this.options.closeOnClick) {
8271
8459
  this.close("toast-click");
@@ -8288,6 +8476,7 @@ var ToastInstance = class extends AuditableComponent {
8288
8476
  }, { signal });
8289
8477
  this.element.addEventListener("keydown", (e) => {
8290
8478
  if (e.key === "Escape" && (this.options.closable ?? true)) {
8479
+ if (isImeComposing(e)) return;
8291
8480
  e.stopPropagation();
8292
8481
  this.close("close-button");
8293
8482
  }
@@ -8322,7 +8511,8 @@ var ToastInstance = class extends AuditableComponent {
8322
8511
  this.timerStartTime = performance.now();
8323
8512
  this.timerId = window.setTimeout(() => {
8324
8513
  this.timerId = null;
8325
- if (typeof document !== "undefined" && this.element.contains(document.activeElement)) {
8514
+ const active = getDeepActiveElement();
8515
+ if (active && this.element.contains(active)) {
8326
8516
  this.isPendingFocusDismiss = true;
8327
8517
  return;
8328
8518
  }
@@ -8362,7 +8552,8 @@ var ToastInstance = class extends AuditableComponent {
8362
8552
  this.isPausedByFocus = false;
8363
8553
  } else if (source === "hover") {
8364
8554
  this.isPausedByHover = false;
8365
- if (typeof document !== "undefined" && this.element.contains(document.activeElement)) {
8555
+ const active = getDeepActiveElement();
8556
+ if (active && this.element.contains(active)) {
8366
8557
  this.isPausedByFocus = true;
8367
8558
  }
8368
8559
  } else {
@@ -8388,7 +8579,11 @@ var ToastInstance = class extends AuditableComponent {
8388
8579
  this.element.parentNode.removeChild(this.element);
8389
8580
  }
8390
8581
  if (this.options.onClose) {
8391
- this.options.onClose(this, reason);
8582
+ try {
8583
+ this.options.onClose(this, reason);
8584
+ } catch (err) {
8585
+ console.error("[Wulf.Toast] Erreur dans le callback onClose:", err);
8586
+ }
8392
8587
  }
8393
8588
  }
8394
8589
  /**
@@ -8448,6 +8643,7 @@ var FOCUSABLE_IN_TOAST = 'button:not([disabled]), [href], [tabindex]:not([tabind
8448
8643
  var ToastManager = class _ToastManager {
8449
8644
  static instance = null;
8450
8645
  containers = /* @__PURE__ */ new Map();
8646
+ containerBaseLabels = /* @__PURE__ */ new WeakMap();
8451
8647
  activeToasts = /* @__PURE__ */ new Map();
8452
8648
  announcerEl = null;
8453
8649
  politeRegion = null;
@@ -8569,7 +8765,7 @@ var ToastManager = class _ToastManager {
8569
8765
  * Annonce la notification sur un canal unique pour éviter les doubles lectures AT.
8570
8766
  */
8571
8767
  announce(toast) {
8572
- const parts = [toast.options.title, toast.options.message].filter((val) => typeof val === "string" && val.trim().length > 0).map((val) => val.trim());
8768
+ 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);
8573
8769
  if (parts.length === 0) return;
8574
8770
  const rawText = parts.join(". ");
8575
8771
  const text = rawText.length > 512 ? `${rawText.slice(0, 509)}...` : rawText;
@@ -8681,7 +8877,8 @@ var ToastManager = class _ToastManager {
8681
8877
  * Transfère le focus avant de retirer un toast focalisé pour éviter que le focus ne retombe sur <body>.
8682
8878
  */
8683
8879
  handleFocusHandoff(toast, list) {
8684
- if (!toast.element.contains(document.activeElement)) {
8880
+ const active = getDeepActiveElement();
8881
+ if (!active || !toast.element.contains(active)) {
8685
8882
  return;
8686
8883
  }
8687
8884
  for (let i = list.length - 1; i >= 0; i--) {
@@ -8694,7 +8891,15 @@ var ToastManager = class _ToastManager {
8694
8891
  }
8695
8892
  }
8696
8893
  const prev = toast.getPreviousActiveElement();
8697
- if (prev && prev.isConnected && typeof prev.focus === "function" && !prev.disabled && !prev.closest("[inert]") && prev.getAttribute("aria-hidden") !== "true") {
8894
+ 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)) {
8895
+ const prevWithCheck = prev;
8896
+ if (typeof prevWithCheck.checkVisibility === "function" && !prevWithCheck.checkVisibility({
8897
+ checkOpacity: false,
8898
+ checkVisibilityCSS: true,
8899
+ visibilityProperty: true
8900
+ })) {
8901
+ return;
8902
+ }
8698
8903
  try {
8699
8904
  prev.focus();
8700
8905
  } catch {
@@ -8722,6 +8927,7 @@ var ToastManager = class _ToastManager {
8722
8927
  this.disposeContainer(container);
8723
8928
  this.containers.delete(position);
8724
8929
  this.activeToasts.delete(position);
8930
+ this.syncContainerRegionLabels();
8725
8931
  }
8726
8932
  }
8727
8933
  } else if (toast.element.parentNode) {
@@ -8760,6 +8966,7 @@ var ToastManager = class _ToastManager {
8760
8966
  this.disposeContainer(container);
8761
8967
  this.containers.delete(position);
8762
8968
  this.activeToasts.delete(position);
8969
+ this.syncContainerRegionLabels();
8763
8970
  }
8764
8971
  }
8765
8972
  } else {
@@ -8792,6 +8999,7 @@ var ToastManager = class _ToastManager {
8792
8999
  this.activeToasts.delete(pos);
8793
9000
  }
8794
9001
  }
9002
+ this.syncContainerRegionLabels();
8795
9003
  }
8796
9004
  });
8797
9005
  }
@@ -8803,6 +9011,10 @@ var ToastManager = class _ToastManager {
8803
9011
  window.clearTimeout(timerId);
8804
9012
  }
8805
9013
  this.announceTimers = [];
9014
+ this.politeAnnounceTimerId = null;
9015
+ this.assertiveAnnounceTimerId = null;
9016
+ this.politeClearTimerId = null;
9017
+ this.assertiveClearTimerId = null;
8806
9018
  for (const list of Array.from(this.activeToasts.values())) {
8807
9019
  for (const toast of [...list]) {
8808
9020
  toast.destroyImmediate("programmatic");
@@ -8823,6 +9035,13 @@ var ToastManager = class _ToastManager {
8823
9035
  }
8824
9036
  _ToastManager.instance = null;
8825
9037
  }
9038
+ syncContainerRegionLabels() {
9039
+ const useSuffix = this.containers.size > 1;
9040
+ for (const [pos, container] of this.containers.entries()) {
9041
+ const baseLabel = this.containerBaseLabels.get(container) || toastI18n.t("notificationsRegion");
9042
+ container.setAttribute("aria-label", useSuffix ? `${baseLabel} (${pos})` : baseLabel);
9043
+ }
9044
+ }
8826
9045
  /**
8827
9046
  * Récupère ou crée le conteneur DOM pour une position d'affichage.
8828
9047
  */
@@ -8832,12 +9051,15 @@ var ToastManager = class _ToastManager {
8832
9051
  container = document.createElement("div");
8833
9052
  container.className = `wulf-toast-container wulf-toast-${position}`;
8834
9053
  container.setAttribute("role", "region");
8835
- container.setAttribute("aria-label", toastI18n.t("notificationsRegion", toast.options.i18n));
9054
+ const baseLabel = toastI18n.t("notificationsRegion", toast.options.i18n);
9055
+ this.containerBaseLabels.set(container, baseLabel);
9056
+ container.setAttribute("aria-label", baseLabel);
8836
9057
  if (useTopLayer && typeof container.showPopover === "function") {
8837
9058
  container.setAttribute("popover", "manual");
8838
9059
  }
8839
9060
  document.body.appendChild(container);
8840
9061
  this.containers.set(position, container);
9062
+ this.syncContainerRegionLabels();
8841
9063
  }
8842
9064
  return container;
8843
9065
  }
@@ -8975,9 +9197,8 @@ var FocusTrap = class extends AuditableComponent {
8975
9197
  return false;
8976
9198
  }
8977
9199
  }
8978
- isElementFocusableBase(el) {
9200
+ isElementVisibleAndEnabled(el) {
8979
9201
  if (!el || !el.isConnected) return false;
8980
- if (el.tabIndex < 0) return false;
8981
9202
  if (el.disabled) return false;
8982
9203
  try {
8983
9204
  if (el.matches(":disabled")) return false;
@@ -9005,6 +9226,14 @@ var FocusTrap = class extends AuditableComponent {
9005
9226
  }
9006
9227
  return true;
9007
9228
  }
9229
+ isElementFocusableBase(el) {
9230
+ if (!el || el.tabIndex < 0) return false;
9231
+ return this.isElementVisibleAndEnabled(el);
9232
+ }
9233
+ isProgrammaticallyFocusable(el) {
9234
+ if (!el || !this.isElementVisibleAndEnabled(el)) return false;
9235
+ return el.tabIndex >= 0 || el.getAttribute("tabindex") !== null;
9236
+ }
9008
9237
  /**
9009
9238
  * Vérifie si un élément est réellement focusable, visible et actif dans le DOM.
9010
9239
  */
@@ -9058,9 +9287,16 @@ var FocusTrap = class extends AuditableComponent {
9058
9287
  document.addEventListener("touchstart", this.handleClickOutsideBound, { capture: true, signal });
9059
9288
  document.addEventListener("click", this.handleClickOutsideBound, { capture: true, signal });
9060
9289
  }
9290
+ if (this.isNativeDialogElement()) {
9291
+ this.element.addEventListener("close", () => this.deactivate(), { signal });
9292
+ }
9061
9293
  this.applyInitialFocus();
9062
9294
  this.runAuditWarning(this.options.audit);
9063
- this.options.onActivate();
9295
+ try {
9296
+ this.options.onActivate();
9297
+ } catch (err) {
9298
+ console.error("[Wulf.FocusTrap] Erreur dans onActivate:", err);
9299
+ }
9064
9300
  return this;
9065
9301
  }
9066
9302
  /**
@@ -9068,6 +9304,7 @@ var FocusTrap = class extends AuditableComponent {
9068
9304
  */
9069
9305
  deactivate() {
9070
9306
  if (!this.active) return this;
9307
+ const wasTop = trapStack[trapStack.length - 1] === this;
9071
9308
  this.active = false;
9072
9309
  this.paused = false;
9073
9310
  const index = trapStack.indexOf(this);
@@ -9081,15 +9318,21 @@ var FocusTrap = class extends AuditableComponent {
9081
9318
  this.element.removeAttribute("tabindex");
9082
9319
  this.addedContainerTabIndex = false;
9083
9320
  }
9084
- const nextTop = trapStack[trapStack.length - 1];
9085
- if (nextTop) {
9086
- nextTop.unpause();
9087
- }
9088
- if (this.options.returnFocus) {
9089
- this.restoreFocus();
9321
+ if (wasTop) {
9322
+ const nextTop = trapStack[trapStack.length - 1];
9323
+ if (nextTop) {
9324
+ nextTop.unpause();
9325
+ }
9326
+ if (this.options.returnFocus) {
9327
+ this.restoreFocus();
9328
+ }
9090
9329
  }
9091
9330
  this.previousActiveElement = null;
9092
- this.options.onDeactivate();
9331
+ try {
9332
+ this.options.onDeactivate();
9333
+ } catch (err) {
9334
+ console.error("[Wulf.FocusTrap] Erreur dans onDeactivate:", err);
9335
+ }
9093
9336
  return this;
9094
9337
  }
9095
9338
  /**
@@ -9155,12 +9398,23 @@ var FocusTrap = class extends AuditableComponent {
9155
9398
  }
9156
9399
  }
9157
9400
  const ariaLabel = this.element.getAttribute("aria-label")?.trim();
9158
- const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings);
9401
+ const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings, true);
9159
9402
  if (!ariaLabel && !hasValidLabelledby) {
9160
9403
  warnings.push(
9161
9404
  'Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'
9162
9405
  );
9163
9406
  }
9407
+ if (this.element.hasAttribute("aria-describedby")) {
9408
+ this.checkAriaIdReferences(this.element, "aria-describedby", warnings, true);
9409
+ }
9410
+ const positiveTabIndexEls = Array.from(this.element.querySelectorAll("[tabindex]")).filter(
9411
+ (el) => el.tabIndex > 0
9412
+ );
9413
+ if (positiveTabIndexEls.length > 0) {
9414
+ warnings.push(
9415
+ `${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).`
9416
+ );
9417
+ }
9164
9418
  return warnings;
9165
9419
  }
9166
9420
  getAuditPrefix() {
@@ -9190,7 +9444,8 @@ var FocusTrap = class extends AuditableComponent {
9190
9444
  }
9191
9445
  isInsideToastContainer(target) {
9192
9446
  if (!target || !(target instanceof Element)) return false;
9193
- return Boolean(target.closest(".wulf-toast-container"));
9447
+ const container = target.closest(".wulf-toast-container");
9448
+ return Boolean(container && container.parentElement === document.body && !this.element.contains(container));
9194
9449
  }
9195
9450
  ensureContainerTabIndex() {
9196
9451
  if (this.element.getAttribute("tabindex") === null) {
@@ -9205,11 +9460,16 @@ var FocusTrap = class extends AuditableComponent {
9205
9460
  return;
9206
9461
  }
9207
9462
  if (e.key === "Escape" && this.options.escapeDeactivates) {
9208
- if (isImeComposing(e)) return;
9209
- if (!this.isNativeModalDialog()) {
9210
- e.preventDefault();
9211
- e.stopPropagation();
9463
+ if (e.defaultPrevented || e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || isImeComposing(e)) return;
9464
+ const deepActive = getDeepActiveElement(document);
9465
+ if (this.isInsideToastContainer(deepActive) || this.isInsideToastContainer(e.target)) {
9466
+ return;
9467
+ }
9468
+ if (this.isNativeModalDialog()) {
9469
+ return;
9212
9470
  }
9471
+ e.preventDefault();
9472
+ e.stopPropagation();
9213
9473
  this.deactivate();
9214
9474
  return;
9215
9475
  }
@@ -9278,22 +9538,38 @@ var FocusTrap = class extends AuditableComponent {
9278
9538
  }
9279
9539
  }
9280
9540
  /**
9281
- * Applique `inert` sur les éléments frères à chaque niveau hiérarchique jusqu'à <body>,
9282
- * en préservant les conteneurs de notifications Toast en Top Layer.
9541
+ * Applique `inert` sur les éléments frères à chaque niveau hiérarchique jusqu'à <body>
9542
+ * (y compris en remontant à travers les ShadowRoot.host), en préservant les conteneurs
9543
+ * de notifications Toast en Top Layer enfants directs de <body>.
9283
9544
  */
9284
9545
  applyInert() {
9285
9546
  this.removeInert();
9286
9547
  let current = this.element;
9287
9548
  const ignoredTags = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "LINK", "META", "NOSCRIPT"]);
9288
- while (current && current !== document.body && current.parentElement) {
9549
+ while (current && current !== document.body) {
9289
9550
  const parent = current.parentElement;
9290
- for (const sibling of Array.from(parent.children)) {
9291
- if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert") && !sibling.matches(".wulf-toast-container, .wulf-toast-announcer")) {
9292
- sibling.setAttribute("inert", "");
9293
- this.inertSiblings.push(sibling);
9551
+ if (parent) {
9552
+ for (const sibling of Array.from(parent.children)) {
9553
+ if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert") && !(parent === document.body && sibling.matches(".wulf-toast-container, .wulf-toast-announcer"))) {
9554
+ sibling.setAttribute("inert", "");
9555
+ this.inertSiblings.push(sibling);
9556
+ }
9557
+ }
9558
+ current = parent;
9559
+ } else {
9560
+ const root = typeof current.getRootNode === "function" ? current.getRootNode() : null;
9561
+ if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot) {
9562
+ for (const sibling of Array.from(root.children)) {
9563
+ if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert")) {
9564
+ sibling.setAttribute("inert", "");
9565
+ this.inertSiblings.push(sibling);
9566
+ }
9567
+ }
9568
+ current = root.host instanceof HTMLElement ? root.host : null;
9569
+ } else {
9570
+ break;
9294
9571
  }
9295
9572
  }
9296
- current = parent;
9297
9573
  }
9298
9574
  }
9299
9575
  removeInert() {
@@ -9306,11 +9582,15 @@ var FocusTrap = class extends AuditableComponent {
9306
9582
  if (typeof this.options.initialFocus === "string") {
9307
9583
  targetEl = safeQuerySelector(this.element, this.options.initialFocus);
9308
9584
  } else if (this.options.initialFocus instanceof HTMLElement) {
9309
- targetEl = this.options.initialFocus;
9585
+ targetEl = this.element.contains(this.options.initialFocus) ? this.options.initialFocus : null;
9310
9586
  }
9311
- if (targetEl && this.isFocusable(targetEl)) {
9312
- targetEl.focus();
9313
- return;
9587
+ if (targetEl) {
9588
+ const isRadio = targetEl instanceof HTMLInputElement && targetEl.type === "radio" && Boolean(targetEl.name);
9589
+ const canFocus = isRadio && targetEl.tabIndex >= 0 ? this.isFocusable(targetEl) : this.isProgrammaticallyFocusable(targetEl);
9590
+ if (canFocus) {
9591
+ targetEl.focus();
9592
+ return;
9593
+ }
9314
9594
  }
9315
9595
  const focusables = this.getFocusableElements();
9316
9596
  if (focusables.length > 0) {
@@ -9321,13 +9601,13 @@ var FocusTrap = class extends AuditableComponent {
9321
9601
  }
9322
9602
  }
9323
9603
  restoreFocus() {
9324
- if (this.previousActiveElement && this.previousActiveElement.isConnected && this.isElementFocusableBase(this.previousActiveElement)) {
9604
+ if (this.previousActiveElement && this.previousActiveElement.isConnected && this.isProgrammaticallyFocusable(this.previousActiveElement)) {
9325
9605
  this.previousActiveElement.focus();
9326
9606
  return;
9327
9607
  }
9328
9608
  if (this.options.fallbackReturnFocus) {
9329
9609
  const fallback = typeof this.options.fallbackReturnFocus === "string" ? safeQuerySelector(document, this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
9330
- if (fallback && fallback.isConnected && this.isElementFocusableBase(fallback)) {
9610
+ if (fallback && fallback.isConnected && this.isProgrammaticallyFocusable(fallback)) {
9331
9611
  fallback.focus();
9332
9612
  }
9333
9613
  }
@@ -9608,7 +9888,7 @@ var ShortcutFormatter = class _ShortcutFormatter {
9608
9888
  case "backspace":
9609
9889
  return isApple ? "\u232B" : "Backspace";
9610
9890
  case "delete":
9611
- return isApple ? "\u2326" : "Suppr";
9891
+ return isApple ? "\u2326" : "Delete";
9612
9892
  case "arrowup":
9613
9893
  return "\u2191";
9614
9894
  case "arrowdown":
@@ -9624,7 +9904,14 @@ var ShortcutFormatter = class _ShortcutFormatter {
9624
9904
  };
9625
9905
 
9626
9906
  // src/shortcut/ShortcutManager.ts
9627
- var ShortcutManager = class _ShortcutManager {
9907
+ var SENSITIVE_AUTOCOMPLETE_TOKENS = /* @__PURE__ */ new Set([
9908
+ "current-password",
9909
+ "new-password",
9910
+ "one-time-code",
9911
+ "cc-number",
9912
+ "cc-csc"
9913
+ ]);
9914
+ var ShortcutManager = class _ShortcutManager extends AuditableComponent {
9628
9915
  options;
9629
9916
  shortcuts = /* @__PURE__ */ new Map();
9630
9917
  scopeStack = [];
@@ -9635,6 +9922,7 @@ var ShortcutManager = class _ShortcutManager {
9635
9922
  abortController = null;
9636
9923
  idCounter = 0;
9637
9924
  constructor(options) {
9925
+ super();
9638
9926
  const rawTimeout = options?.sequenceTimeout;
9639
9927
  const sequenceTimeout = typeof rawTimeout === "number" && Number.isFinite(rawTimeout) && rawTimeout > 0 ? Math.min(rawTimeout, 1e4) : 800;
9640
9928
  this.options = {
@@ -9664,10 +9952,11 @@ var ShortcutManager = class _ShortcutManager {
9664
9952
  if (tagName === "TEXTAREA" || tagName === "SELECT") {
9665
9953
  return true;
9666
9954
  }
9667
- if (el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "plaintext-only" || el.getAttribute("contenteditable") === "") {
9955
+ const contentEditable = el.getAttribute?.("contenteditable")?.toLowerCase();
9956
+ if (el.isContentEditable || contentEditable === "true" || contentEditable === "plaintext-only" || contentEditable === "") {
9668
9957
  return true;
9669
9958
  }
9670
- const role = el.getAttribute("role");
9959
+ const role = el.getAttribute?.("role");
9671
9960
  if (role === "textbox" || role === "searchbox" || role === "combobox" || role === "spinbutton") {
9672
9961
  return true;
9673
9962
  }
@@ -9682,14 +9971,45 @@ var ShortcutManager = class _ShortcutManager {
9682
9971
  return false;
9683
9972
  }
9684
9973
  /**
9685
- * Vérifie si la cible est un champ de mot de passe (sanctuaire anti-keylogging).
9974
+ * Vérifie si la cible appartient à un widget composite à typeahead clavier (listbox, menu, tree, grid).
9975
+ */
9976
+ static isTypeaheadWidget(target) {
9977
+ if (!target || typeof target.tagName !== "string") {
9978
+ return false;
9979
+ }
9980
+ const el = target;
9981
+ const role = el.getAttribute?.("role");
9982
+ if (role === "listbox" || role === "menu" || role === "menubar" || role === "tree" || role === "grid") {
9983
+ return true;
9984
+ }
9985
+ if (typeof el.closest === "function") {
9986
+ return Boolean(el.closest('[role="listbox"], [role="menu"], [role="menubar"], [role="tree"], [role="grid"]'));
9987
+ }
9988
+ return false;
9989
+ }
9990
+ /**
9991
+ * Vérifie si la cible est un champ sensible (password, data-mask-sensitive, autocomplete sensible).
9686
9992
  */
9687
- static isPasswordField(target) {
9993
+ static isSensitiveField(target) {
9688
9994
  if (!target || typeof target.tagName !== "string") {
9689
9995
  return false;
9690
9996
  }
9691
9997
  const el = target;
9692
- return el.tagName.toUpperCase() === "INPUT" && (el.type || "").toLowerCase() === "password";
9998
+ if (el.tagName.toUpperCase() === "INPUT" && (el.type || "").toLowerCase() === "password") {
9999
+ return true;
10000
+ }
10001
+ const sensitiveAttr = el.getAttribute?.("data-mask-sensitive");
10002
+ if (sensitiveAttr !== null && sensitiveAttr !== void 0 && sensitiveAttr !== "false") {
10003
+ return true;
10004
+ }
10005
+ const ac = el.getAttribute?.("autocomplete");
10006
+ if (ac) {
10007
+ const tokens = ac.trim().toLowerCase().split(/\s+/);
10008
+ if (tokens.some((tok) => SENSITIVE_AUTOCOMPLETE_TOKENS.has(tok))) {
10009
+ return true;
10010
+ }
10011
+ }
10012
+ return false;
9693
10013
  }
9694
10014
  /**
9695
10015
  * Enregistre un ou plusieurs raccourcis clavier.
@@ -9702,8 +10022,11 @@ var ShortcutManager = class _ShortcutManager {
9702
10022
  if (!def.combo || typeof def.handler !== "function") {
9703
10023
  continue;
9704
10024
  }
9705
- const id = `wulf_shortcut_${++this.idCounter}`;
9706
10025
  const normalizedSteps = ShortcutFormatter.parseCombo(def.combo);
10026
+ if (normalizedSteps.length === 0 || normalizedSteps.some((step) => !step.key)) {
10027
+ continue;
10028
+ }
10029
+ const id = `wulf_shortcut_${++this.idCounter}`;
9707
10030
  const isSequence = normalizedSteps.length > 1;
9708
10031
  const formattedCombo = ShortcutFormatter.format(def.combo);
9709
10032
  const registered = {
@@ -9822,11 +10145,47 @@ var ShortcutManager = class _ShortcutManager {
9822
10145
  const list = [];
9823
10146
  for (const shortcut of this.shortcuts.values()) {
9824
10147
  if (!scope || shortcut.scope === scope || shortcut.scope === "*") {
9825
- list.push({ ...shortcut });
10148
+ list.push({
10149
+ ...shortcut,
10150
+ normalizedSteps: shortcut.normalizedSteps.map((step) => ({ ...step }))
10151
+ });
9826
10152
  }
9827
10153
  }
9828
10154
  return list;
9829
10155
  }
10156
+ /**
10157
+ * Audite le registre des raccourcis vis-à-vis de WCAG 2.1.4 et de l'Axiome Primordial.
10158
+ */
10159
+ audit() {
10160
+ const warnings = [];
10161
+ const criticalEditKeys = /* @__PURE__ */ new Set(["c", "v", "x", "a", "z"]);
10162
+ for (const shortcut of this.shortcuts.values()) {
10163
+ const isSingleCharWithoutMod = shortcut.normalizedSteps.length > 0 && shortcut.normalizedSteps.every(
10164
+ (step) => !step.ctrl && !step.alt && !step.meta && step.key.length === 1
10165
+ );
10166
+ if (isSingleCharWithoutMod) {
10167
+ warnings.push(
10168
+ `Raccourci mono-caract\xE8re sans modificateur "${shortcut.combo}" : pr\xE9voyez une option pour le d\xE9sactiver ou le reconfigurer (WCAG 2.1.4).`
10169
+ );
10170
+ }
10171
+ if (shortcut.allowInEditable && !shortcut.isSequence && shortcut.normalizedSteps.length === 1) {
10172
+ const s = shortcut.normalizedSteps[0];
10173
+ const isPrimaryModOnly = !s.alt && !s.shift && (s.ctrl && !s.meta || s.meta && !s.ctrl);
10174
+ if (isPrimaryModOnly && criticalEditKeys.has(s.key)) {
10175
+ warnings.push(
10176
+ `Raccourci "${shortcut.combo}" avec allowInEditable: true risque d'\xE9craser une commande d'\xE9dition native (Ctrl/Cmd+${s.key.toUpperCase()}).`
10177
+ );
10178
+ }
10179
+ }
10180
+ }
10181
+ return warnings;
10182
+ }
10183
+ getAuditPrefix() {
10184
+ return "Wulf.Shortcut";
10185
+ }
10186
+ getAuditTargetLabel() {
10187
+ return `${this.shortcuts.size} raccourci(s)`;
10188
+ }
9830
10189
  /**
9831
10190
  * Associe l'attribut standard WAI-ARIA `aria-keyshortcuts` sur un élément DOM.
9832
10191
  */
@@ -9893,9 +10252,15 @@ var ShortcutManager = class _ShortcutManager {
9893
10252
  }
9894
10253
  const currentScope = this.getScope();
9895
10254
  const composed = typeof event.composedPath === "function" ? event.composedPath() : [];
9896
- const actualTarget = composed.length > 0 ? composed[0] : event.target;
9897
- const isEditable = _ShortcutManager.isEditable(actualTarget) || _ShortcutManager.isEditable(event.target);
9898
- const isPasswordInput = _ShortcutManager.isPasswordField(actualTarget) || _ShortcutManager.isPasswordField(event.target);
10255
+ const pathTargets = composed.length > 0 ? composed : event.target ? [event.target] : [];
10256
+ let isEditable = _ShortcutManager.isEditable(event.target);
10257
+ let isSensitiveInput = _ShortcutManager.isSensitiveField(event.target);
10258
+ let isTypeahead = _ShortcutManager.isTypeaheadWidget(event.target);
10259
+ for (const node of pathTargets) {
10260
+ if (!isEditable && _ShortcutManager.isEditable(node)) isEditable = true;
10261
+ if (!isSensitiveInput && _ShortcutManager.isSensitiveField(node)) isSensitiveInput = true;
10262
+ if (!isTypeahead && _ShortcutManager.isTypeaheadWidget(node)) isTypeahead = true;
10263
+ }
9899
10264
  const currentStep = {
9900
10265
  ctrl: event.ctrlKey,
9901
10266
  alt: event.altKey,
@@ -9903,14 +10268,14 @@ var ShortcutManager = class _ShortcutManager {
9903
10268
  meta: event.metaKey,
9904
10269
  key: ShortcutFormatter.normalizeKeyName(event.key || "")
9905
10270
  };
9906
- const now = event.timeStamp > 0 ? event.timeStamp : typeof performance !== "undefined" ? performance.now() : Date.now();
10271
+ const now = typeof performance !== "undefined" ? performance.now() : Date.now();
9907
10272
  if (this.sequenceBuffer.length > 0) {
9908
10273
  const last = this.sequenceBuffer[this.sequenceBuffer.length - 1];
9909
10274
  if (now - last.timestamp > this.options.sequenceTimeout) {
9910
10275
  this.clearSequenceBuffer();
9911
10276
  }
9912
10277
  }
9913
- const activeCandidates = this.getActiveShortcuts(currentScope, isEditable, isPasswordInput);
10278
+ const activeCandidates = this.getActiveShortcuts(currentScope, isEditable, isSensitiveInput, isTypeahead);
9914
10279
  const proposedSequence = [...this.sequenceBuffer.map((b) => b.step), currentStep];
9915
10280
  const matchingSequence = this.findMatchingSequence(activeCandidates, proposedSequence);
9916
10281
  if (matchingSequence) {
@@ -9921,7 +10286,7 @@ var ShortcutManager = class _ShortcutManager {
9921
10286
  if (this.isPrefixOfAnySequence(activeCandidates, proposedSequence)) {
9922
10287
  this.sequenceBuffer.push({ step: currentStep, timestamp: now });
9923
10288
  this.resetSequenceTimer();
9924
- if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !isEditable) {
10289
+ if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey && !isEditable && !isTypeahead) {
9925
10290
  event.preventDefault();
9926
10291
  }
9927
10292
  return;
@@ -9932,7 +10297,7 @@ var ShortcutManager = class _ShortcutManager {
9932
10297
  this.executeShortcut(matchingChord, event, currentScope, false);
9933
10298
  }
9934
10299
  }
9935
- getActiveShortcuts(currentScope, isEditable, isPasswordInput = false) {
10300
+ getActiveShortcuts(currentScope, isEditable, isSensitiveInput = false, isTypeahead = false) {
9936
10301
  const list = [];
9937
10302
  for (const shortcut of this.shortcuts.values()) {
9938
10303
  if (shortcut.scope !== currentScope && shortcut.scope !== "*") {
@@ -9941,15 +10306,25 @@ var ShortcutManager = class _ShortcutManager {
9941
10306
  if (isEditable && !shortcut.allowInEditable) {
9942
10307
  continue;
9943
10308
  }
9944
- if (isPasswordInput) {
10309
+ if (isTypeahead) {
10310
+ const firstStep = shortcut.normalizedSteps[0];
10311
+ if (firstStep && !firstStep.ctrl && !firstStep.alt && !firstStep.meta && firstStep.key.length === 1) {
10312
+ continue;
10313
+ }
10314
+ }
10315
+ if (isSensitiveInput) {
9945
10316
  if (shortcut.isSequence) {
9946
10317
  continue;
9947
10318
  }
9948
10319
  const firstStep = shortcut.normalizedSteps[0];
9949
- if (firstStep && firstStep.key.length === 1) {
9950
- const isUntouchedChar = !firstStep.ctrl && !firstStep.alt && !firstStep.meta;
9951
- const isAltGrOrOptionChar = firstStep.ctrl && firstStep.alt && !firstStep.meta || firstStep.alt && !firstStep.ctrl && !firstStep.meta;
9952
- if (isUntouchedChar || isAltGrOrOptionChar) {
10320
+ if (firstStep) {
10321
+ if (firstStep.key.length === 1) {
10322
+ const isUntouchedChar = !firstStep.ctrl && !firstStep.alt && !firstStep.meta;
10323
+ const isAltGrOrOptionChar = firstStep.ctrl && firstStep.alt && !firstStep.meta || firstStep.alt && !firstStep.ctrl && !firstStep.meta;
10324
+ if (isUntouchedChar || isAltGrOrOptionChar) {
10325
+ continue;
10326
+ }
10327
+ } else if (!firstStep.ctrl && !firstStep.alt && !firstStep.meta && (firstStep.key === "backspace" || firstStep.key === "delete" || firstStep.key === "dead")) {
9953
10328
  continue;
9954
10329
  }
9955
10330
  }
@@ -10042,7 +10417,11 @@ var ShortcutManager = class _ShortcutManager {
10042
10417
  shortcut.handler(event, info);
10043
10418
  } catch (err) {
10044
10419
  if (this.options.onError) {
10045
- this.options.onError(err instanceof Error ? err : new Error(String(err)), shortcut.combo);
10420
+ try {
10421
+ this.options.onError(err instanceof Error ? err : new Error(String(err)), shortcut.combo);
10422
+ } catch (onErrException) {
10423
+ console.error("[Wulf.Shortcut] Erreur dans le callback onError:", onErrException);
10424
+ }
10046
10425
  } else {
10047
10426
  console.error(`[Wulf.Shortcut] Erreur lors de l'ex\xE9cution du raccourci "${shortcut.combo}":`, err);
10048
10427
  }