wulf.js 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +217 -11
  2. package/changelog.md +60 -0
  3. package/dist/anchor.esm.js +9 -0
  4. package/dist/anchor.esm.js.map +7 -0
  5. package/dist/anchor.global.js +695 -0
  6. package/dist/anchor.global.js.map +7 -0
  7. package/dist/anchor.global.min.js +6 -0
  8. package/dist/anchor.global.min.js.map +7 -0
  9. package/dist/autosize.css +1 -0
  10. package/dist/autosize.css.map +7 -0
  11. package/dist/autosize.esm.js +10 -0
  12. package/dist/autosize.esm.js.map +7 -0
  13. package/dist/autosize.global.js +657 -0
  14. package/dist/autosize.global.js.map +7 -0
  15. package/dist/autosize.global.min.js +6 -0
  16. package/dist/autosize.global.min.js.map +7 -0
  17. package/dist/autosize.layered.css +1 -0
  18. package/dist/autosize.layered.css.map +7 -0
  19. package/dist/chunks/chunk-22AIMRD5.js +119 -0
  20. package/dist/chunks/chunk-22AIMRD5.js.map +7 -0
  21. package/dist/chunks/chunk-5N2IRGDM.js +766 -0
  22. package/dist/chunks/chunk-5N2IRGDM.js.map +7 -0
  23. package/dist/chunks/chunk-72FVCNNZ.js +863 -0
  24. package/dist/chunks/chunk-72FVCNNZ.js.map +7 -0
  25. package/dist/chunks/chunk-AXZYYW7H.js +865 -0
  26. package/dist/chunks/chunk-AXZYYW7H.js.map +7 -0
  27. package/dist/chunks/chunk-CM3SBIVQ.js +1116 -0
  28. package/dist/chunks/chunk-CM3SBIVQ.js.map +7 -0
  29. package/dist/chunks/chunk-H4GRLGQ3.js +578 -0
  30. package/dist/chunks/chunk-H4GRLGQ3.js.map +7 -0
  31. package/dist/chunks/chunk-ITRU2RFV.js +1195 -0
  32. package/dist/chunks/chunk-ITRU2RFV.js.map +7 -0
  33. package/dist/chunks/chunk-NLUQZEL4.js +1029 -0
  34. package/dist/chunks/chunk-NLUQZEL4.js.map +7 -0
  35. package/dist/chunks/chunk-QV46A7FV.js +197 -0
  36. package/dist/chunks/chunk-QV46A7FV.js.map +7 -0
  37. package/dist/chunks/chunk-SXLUXN6W.js +612 -0
  38. package/dist/chunks/chunk-SXLUXN6W.js.map +7 -0
  39. package/dist/chunks/chunk-T2H4EJCW.js +621 -0
  40. package/dist/chunks/chunk-T2H4EJCW.js.map +7 -0
  41. package/dist/chunks/chunk-TILLYEF2.js +6044 -0
  42. package/dist/chunks/chunk-TILLYEF2.js.map +7 -0
  43. package/dist/chunks/chunk-VJO22BAT.js +72 -0
  44. package/dist/chunks/chunk-VJO22BAT.js.map +7 -0
  45. package/dist/chunks/chunk-ZGUU6DMM.js +77 -0
  46. package/dist/chunks/chunk-ZGUU6DMM.js.map +7 -0
  47. package/dist/focus-trap.esm.js +6 -536
  48. package/dist/focus-trap.esm.js.map +3 -3
  49. package/dist/focus-trap.global.js +260 -87
  50. package/dist/focus-trap.global.js.map +3 -3
  51. package/dist/focus-trap.global.min.js +4 -4
  52. package/dist/focus-trap.global.min.js.map +4 -4
  53. package/dist/index.esm.js +79 -10069
  54. package/dist/index.esm.js.map +4 -4
  55. package/dist/index.global.js +4192 -355
  56. package/dist/index.global.js.map +4 -4
  57. package/dist/index.global.min.js +6 -3
  58. package/dist/index.global.min.js.map +4 -4
  59. package/dist/mask.esm.js +16 -6094
  60. package/dist/mask.esm.js.map +4 -4
  61. package/dist/mask.global.js +44 -55
  62. package/dist/mask.global.js.map +3 -3
  63. package/dist/mask.global.min.js +3 -3
  64. package/dist/mask.global.min.js.map +4 -4
  65. package/dist/masonry.esm.js +15 -1067
  66. package/dist/masonry.esm.js.map +4 -4
  67. package/dist/masonry.global.js +229 -148
  68. package/dist/masonry.global.js.map +3 -3
  69. package/dist/masonry.global.min.js +4 -4
  70. package/dist/masonry.global.min.js.map +4 -4
  71. package/dist/scroll.css +1 -1
  72. package/dist/scroll.css.map +2 -2
  73. package/dist/scroll.esm.js +14 -1175
  74. package/dist/scroll.esm.js.map +3 -3
  75. package/dist/scroll.global.js +171 -88
  76. package/dist/scroll.global.js.map +3 -3
  77. package/dist/scroll.global.min.js +3 -3
  78. package/dist/scroll.global.min.js.map +4 -4
  79. package/dist/scroll.layered.css +1 -1
  80. package/dist/scroll.layered.css.map +2 -2
  81. package/dist/shortcut.esm.js +6 -741
  82. package/dist/shortcut.esm.js.map +4 -4
  83. package/dist/shortcut.global.js +225 -58
  84. package/dist/shortcut.global.js.map +3 -3
  85. package/dist/shortcut.global.min.js +8 -2
  86. package/dist/shortcut.global.min.js.map +4 -4
  87. package/dist/size-report.json +319 -0
  88. package/dist/sortable.css +1 -0
  89. package/dist/sortable.css.map +7 -0
  90. package/dist/sortable.esm.js +22 -0
  91. package/dist/sortable.esm.js.map +7 -0
  92. package/dist/sortable.global.js +1477 -0
  93. package/dist/sortable.global.js.map +7 -0
  94. package/dist/sortable.global.min.js +6 -0
  95. package/dist/sortable.global.min.js.map +7 -0
  96. package/dist/sortable.layered.css +1 -0
  97. package/dist/sortable.layered.css.map +7 -0
  98. package/dist/sri-manifest.json +64 -0
  99. package/dist/toast.css +1 -1
  100. package/dist/toast.css.map +2 -2
  101. package/dist/toast.esm.js +19 -1129
  102. package/dist/toast.esm.js.map +3 -3
  103. package/dist/toast.global.js +386 -104
  104. package/dist/toast.global.js.map +3 -3
  105. package/dist/toast.global.min.js +4 -4
  106. package/dist/toast.global.min.js.map +4 -4
  107. package/dist/toast.layered.css +1 -1
  108. package/dist/toast.layered.css.map +2 -2
  109. package/dist/types/anchor/Anchor.d.ts +41 -0
  110. package/dist/types/anchor/index.d.ts +3 -0
  111. package/dist/types/anchor/types.d.ts +115 -0
  112. package/dist/types/autosize/Autosize.d.ts +71 -0
  113. package/dist/types/autosize/index.d.ts +3 -0
  114. package/dist/types/autosize/types.d.ts +66 -0
  115. package/dist/types/common/AuditableComponent.d.ts +1 -1
  116. package/dist/types/common/dom.d.ts +5 -0
  117. package/dist/types/common/registry.d.ts +40 -0
  118. package/dist/types/focus-trap/FocusTrap.d.ts +8 -3
  119. package/dist/types/index.d.ts +13 -1
  120. package/dist/types/mask/paste.d.ts +2 -5
  121. package/dist/types/masonry/Masonry.d.ts +2 -0
  122. package/dist/types/scroll/ScrollBlock.d.ts +2 -0
  123. package/dist/types/scroll/types.d.ts +6 -0
  124. package/dist/types/shortcut/ShortcutManager.d.ts +16 -3
  125. package/dist/types/shortcut/types.d.ts +5 -0
  126. package/dist/types/sortable/Sortable.d.ts +75 -0
  127. package/dist/types/sortable/i18n/en.d.ts +2 -0
  128. package/dist/types/sortable/i18n/fr.d.ts +2 -0
  129. package/dist/types/sortable/i18n/index.d.ts +9 -0
  130. package/dist/types/sortable/i18n/types.d.ts +15 -0
  131. package/dist/types/sortable/index.d.ts +4 -0
  132. package/dist/types/sortable/types.d.ts +112 -0
  133. package/dist/types/toast/Toast.d.ts +6 -1
  134. package/dist/types/toast/ToastInstance.d.ts +7 -0
  135. package/dist/types/toast/ToastManager.d.ts +4 -2
  136. package/dist/types/toast/types.d.ts +27 -1
  137. package/dist/types/undo/UndoManager.d.ts +112 -0
  138. package/dist/types/undo/i18n/en.d.ts +2 -0
  139. package/dist/types/undo/i18n/fr.d.ts +2 -0
  140. package/dist/types/undo/i18n/index.d.ts +9 -0
  141. package/dist/types/undo/i18n/types.d.ts +6 -0
  142. package/dist/types/undo/index.d.ts +5 -0
  143. package/dist/types/undo/types.d.ts +106 -0
  144. package/dist/undo.esm.js +23 -0
  145. package/dist/undo.esm.js.map +7 -0
  146. package/dist/undo.global.js +1029 -0
  147. package/dist/undo.global.js.map +7 -0
  148. package/dist/undo.global.min.js +6 -0
  149. package/dist/undo.global.min.js.map +7 -0
  150. package/package.json +54 -5
@@ -25,38 +25,6 @@ var __WulfIIFE = (() => {
25
25
  default: () => FocusTrap
26
26
  });
27
27
 
28
- // src/common/dom.ts
29
- function getSafeWulfNamespace() {
30
- if (typeof window === "undefined") return null;
31
- const win = window;
32
- const existing = win.Wulf;
33
- if (!existing || typeof existing !== "object" || typeof Node !== "undefined" && existing instanceof Node || typeof HTMLCollection !== "undefined" && existing instanceof HTMLCollection) {
34
- const fresh = {};
35
- win.Wulf = fresh;
36
- return fresh;
37
- }
38
- return existing;
39
- }
40
- function safeCssEscape(value) {
41
- if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
42
- return CSS.escape(value);
43
- }
44
- return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
45
- }
46
- function getDeepActiveElement(root) {
47
- if (typeof document === "undefined") return null;
48
- let active = (root ?? document).activeElement;
49
- while (active && active.shadowRoot && active.shadowRoot.activeElement) {
50
- active = active.shadowRoot.activeElement;
51
- }
52
- return active && typeof active.focus === "function" ? active : null;
53
- }
54
- function isImeComposing(event) {
55
- return Boolean(
56
- event.isComposing || event.key === "Process" || event.key === "Enter" && event.keyCode === 229
57
- );
58
- }
59
-
60
28
  // src/common/AuditableComponent.ts
61
29
  var AuditableComponent = class {
62
30
  /**
@@ -118,6 +86,70 @@ var __WulfIIFE = (() => {
118
86
  }
119
87
  };
120
88
 
89
+ // src/common/dom.ts
90
+ function safeCssEscape(value) {
91
+ if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
92
+ return CSS.escape(value);
93
+ }
94
+ return String(value).replace(/["\\\u0000-\u001F\u007F]/g, "\\$&");
95
+ }
96
+ function getDeepActiveElement(root) {
97
+ if (typeof document === "undefined") return null;
98
+ let active = (root ?? document).activeElement;
99
+ while (active && active.shadowRoot && active.shadowRoot.activeElement) {
100
+ active = active.shadowRoot.activeElement;
101
+ }
102
+ return active && typeof active.focus === "function" ? active : null;
103
+ }
104
+ function isImeComposing(event) {
105
+ return Boolean(
106
+ event.isComposing || event.key === "Process" || event.key === "Enter" && event.keyCode === 229
107
+ );
108
+ }
109
+
110
+ // src/common/registry.ts
111
+ var WULF_TRAP_STACK_SYMBOL = Symbol.for("wulf.focusTrap.stack.v1");
112
+ var WULF_TOAST_MANAGER_SYMBOL = Symbol.for("wulf.toast.manager.v1");
113
+ var WULF_TOAST_CONTAINERS_SYMBOL = Symbol.for("wulf.toast.containers.v1");
114
+ var WULF_TOAST_ANNOUNCERS_SYMBOL = Symbol.for("wulf.toast.announcers.v1");
115
+ function getGlobalRegistry() {
116
+ if (typeof globalThis === "undefined") return null;
117
+ return globalThis;
118
+ }
119
+ function getSharedTrapStack() {
120
+ const reg = getGlobalRegistry();
121
+ if (!reg) return [];
122
+ let stack = reg[WULF_TRAP_STACK_SYMBOL];
123
+ if (!Array.isArray(stack)) {
124
+ stack = [];
125
+ reg[WULF_TRAP_STACK_SYMBOL] = stack;
126
+ }
127
+ return stack;
128
+ }
129
+ function getWeakSetRegistry(sym) {
130
+ if (typeof WeakSet === "undefined") return null;
131
+ const reg = getGlobalRegistry();
132
+ if (!reg) return null;
133
+ let set = reg[sym];
134
+ if (!(set instanceof WeakSet)) {
135
+ set = /* @__PURE__ */ new WeakSet();
136
+ reg[sym] = set;
137
+ }
138
+ return set;
139
+ }
140
+ function isRegisteredToastContainer(el) {
141
+ if (!el || typeof HTMLElement === "undefined" || !(el instanceof HTMLElement)) {
142
+ return false;
143
+ }
144
+ return getWeakSetRegistry(WULF_TOAST_CONTAINERS_SYMBOL)?.has(el) ?? false;
145
+ }
146
+ function isRegisteredToastAnnouncer(el) {
147
+ if (!el || typeof HTMLElement === "undefined" || !(el instanceof HTMLElement)) {
148
+ return false;
149
+ }
150
+ return getWeakSetRegistry(WULF_TOAST_ANNOUNCERS_SYMBOL)?.has(el) ?? false;
151
+ }
152
+
121
153
  // src/focus-trap/FocusTrap.ts
122
154
  var FOCUSABLE_SELECTOR = [
123
155
  "a[href]",
@@ -143,7 +175,9 @@ var __WulfIIFE = (() => {
143
175
  return null;
144
176
  }
145
177
  }
146
- var trapStack = [];
178
+ function getTrapStack() {
179
+ return getSharedTrapStack();
180
+ }
147
181
  var FocusTrap = class extends AuditableComponent {
148
182
  element;
149
183
  options;
@@ -160,8 +194,11 @@ var __WulfIIFE = (() => {
160
194
  handleFocusInBound;
161
195
  constructor(target, options = {}) {
162
196
  super();
197
+ if (typeof target === "string" && typeof document === "undefined") {
198
+ throw new Error("[Wulf.FocusTrap] Impossible de r\xE9soudre un s\xE9lecteur CSS sans environnement DOM (document).");
199
+ }
163
200
  const el = typeof target === "string" ? safeQuerySelector(document, target) : target;
164
- if (!el || !(el instanceof HTMLElement)) {
201
+ if (!el || typeof HTMLElement === "undefined" || !(el instanceof HTMLElement)) {
165
202
  throw new Error(`[Wulf.FocusTrap] Conteneur introuvable ou invalide : "${target}"`);
166
203
  }
167
204
  this.element = el;
@@ -195,9 +232,8 @@ var __WulfIIFE = (() => {
195
232
  return false;
196
233
  }
197
234
  }
198
- isElementFocusableBase(el) {
235
+ isElementVisibleAndEnabled(el) {
199
236
  if (!el || !el.isConnected) return false;
200
- if (el.tabIndex < 0) return false;
201
237
  if (el.disabled) return false;
202
238
  try {
203
239
  if (el.matches(":disabled")) return false;
@@ -217,23 +253,35 @@ var __WulfIIFE = (() => {
217
253
  }
218
254
  } else {
219
255
  if (el.style.display === "none" || el.style.visibility === "hidden") return false;
220
- const style = window.getComputedStyle(el);
221
- if (style.display === "none" || style.visibility === "hidden") return false;
222
- if (el.offsetWidth === 0 && el.offsetHeight === 0 && style.position !== "fixed") {
223
- return false;
256
+ if (typeof window !== "undefined" && typeof window.getComputedStyle === "function") {
257
+ const style = window.getComputedStyle(el);
258
+ if (style.display === "none" || style.visibility === "hidden") return false;
259
+ if (el.offsetWidth === 0 && el.offsetHeight === 0 && style.position !== "fixed") {
260
+ return false;
261
+ }
224
262
  }
225
263
  }
226
264
  return true;
227
265
  }
266
+ isElementFocusableBase(el) {
267
+ if (!el || el.tabIndex < 0) return false;
268
+ return this.isElementVisibleAndEnabled(el);
269
+ }
270
+ isProgrammaticallyFocusable(el) {
271
+ if (!el || !this.isElementVisibleAndEnabled(el)) return false;
272
+ return el.tabIndex >= 0 || el.getAttribute("tabindex") !== null;
273
+ }
228
274
  /**
229
275
  * Vérifie si un élément est réellement focusable, visible et actif dans le DOM.
230
276
  */
231
277
  isFocusable(el) {
232
278
  if (!this.isElementFocusableBase(el)) return false;
233
279
  if (el instanceof HTMLInputElement && el.type === "radio" && el.name) {
280
+ const rootNode = typeof el.getRootNode === "function" ? el.getRootNode() : this.element;
281
+ const scopeRoot = el.form && this.isNodeInsideContainer(el.form) ? el.form : rootNode && (rootNode instanceof Document || typeof ShadowRoot !== "undefined" && rootNode instanceof ShadowRoot) ? rootNode : this.element;
234
282
  const group = Array.from(
235
- this.element.querySelectorAll(`input[type="radio"][name="${safeCssEscape(el.name)}"]`)
236
- ).filter((r) => r.form === el.form && this.isElementFocusableBase(r));
283
+ scopeRoot.querySelectorAll(`input[type="radio"][name="${safeCssEscape(el.name)}"]`)
284
+ ).filter((r) => r.form === el.form && this.isNodeInsideContainer(r) && this.isElementFocusableBase(r));
237
285
  if (group.length === 0) return false;
238
286
  const checked = group.find((r) => r.checked);
239
287
  if (checked) {
@@ -243,18 +291,68 @@ var __WulfIIFE = (() => {
243
291
  }
244
292
  return true;
245
293
  }
294
+ collectFocusables(root, out, seen) {
295
+ const children = root.children;
296
+ for (let i = 0; i < children.length; i++) {
297
+ const child = children[i];
298
+ if (!(child instanceof HTMLElement)) continue;
299
+ if (child.hasAttribute("inert") || child.hidden) continue;
300
+ let matchesSelector = false;
301
+ try {
302
+ matchesSelector = child.matches(FOCUSABLE_SELECTOR);
303
+ } catch {
304
+ matchesSelector = false;
305
+ }
306
+ if (matchesSelector && !seen.has(child) && this.isFocusable(child)) {
307
+ seen.add(child);
308
+ out.push(child);
309
+ }
310
+ if (child.shadowRoot) {
311
+ this.collectFocusables(child.shadowRoot, out, seen);
312
+ }
313
+ if (child.tagName === "SLOT") {
314
+ const assigned = child.assignedElements({ flatten: true });
315
+ for (const slotted of assigned) {
316
+ if (!(slotted instanceof HTMLElement)) continue;
317
+ if (slotted.hasAttribute("inert") || slotted.hidden) continue;
318
+ let slottedMatches = false;
319
+ try {
320
+ slottedMatches = slotted.matches(FOCUSABLE_SELECTOR);
321
+ } catch {
322
+ slottedMatches = false;
323
+ }
324
+ if (slottedMatches && !seen.has(slotted) && this.isFocusable(slotted)) {
325
+ seen.add(slotted);
326
+ out.push(slotted);
327
+ }
328
+ if (slotted.shadowRoot) {
329
+ this.collectFocusables(slotted.shadowRoot, out, seen);
330
+ }
331
+ this.collectFocusables(slotted, out, seen);
332
+ }
333
+ } else {
334
+ this.collectFocusables(child, out, seen);
335
+ }
336
+ }
337
+ }
246
338
  /**
247
- * Retourne tous les éléments focusables réels ordonnés dans le conteneur.
339
+ * Retourne tous les éléments focusables réels ordonnés dans le conteneur (Light DOM + Shadow DOM ouverts).
248
340
  */
249
341
  getFocusableElements() {
250
- const rawElements = Array.from(this.element.querySelectorAll(FOCUSABLE_SELECTOR));
251
- return rawElements.filter((el) => this.isFocusable(el));
342
+ const out = [];
343
+ const seen = /* @__PURE__ */ new Set();
344
+ if (this.element.shadowRoot) {
345
+ this.collectFocusables(this.element.shadowRoot, out, seen);
346
+ }
347
+ this.collectFocusables(this.element, out, seen);
348
+ return out;
252
349
  }
253
350
  /**
254
351
  * Active le trap.
255
352
  */
256
353
  activate() {
257
- if (this.active) return this;
354
+ if (this.active || typeof document === "undefined") return this;
355
+ const trapStack = getTrapStack();
258
356
  const currentTop = trapStack[trapStack.length - 1];
259
357
  if (currentTop) {
260
358
  currentTop.pause();
@@ -278,9 +376,16 @@ var __WulfIIFE = (() => {
278
376
  document.addEventListener("touchstart", this.handleClickOutsideBound, { capture: true, signal });
279
377
  document.addEventListener("click", this.handleClickOutsideBound, { capture: true, signal });
280
378
  }
379
+ if (this.isNativeDialogElement()) {
380
+ this.element.addEventListener("close", () => this.deactivate(), { signal });
381
+ }
281
382
  this.applyInitialFocus();
282
383
  this.runAuditWarning(this.options.audit);
283
- this.options.onActivate();
384
+ try {
385
+ this.options.onActivate();
386
+ } catch (err) {
387
+ console.error("[Wulf.FocusTrap] Erreur dans onActivate:", err);
388
+ }
284
389
  return this;
285
390
  }
286
391
  /**
@@ -288,6 +393,8 @@ var __WulfIIFE = (() => {
288
393
  */
289
394
  deactivate() {
290
395
  if (!this.active) return this;
396
+ const trapStack = getTrapStack();
397
+ const wasTop = trapStack[trapStack.length - 1] === this;
291
398
  this.active = false;
292
399
  this.paused = false;
293
400
  const index = trapStack.indexOf(this);
@@ -301,15 +408,21 @@ var __WulfIIFE = (() => {
301
408
  this.element.removeAttribute("tabindex");
302
409
  this.addedContainerTabIndex = false;
303
410
  }
304
- const nextTop = trapStack[trapStack.length - 1];
305
- if (nextTop) {
306
- nextTop.unpause();
307
- }
308
- if (this.options.returnFocus) {
309
- this.restoreFocus();
411
+ if (wasTop) {
412
+ const nextTop = trapStack[trapStack.length - 1];
413
+ if (nextTop) {
414
+ nextTop.unpause();
415
+ }
416
+ if (this.options.returnFocus) {
417
+ this.restoreFocus();
418
+ }
310
419
  }
311
420
  this.previousActiveElement = null;
312
- this.options.onDeactivate();
421
+ try {
422
+ this.options.onDeactivate();
423
+ } catch (err) {
424
+ console.error("[Wulf.FocusTrap] Erreur dans onDeactivate:", err);
425
+ }
313
426
  return this;
314
427
  }
315
428
  /**
@@ -325,6 +438,7 @@ var __WulfIIFE = (() => {
325
438
  */
326
439
  unpause() {
327
440
  if (!this.active) return;
441
+ const trapStack = getTrapStack();
328
442
  if (trapStack[trapStack.length - 1] !== this) return;
329
443
  this.paused = false;
330
444
  if (this.options.setInert && !this.isNativeModalDialog()) {
@@ -375,12 +489,23 @@ var __WulfIIFE = (() => {
375
489
  }
376
490
  }
377
491
  const ariaLabel = this.element.getAttribute("aria-label")?.trim();
378
- const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings);
492
+ const hasValidLabelledby = this.checkAriaIdReferences(this.element, "aria-labelledby", warnings, true);
379
493
  if (!ariaLabel && !hasValidLabelledby) {
380
494
  warnings.push(
381
495
  'Nom accessible manquant : d\xE9finissez aria-labelledby="id-titre" ou aria-label="..." sur le conteneur (WCAG 4.1.2).'
382
496
  );
383
497
  }
498
+ if (this.element.hasAttribute("aria-describedby")) {
499
+ this.checkAriaIdReferences(this.element, "aria-describedby", warnings, true);
500
+ }
501
+ const positiveTabIndexEls = Array.from(this.element.querySelectorAll("[tabindex]")).filter(
502
+ (el) => el.tabIndex > 0
503
+ );
504
+ if (positiveTabIndexEls.length > 0) {
505
+ warnings.push(
506
+ `${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).`
507
+ );
508
+ }
384
509
  return warnings;
385
510
  }
386
511
  getAuditPrefix() {
@@ -396,8 +521,23 @@ var __WulfIIFE = (() => {
396
521
  this.deactivate();
397
522
  }
398
523
  // --- Implémentation interne ---
524
+ isNodeInsideContainer(node) {
525
+ let current = node;
526
+ while (current) {
527
+ if (current === this.element || this.element.contains(current)) {
528
+ return true;
529
+ }
530
+ const root = typeof current.getRootNode === "function" ? current.getRootNode() : null;
531
+ if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && root.host) {
532
+ current = root.host;
533
+ } else {
534
+ break;
535
+ }
536
+ }
537
+ return false;
538
+ }
399
539
  isEventInside(e, target) {
400
- if (target && this.element.contains(target)) {
540
+ if (this.isNodeInsideContainer(target)) {
401
541
  return true;
402
542
  }
403
543
  if (typeof e.composedPath === "function") {
@@ -409,8 +549,23 @@ var __WulfIIFE = (() => {
409
549
  return false;
410
550
  }
411
551
  isInsideToastContainer(target) {
412
- if (!target || !(target instanceof Element)) return false;
413
- return Boolean(target.closest(".wulf-toast-container"));
552
+ if (typeof document === "undefined" || !target) return false;
553
+ let current = target;
554
+ while (current) {
555
+ if (current instanceof Element) {
556
+ const container = current.closest(".wulf-toast-container");
557
+ if (container && isRegisteredToastContainer(container) && container.parentElement === document.body && !this.isNodeInsideContainer(container)) {
558
+ return true;
559
+ }
560
+ }
561
+ const root = typeof current.getRootNode === "function" ? current.getRootNode() : null;
562
+ if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && root.host) {
563
+ current = root.host;
564
+ } else {
565
+ break;
566
+ }
567
+ }
568
+ return false;
414
569
  }
415
570
  ensureContainerTabIndex() {
416
571
  if (this.element.getAttribute("tabindex") === null) {
@@ -425,11 +580,16 @@ var __WulfIIFE = (() => {
425
580
  return;
426
581
  }
427
582
  if (e.key === "Escape" && this.options.escapeDeactivates) {
428
- if (isImeComposing(e)) return;
429
- if (!this.isNativeModalDialog()) {
430
- e.preventDefault();
431
- e.stopPropagation();
583
+ if (e.defaultPrevented || e.ctrlKey || e.altKey || e.metaKey || e.shiftKey || isImeComposing(e)) return;
584
+ const deepActive = getDeepActiveElement(document);
585
+ if (this.isInsideToastContainer(deepActive) || this.isInsideToastContainer(e.target)) {
586
+ return;
587
+ }
588
+ if (this.isNativeModalDialog()) {
589
+ return;
432
590
  }
591
+ e.preventDefault();
592
+ e.stopPropagation();
433
593
  this.deactivate();
434
594
  return;
435
595
  }
@@ -445,7 +605,7 @@ var __WulfIIFE = (() => {
445
605
  const last = focusables[focusables.length - 1];
446
606
  const deepCurrent = getDeepActiveElement(document);
447
607
  const current = deepCurrent instanceof HTMLElement ? deepCurrent : document.activeElement;
448
- const isInside = current ? this.element.contains(current) || this.isEventInside(e, current) : false;
608
+ const isInside = current ? this.isNodeInsideContainer(current) || this.isEventInside(e, current) : false;
449
609
  if (!e.shiftKey && (current === last || !isInside)) {
450
610
  e.preventDefault();
451
611
  first.focus();
@@ -498,22 +658,39 @@ var __WulfIIFE = (() => {
498
658
  }
499
659
  }
500
660
  /**
501
- * Applique `inert` sur les éléments frères à chaque niveau hiérarchique jusqu'à <body>,
502
- * en préservant les conteneurs de notifications Toast en Top Layer.
661
+ * Applique `inert` sur les éléments frères à chaque niveau hiérarchique jusqu'à <body>
662
+ * (y compris en remontant à travers les ShadowRoot.host), en préservant les conteneurs
663
+ * de notifications Toast en Top Layer enfants directs de <body>.
503
664
  */
504
665
  applyInert() {
505
666
  this.removeInert();
667
+ if (typeof document === "undefined") return;
506
668
  let current = this.element;
507
669
  const ignoredTags = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "TEMPLATE", "LINK", "META", "NOSCRIPT"]);
508
- while (current && current !== document.body && current.parentElement) {
670
+ while (current && current !== document.body) {
509
671
  const parent = current.parentElement;
510
- for (const sibling of Array.from(parent.children)) {
511
- if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert") && !sibling.matches(".wulf-toast-container, .wulf-toast-announcer")) {
512
- sibling.setAttribute("inert", "");
513
- this.inertSiblings.push(sibling);
672
+ if (parent) {
673
+ for (const sibling of Array.from(parent.children)) {
674
+ if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert") && !(parent === document.body && (isRegisteredToastContainer(sibling) || isRegisteredToastAnnouncer(sibling)))) {
675
+ sibling.setAttribute("inert", "");
676
+ this.inertSiblings.push(sibling);
677
+ }
678
+ }
679
+ current = parent;
680
+ } else {
681
+ const root = typeof current.getRootNode === "function" ? current.getRootNode() : null;
682
+ if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot) {
683
+ for (const sibling of Array.from(root.children)) {
684
+ if (sibling instanceof HTMLElement && sibling !== current && !ignoredTags.has(sibling.tagName) && !sibling.hasAttribute("inert")) {
685
+ sibling.setAttribute("inert", "");
686
+ this.inertSiblings.push(sibling);
687
+ }
688
+ }
689
+ current = root.host instanceof HTMLElement ? root.host : null;
690
+ } else {
691
+ break;
514
692
  }
515
693
  }
516
- current = parent;
517
694
  }
518
695
  }
519
696
  removeInert() {
@@ -526,11 +703,15 @@ var __WulfIIFE = (() => {
526
703
  if (typeof this.options.initialFocus === "string") {
527
704
  targetEl = safeQuerySelector(this.element, this.options.initialFocus);
528
705
  } else if (this.options.initialFocus instanceof HTMLElement) {
529
- targetEl = this.options.initialFocus;
706
+ targetEl = this.isNodeInsideContainer(this.options.initialFocus) ? this.options.initialFocus : null;
530
707
  }
531
- if (targetEl && this.isFocusable(targetEl)) {
532
- targetEl.focus();
533
- return;
708
+ if (targetEl) {
709
+ const isRadio = targetEl instanceof HTMLInputElement && targetEl.type === "radio" && Boolean(targetEl.name);
710
+ const canFocus = isRadio && targetEl.tabIndex >= 0 ? this.isFocusable(targetEl) : this.isProgrammaticallyFocusable(targetEl);
711
+ if (canFocus) {
712
+ targetEl.focus();
713
+ return;
714
+ }
534
715
  }
535
716
  const focusables = this.getFocusableElements();
536
717
  if (focusables.length > 0) {
@@ -541,27 +722,19 @@ var __WulfIIFE = (() => {
541
722
  }
542
723
  }
543
724
  restoreFocus() {
544
- if (this.previousActiveElement && this.previousActiveElement.isConnected && this.isElementFocusableBase(this.previousActiveElement)) {
725
+ if (this.previousActiveElement && this.previousActiveElement.isConnected && this.isProgrammaticallyFocusable(this.previousActiveElement)) {
545
726
  this.previousActiveElement.focus();
546
727
  return;
547
728
  }
548
- if (this.options.fallbackReturnFocus) {
729
+ if (this.options.fallbackReturnFocus && typeof document !== "undefined") {
549
730
  const fallback = typeof this.options.fallbackReturnFocus === "string" ? safeQuerySelector(document, this.options.fallbackReturnFocus) : this.options.fallbackReturnFocus;
550
- if (fallback && fallback.isConnected && this.isElementFocusableBase(fallback)) {
731
+ if (fallback && fallback.isConnected && this.isProgrammaticallyFocusable(fallback)) {
551
732
  fallback.focus();
552
733
  }
553
734
  }
554
735
  }
555
736
  };
556
-
557
- // src/focus-trap/index.ts
558
- var wulfNamespace = getSafeWulfNamespace();
559
- if (wulfNamespace) {
560
- wulfNamespace.FocusTrap = Object.assign(FocusTrap, {
561
- FocusTrap
562
- });
563
- }
564
737
  return __toCommonJS(index_exports);
565
738
  })();
566
- if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { for (var k in __WulfIIFE) { if (Object.hasOwn(__WulfIIFE, k) && k !== "__proto__" && k !== "constructor" && k !== "prototype" && __w[k] === undefined) { try { Object.defineProperty(__w, k, { value: __WulfIIFE[k], writable: true, configurable: true, enumerable: true }); } catch (_) { try { __w[k] = __WulfIIFE[k]; } catch (__) {} } } } } }
739
+ if (typeof window !== "undefined") { var __w = window.Wulf; if (!__w || typeof __w !== "object" || (typeof Node !== "undefined" && __w instanceof Node) || (typeof HTMLCollection !== "undefined" && __w instanceof HTMLCollection)) { __w = {}; window.Wulf = __w; } var __set = function(obj, key, val) { try { Object.defineProperty(obj, key, { value: val, writable: true, configurable: true, enumerable: true }); } catch (_) { try { obj[key] = val; } catch (__) {} } }; if (typeof __WulfIIFE !== "undefined" && __WulfIIFE) { var __e = __WulfIIFE; var __skip = ["__proto__","constructor","prototype"]; for (var k in __e) { if (Object.hasOwn(__e, k) && __skip.indexOf(k) === -1 && __w[k] === undefined) { __set(__w, k, __e[k]); } } if (__e.FocusTrap) __set(__w, "FocusTrap", Object.assign(__e.FocusTrap, { FocusTrap: __e.FocusTrap, default: __e.FocusTrap })); }}
567
740
  //# sourceMappingURL=focus-trap.global.js.map