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
@@ -0,0 +1,695 @@
1
+ "use strict";
2
+ var __WulfIIFE = (() => {
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/anchor/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ Anchor: () => Anchor,
25
+ default: () => Anchor
26
+ });
27
+
28
+ // src/common/AuditableComponent.ts
29
+ var AuditableComponent = class {
30
+ /**
31
+ * Indication affichée en pied de warning pour expliquer comment désactiver l'audit.
32
+ */
33
+ getAuditDisableHint() {
34
+ return "Passez { audit: false } dans les options pour d\xE9sactiver cet avertissement";
35
+ }
36
+ /**
37
+ * Exécute l'audit d'accessibilité et émet un avertissement standardisé dans la console
38
+ * si l'audit est activé et que des contraintes manquent.
39
+ */
40
+ runAuditWarning(enabled = true) {
41
+ if (!enabled) return [];
42
+ const warnings = this.audit();
43
+ if (warnings.length > 0 && typeof console !== "undefined" && typeof console.warn === "function") {
44
+ console.warn(
45
+ `[${this.getAuditPrefix()}] Audit d'accessibilit\xE9 \u2014 ${warnings.length} contrainte(s) manquante(s) sur ${this.getAuditTargetLabel()} :
46
+ ` + warnings.map((w) => ` - ${w}`).join("\n") + `
47
+ (${this.getAuditDisableHint()})`
48
+ );
49
+ }
50
+ return warnings;
51
+ }
52
+ /**
53
+ * Vérifie si un attribut de référence d'IDs ARIA (ex: aria-labelledby, aria-describedby, aria-errormessage)
54
+ * pointe vers des éléments réellement présents dans le document (et optionnellement non vides).
55
+ */
56
+ checkAriaIdReferences(element, attrName, warnings, requireNonEmptyText = false) {
57
+ const rawValue = element.getAttribute(attrName)?.trim();
58
+ if (!rawValue) return false;
59
+ const doc = element.ownerDocument || document;
60
+ const root = typeof element.getRootNode === "function" ? element.getRootNode() : doc;
61
+ const ids = rawValue.split(/\s+/).filter(Boolean);
62
+ const targets = ids.map(
63
+ (id) => typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root.getElementById(id) : doc.getElementById(id)
64
+ );
65
+ const allFound = ids.length > 0 && targets.every((el) => Boolean(el));
66
+ if (!allFound) {
67
+ warnings.push(
68
+ `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible est introuvable dans le DOM.`
69
+ );
70
+ return false;
71
+ }
72
+ if (requireNonEmptyText) {
73
+ const hasNonEmptyText = targets.some((el) => {
74
+ if (!el) return false;
75
+ const text = el.textContent?.trim() || el.getAttribute("aria-label")?.trim() || "";
76
+ return text.length > 0;
77
+ });
78
+ if (!hasNonEmptyText) {
79
+ warnings.push(
80
+ `Attribut ${attrName}="${rawValue}" invalide : l'\xE9l\xE9ment cible ne contient aucun texte accessible.`
81
+ );
82
+ return false;
83
+ }
84
+ }
85
+ return true;
86
+ }
87
+ };
88
+
89
+ // src/anchor/Anchor.ts
90
+ var anchorIdCounter = 0;
91
+ var ALL_PLACEMENTS = [
92
+ "bottom-start",
93
+ "bottom",
94
+ "bottom-end",
95
+ "top-start",
96
+ "top",
97
+ "top-end",
98
+ "right-start",
99
+ "right",
100
+ "right-end",
101
+ "left-start",
102
+ "left",
103
+ "left-end"
104
+ ];
105
+ var PLACEMENT_SET = new Set(ALL_PLACEMENTS);
106
+ function resolveCandidatePlacements(preferred) {
107
+ const seen = /* @__PURE__ */ new Set();
108
+ const out = [];
109
+ if (Array.isArray(preferred)) {
110
+ for (const p of preferred) {
111
+ if (typeof p === "string" && PLACEMENT_SET.has(p) && !seen.has(p)) {
112
+ seen.add(p);
113
+ out.push(p);
114
+ }
115
+ }
116
+ }
117
+ for (const p of ALL_PLACEMENTS) {
118
+ if (!seen.has(p)) out.push(p);
119
+ }
120
+ return out;
121
+ }
122
+ var OPPOSITE_SIDE = {
123
+ top: "bottom",
124
+ bottom: "top",
125
+ left: "right",
126
+ right: "left"
127
+ };
128
+ var ROLE_BY_HASPOPUP = {
129
+ menu: "menu",
130
+ listbox: "listbox",
131
+ tree: "tree",
132
+ grid: "grid",
133
+ dialog: "dialog"
134
+ };
135
+ function resolveEl(target, root) {
136
+ if (typeof target !== "string") {
137
+ return typeof HTMLElement !== "undefined" && target instanceof HTMLElement ? target : null;
138
+ }
139
+ if (!target || typeof document === "undefined") return null;
140
+ try {
141
+ return (root ?? document).querySelector(target);
142
+ } catch {
143
+ return null;
144
+ }
145
+ }
146
+ function getParentCrossingShadow(el) {
147
+ if (el.parentElement) return el.parentElement;
148
+ const root = typeof el.getRootNode === "function" ? el.getRootNode() : null;
149
+ if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && root.host instanceof HTMLElement) {
150
+ return root.host;
151
+ }
152
+ return null;
153
+ }
154
+ function isTopLayerElement(el) {
155
+ try {
156
+ return el.matches(":popover-open") || el.matches(":modal");
157
+ } catch {
158
+ return el.classList.contains(":popover-open");
159
+ }
160
+ }
161
+ function isRtlElement(el) {
162
+ if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") return false;
163
+ return window.getComputedStyle(el).direction === "rtl";
164
+ }
165
+ function parsePlacement(placement) {
166
+ const idx = placement.indexOf("-");
167
+ if (idx === -1) return [placement, null];
168
+ return [placement.slice(0, idx), placement.slice(idx + 1)];
169
+ }
170
+ function toLogicalPositionArea(side, alignment, rtl) {
171
+ const inlineStart = rtl ? "right" : "left";
172
+ const blockPos = side === "top" ? "block-start" : side === "bottom" ? "block-end" : null;
173
+ if (blockPos) {
174
+ if (!alignment) return blockPos;
175
+ return `${blockPos} ${alignment === "start" ? "span-inline-end" : "span-inline-start"}`;
176
+ }
177
+ const inlinePos = side === inlineStart ? "inline-start" : "inline-end";
178
+ if (!alignment) return inlinePos;
179
+ return `${inlinePos} ${alignment === "start" ? "span-block-end" : "span-block-start"}`;
180
+ }
181
+ function intersectRects(a, b) {
182
+ const x = Math.max(a.x, b.x);
183
+ const y = Math.max(a.y, b.y);
184
+ const right = Math.min(a.x + a.width, b.x + b.width);
185
+ const bottom = Math.min(a.y + a.height, b.y + b.height);
186
+ return { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };
187
+ }
188
+ function getViewportRect() {
189
+ if (typeof window === "undefined" || typeof document === "undefined") {
190
+ return { x: 0, y: 0, width: 0, height: 0 };
191
+ }
192
+ const vv = window.visualViewport;
193
+ if (vv) {
194
+ return { x: vv.offsetLeft, y: vv.offsetTop, width: vv.width, height: vv.height };
195
+ }
196
+ return {
197
+ x: 0,
198
+ y: 0,
199
+ width: document.documentElement.clientWidth || window.innerWidth,
200
+ height: document.documentElement.clientHeight || window.innerHeight
201
+ };
202
+ }
203
+ function getBoundaryRect(floating, boundary) {
204
+ if (boundary && typeof boundary === "object" && !("nodeType" in boundary)) {
205
+ return { ...boundary };
206
+ }
207
+ if (typeof HTMLElement !== "undefined" && boundary instanceof HTMLElement) {
208
+ const r = boundary.getBoundingClientRect();
209
+ return { x: r.left, y: r.top, width: r.width, height: r.height };
210
+ }
211
+ let rect = getViewportRect();
212
+ if (boundary === "viewport" || isTopLayerElement(floating) || typeof window === "undefined") {
213
+ return rect;
214
+ }
215
+ const clipRe = /(hidden|clip|auto|scroll)/;
216
+ let cur = getParentCrossingShadow(floating);
217
+ while (cur && cur !== document.body && cur !== document.documentElement) {
218
+ const cs = window.getComputedStyle(cur);
219
+ if (clipRe.test(cs.overflow + cs.overflowX + cs.overflowY)) {
220
+ const cr = cur.getBoundingClientRect();
221
+ rect = intersectRects(rect, {
222
+ x: cr.left + cur.clientLeft,
223
+ y: cr.top + cur.clientTop,
224
+ width: cur.clientWidth || cr.width,
225
+ height: cur.clientHeight || cr.height
226
+ });
227
+ }
228
+ cur = getParentCrossingShadow(cur);
229
+ }
230
+ return rect;
231
+ }
232
+ function getContainingBlockOffset(floating, strategy) {
233
+ if (typeof window === "undefined") return { x: 0, y: 0 };
234
+ if (strategy === "absolute") {
235
+ const op = floating.offsetParent;
236
+ if (op instanceof HTMLElement && op !== document.body && op !== document.documentElement) {
237
+ const r = op.getBoundingClientRect();
238
+ return { x: r.left + op.clientLeft - op.scrollLeft, y: r.top + op.clientTop - op.scrollTop };
239
+ }
240
+ return { x: -window.scrollX, y: -window.scrollY };
241
+ }
242
+ if (isTopLayerElement(floating)) return { x: 0, y: 0 };
243
+ let cur = getParentCrossingShadow(floating);
244
+ while (cur && cur !== document.documentElement) {
245
+ const cs = window.getComputedStyle(cur);
246
+ if (cs.transform !== "none" || cs.perspective !== "none" || cs.filter !== "none" || cs.backdropFilter && cs.backdropFilter !== "none" || /layout|paint|strict|content/.test(cs.contain) || /transform|perspective|filter/.test(cs.willChange)) {
247
+ const r = cur.getBoundingClientRect();
248
+ return {
249
+ x: r.left + cur.clientLeft - cur.scrollLeft,
250
+ y: r.top + cur.clientTop - cur.scrollTop
251
+ };
252
+ }
253
+ cur = getParentCrossingShadow(cur);
254
+ }
255
+ return { x: 0, y: 0 };
256
+ }
257
+ var Anchor = class _Anchor extends AuditableComponent {
258
+ reference;
259
+ floating;
260
+ options;
261
+ anchorName;
262
+ isDestroyed = false;
263
+ isRunning = false;
264
+ nativeApplied = false;
265
+ rafId = null;
266
+ resizeObserver = null;
267
+ abortController = null;
268
+ savedRefAnchorName = "";
269
+ savedFloatingStyles = {};
270
+ savedPlacementAttr = null;
271
+ savedArrowStyles = null;
272
+ constructor(reference, floating, options = {}) {
273
+ super();
274
+ const refEl = resolveEl(reference);
275
+ const floatEl = resolveEl(floating);
276
+ if (!refEl || !floatEl) {
277
+ throw new Error("[Wulf.Anchor] \xC9l\xE9ments reference et floating valides requis.");
278
+ }
279
+ this.reference = refEl;
280
+ this.floating = floatEl;
281
+ this.anchorName = `--wulf-anchor-${++anchorIdCounter}`;
282
+ const arrowEl = options.arrow ? typeof options.arrow === "string" ? resolveEl(options.arrow, floatEl) ?? resolveEl(options.arrow) : resolveEl(options.arrow) : null;
283
+ const rawPad = options.padding;
284
+ const padding = typeof rawPad === "number" && Number.isFinite(rawPad) && rawPad >= 0 ? rawPad : 8;
285
+ const rawArrowPad = options.arrowPadding;
286
+ const arrowPadding = typeof rawArrowPad === "number" && Number.isFinite(rawArrowPad) && rawArrowPad >= 0 ? rawArrowPad : 6;
287
+ this.options = {
288
+ placement: options.placement ?? "bottom-start",
289
+ strategy: options.strategy ?? "fixed",
290
+ offset: options.offset ?? 8,
291
+ flip: options.flip ?? true,
292
+ shift: options.shift ?? true,
293
+ padding,
294
+ arrow: arrowEl,
295
+ arrowPadding,
296
+ boundary: options.boundary ?? "clippingAncestors",
297
+ autoUpdate: options.autoUpdate ?? true,
298
+ useNativeAnchor: options.useNativeAnchor ?? false,
299
+ preferredPlacements: Array.isArray(options.preferredPlacements) ? [...options.preferredPlacements] : void 0,
300
+ onPosition: options.onPosition,
301
+ audit: options.audit ?? true
302
+ };
303
+ this.saveInitialState();
304
+ this.update();
305
+ if (this.options.autoUpdate) {
306
+ this.start();
307
+ }
308
+ this.runAuditWarning(this.options.audit);
309
+ }
310
+ /**
311
+ * Détecte si CSS Anchor Positioning natif (anchor-name + position-area) est supporté.
312
+ */
313
+ static supportsNativeAnchor() {
314
+ return typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("anchor-name", "--wulf-a") && CSS.supports("position-area", "block-end");
315
+ }
316
+ /**
317
+ * Calcule la position géométrique optimale sans muter le DOM.
318
+ */
319
+ static computePosition(reference, floating, options = {}) {
320
+ const placement = options.placement ?? "bottom-start";
321
+ const strategy = options.strategy ?? "fixed";
322
+ const flip = options.flip ?? true;
323
+ const shift = options.shift ?? true;
324
+ const padding = typeof options.padding === "number" && Number.isFinite(options.padding) ? Math.max(0, options.padding) : 8;
325
+ const arrowPadding = typeof options.arrowPadding === "number" && Number.isFinite(options.arrowPadding) ? Math.max(0, options.arrowPadding) : 6;
326
+ const rawOffset = options.offset ?? 8;
327
+ const mainOffset = typeof rawOffset === "number" ? rawOffset : rawOffset.mainAxis ?? 8;
328
+ const crossOffset = typeof rawOffset === "number" ? 0 : rawOffset.crossAxis ?? 0;
329
+ const refRect = reference.getBoundingClientRect();
330
+ const floatRect = floating.getBoundingClientRect();
331
+ const boundary = getBoundaryRect(floating, options.boundary ?? "clippingAncestors");
332
+ const cb = getContainingBlockOffset(floating, strategy);
333
+ const rtl = isRtlElement(floating) || isRtlElement(reference);
334
+ const placeFor = (s, al) => {
335
+ let vx2 = 0;
336
+ let vy2 = 0;
337
+ if (s === "top" || s === "bottom") {
338
+ vy2 = s === "bottom" ? refRect.bottom + mainOffset : refRect.top - floatRect.height - mainOffset;
339
+ if (!al) {
340
+ vx2 = refRect.left + (refRect.width - floatRect.width) / 2;
341
+ } else {
342
+ const alignLeft = al === "start" !== rtl;
343
+ vx2 = alignLeft ? refRect.left : refRect.right - floatRect.width;
344
+ }
345
+ vx2 += rtl ? -crossOffset : crossOffset;
346
+ } else {
347
+ vx2 = s === "right" ? refRect.right + mainOffset : refRect.left - floatRect.width - mainOffset;
348
+ if (!al) {
349
+ vy2 = refRect.top + (refRect.height - floatRect.height) / 2;
350
+ } else {
351
+ vy2 = al === "start" ? refRect.top : refRect.bottom - floatRect.height;
352
+ }
353
+ vy2 += crossOffset;
354
+ }
355
+ return { vx: vx2, vy: vy2 };
356
+ };
357
+ let side;
358
+ let alignment;
359
+ let vx;
360
+ let vy;
361
+ if (placement === "best") {
362
+ const candidates = resolveCandidatePlacements(options.preferredPlacements);
363
+ let chosen = candidates[0];
364
+ if (floatRect.width > 0 || floatRect.height > 0) {
365
+ const minX = boundary.x + padding - 0.5;
366
+ const maxX = boundary.x + boundary.width - padding + 0.5;
367
+ const minY = boundary.y + padding - 0.5;
368
+ const maxY = boundary.y + boundary.height - padding + 0.5;
369
+ for (const cand of candidates) {
370
+ const [cs, ca] = parsePlacement(cand);
371
+ const pos = placeFor(cs, ca);
372
+ if (pos.vx >= minX && pos.vx + floatRect.width <= maxX && pos.vy >= minY && pos.vy + floatRect.height <= maxY) {
373
+ chosen = cand;
374
+ break;
375
+ }
376
+ }
377
+ }
378
+ [side, alignment] = parsePlacement(chosen);
379
+ ({ vx, vy } = placeFor(side, alignment));
380
+ } else {
381
+ [side, alignment] = parsePlacement(placement);
382
+ ({ vx, vy } = placeFor(side, alignment));
383
+ if (flip) {
384
+ const opp = OPPOSITE_SIDE[side];
385
+ const availCurrent = side === "bottom" ? boundary.y + boundary.height - padding - (refRect.bottom + mainOffset) : side === "top" ? refRect.top - mainOffset - (boundary.y + padding) : side === "right" ? boundary.x + boundary.width - padding - (refRect.right + mainOffset) : refRect.left - mainOffset - (boundary.x + padding);
386
+ const availOpp = opp === "bottom" ? boundary.y + boundary.height - padding - (refRect.bottom + mainOffset) : opp === "top" ? refRect.top - mainOffset - (boundary.y + padding) : opp === "right" ? boundary.x + boundary.width - padding - (refRect.right + mainOffset) : refRect.left - mainOffset - (boundary.x + padding);
387
+ const needed = side === "top" || side === "bottom" ? floatRect.height : floatRect.width;
388
+ if (availCurrent < needed && availOpp > availCurrent) {
389
+ side = opp;
390
+ ({ vx, vy } = placeFor(side, alignment));
391
+ }
392
+ }
393
+ }
394
+ if (shift) {
395
+ if (side === "top" || side === "bottom") {
396
+ const minX = boundary.x + padding;
397
+ const maxX = Math.max(minX, boundary.x + boundary.width - floatRect.width - padding);
398
+ vx = Math.min(Math.max(vx, minX), maxX);
399
+ } else {
400
+ const minY = boundary.y + padding;
401
+ const maxY = Math.max(minY, boundary.y + boundary.height - floatRect.height - padding);
402
+ vy = Math.min(Math.max(vy, minY), maxY);
403
+ }
404
+ }
405
+ const effectivePlacement = alignment ? `${side}-${alignment}` : side;
406
+ const x = Math.round((vx - cb.x) * 100) / 100;
407
+ const y = Math.round((vy - cb.y) * 100) / 100;
408
+ let arrowX = null;
409
+ let arrowY = null;
410
+ const arrowEl = options.arrow instanceof HTMLElement ? options.arrow : null;
411
+ if (arrowEl) {
412
+ const ar = arrowEl.getBoundingClientRect();
413
+ if (side === "top" || side === "bottom") {
414
+ const maxAx = Math.max(arrowPadding, floatRect.width - ar.width - arrowPadding);
415
+ arrowX = Math.round(Math.min(Math.max(refRect.left + refRect.width / 2 - vx - ar.width / 2, arrowPadding), maxAx) * 100) / 100;
416
+ } else {
417
+ const maxAy = Math.max(arrowPadding, floatRect.height - ar.height - arrowPadding);
418
+ arrowY = Math.round(Math.min(Math.max(refRect.top + refRect.height / 2 - vy - ar.height / 2, arrowPadding), maxAy) * 100) / 100;
419
+ }
420
+ }
421
+ const isReferenceClipped = refRect.right <= boundary.x || refRect.left >= boundary.x + boundary.width || refRect.bottom <= boundary.y || refRect.top >= boundary.y + boundary.height;
422
+ return {
423
+ x,
424
+ y,
425
+ viewportX: Math.round(vx * 100) / 100,
426
+ viewportY: Math.round(vy * 100) / 100,
427
+ placement: effectivePlacement,
428
+ side,
429
+ alignment,
430
+ arrowX,
431
+ arrowY,
432
+ isNative: false,
433
+ isReferenceClipped
434
+ };
435
+ }
436
+ update() {
437
+ if (this.isDestroyed) {
438
+ const fallbackPlacement = this.options.placement === "best" ? resolveCandidatePlacements(this.options.preferredPlacements)[0] : this.options.placement;
439
+ const [side, alignment] = parsePlacement(fallbackPlacement);
440
+ return {
441
+ x: 0,
442
+ y: 0,
443
+ viewportX: 0,
444
+ viewportY: 0,
445
+ placement: fallbackPlacement,
446
+ side,
447
+ alignment,
448
+ arrowX: null,
449
+ arrowY: null,
450
+ isNative: false,
451
+ isReferenceClipped: false
452
+ };
453
+ }
454
+ const canUseNative = this.options.useNativeAnchor && this.options.placement !== "best" && !this.options.arrow && this.options.strategy === "fixed" && _Anchor.supportsNativeAnchor();
455
+ let result;
456
+ if (canUseNative) {
457
+ const nativePlacement = this.options.placement;
458
+ const [side, alignment] = parsePlacement(nativePlacement);
459
+ const rtl = isRtlElement(this.floating) || isRtlElement(this.reference);
460
+ const fStyle = this.floating.style;
461
+ const rStyle = this.reference.style;
462
+ rStyle.anchorName = this.anchorName;
463
+ fStyle.position = "fixed";
464
+ fStyle.inset = "auto";
465
+ fStyle.margin = "0";
466
+ fStyle.positionAnchor = this.anchorName;
467
+ fStyle.positionArea = toLogicalPositionArea(side, alignment, rtl);
468
+ if (this.options.flip) {
469
+ fStyle.positionTryFallbacks = "flip-block, flip-inline, flip-block flip-inline";
470
+ }
471
+ this.nativeApplied = true;
472
+ this.floating.setAttribute("data-anchor-placement", nativePlacement);
473
+ const fr = this.floating.getBoundingClientRect();
474
+ result = {
475
+ x: fr.left,
476
+ y: fr.top,
477
+ viewportX: fr.left,
478
+ viewportY: fr.top,
479
+ placement: nativePlacement,
480
+ side,
481
+ alignment,
482
+ arrowX: null,
483
+ arrowY: null,
484
+ isNative: true,
485
+ isReferenceClipped: false
486
+ };
487
+ } else {
488
+ if (this.nativeApplied) {
489
+ this.restoreNativeStyles();
490
+ }
491
+ result = _Anchor.computePosition(this.reference, this.floating, {
492
+ ...this.options,
493
+ arrow: this.options.arrow
494
+ });
495
+ this.floating.style.position = this.options.strategy;
496
+ this.floating.style.left = `${result.x}px`;
497
+ this.floating.style.top = `${result.y}px`;
498
+ this.floating.style.setProperty("--wulf-anchor-x", `${result.x}px`);
499
+ this.floating.style.setProperty("--wulf-anchor-y", `${result.y}px`);
500
+ this.floating.setAttribute("data-anchor-placement", result.placement);
501
+ if (this.options.arrow) {
502
+ if (result.arrowX !== null) {
503
+ this.options.arrow.style.left = `${result.arrowX}px`;
504
+ this.options.arrow.style.top = "";
505
+ this.options.arrow.style.setProperty("--wulf-anchor-arrow-x", `${result.arrowX}px`);
506
+ } else if (result.arrowY !== null) {
507
+ this.options.arrow.style.top = `${result.arrowY}px`;
508
+ this.options.arrow.style.left = "";
509
+ this.options.arrow.style.setProperty("--wulf-anchor-arrow-y", `${result.arrowY}px`);
510
+ }
511
+ }
512
+ }
513
+ if (this.options.onPosition) {
514
+ try {
515
+ this.options.onPosition(result);
516
+ } catch (err) {
517
+ console.error("[Wulf.Anchor] Erreur dans onPosition:", err);
518
+ }
519
+ }
520
+ return result;
521
+ }
522
+ setPlacement(placement) {
523
+ if (!this.isDestroyed) {
524
+ this.options.placement = placement;
525
+ this.update();
526
+ }
527
+ return this;
528
+ }
529
+ start() {
530
+ if (this.isDestroyed || this.isRunning || typeof window === "undefined") return this;
531
+ this.isRunning = true;
532
+ this.abortController = new AbortController();
533
+ const { signal } = this.abortController;
534
+ const schedule = () => {
535
+ if (this.isDestroyed || this.rafId !== null) return;
536
+ this.rafId = window.requestAnimationFrame(() => {
537
+ this.rafId = null;
538
+ if (!this.isDestroyed) this.update();
539
+ });
540
+ };
541
+ if (typeof ResizeObserver !== "undefined") {
542
+ const lastSizes = /* @__PURE__ */ new WeakMap();
543
+ this.resizeObserver = new ResizeObserver((entries) => {
544
+ if (this.isDestroyed) return;
545
+ let changed = false;
546
+ for (const entry of entries) {
547
+ const w = entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;
548
+ const h = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
549
+ const prev = lastSizes.get(entry.target);
550
+ if (!prev || Math.abs(w - prev.w) >= 0.5 || Math.abs(h - prev.h) >= 0.5) {
551
+ lastSizes.set(entry.target, { w, h });
552
+ changed = true;
553
+ }
554
+ }
555
+ if (changed) {
556
+ this.update();
557
+ }
558
+ });
559
+ this.resizeObserver.observe(this.reference);
560
+ this.resizeObserver.observe(this.floating);
561
+ }
562
+ const seenScrollParents = /* @__PURE__ */ new Set();
563
+ for (const startNode of [this.reference, this.floating]) {
564
+ let cur = startNode;
565
+ while (cur) {
566
+ if (!seenScrollParents.has(cur)) {
567
+ seenScrollParents.add(cur);
568
+ cur.addEventListener("scroll", schedule, { passive: true, signal });
569
+ }
570
+ cur = getParentCrossingShadow(cur);
571
+ }
572
+ }
573
+ window.addEventListener("scroll", schedule, { passive: true, signal });
574
+ window.addEventListener("resize", schedule, { passive: true, signal });
575
+ if (window.visualViewport) {
576
+ window.visualViewport.addEventListener("scroll", schedule, { passive: true, signal });
577
+ window.visualViewport.addEventListener("resize", schedule, { passive: true, signal });
578
+ }
579
+ this.floating.addEventListener(
580
+ "beforetoggle",
581
+ (ev) => {
582
+ if (ev.newState === "open") {
583
+ schedule();
584
+ queueMicrotask(() => {
585
+ if (!this.isDestroyed && isTopLayerElement(this.floating)) {
586
+ this.update();
587
+ }
588
+ });
589
+ }
590
+ },
591
+ { signal }
592
+ );
593
+ return this;
594
+ }
595
+ stop() {
596
+ this.isRunning = false;
597
+ if (this.rafId !== null && typeof window !== "undefined") {
598
+ window.cancelAnimationFrame(this.rafId);
599
+ this.rafId = null;
600
+ }
601
+ this.abortController?.abort();
602
+ this.abortController = null;
603
+ this.resizeObserver?.disconnect();
604
+ this.resizeObserver = null;
605
+ return this;
606
+ }
607
+ audit() {
608
+ const warnings = [];
609
+ const floatRole = this.floating.getAttribute("role");
610
+ if (floatRole === "tooltip") {
611
+ const hasDesc = this.checkAriaIdReferences(this.reference, "aria-describedby", warnings, true);
612
+ if (!hasDesc) {
613
+ warnings.push('\xC9l\xE9ment role="tooltip" sans liaison aria-describedby valide sur la r\xE9f\xE9rence (WCAG 4.1.2).');
614
+ }
615
+ } else if (this.reference.hasAttribute("aria-describedby")) {
616
+ this.checkAriaIdReferences(this.reference, "aria-describedby", warnings, true);
617
+ }
618
+ if (this.reference.hasAttribute("aria-controls")) {
619
+ this.checkAriaIdReferences(this.reference, "aria-controls", warnings, false);
620
+ }
621
+ const hasPopup = this.reference.getAttribute("aria-haspopup");
622
+ if (hasPopup && ROLE_BY_HASPOPUP[hasPopup] && floatRole !== ROLE_BY_HASPOPUP[hasPopup]) {
623
+ warnings.push(
624
+ `Attribut aria-haspopup="${hasPopup}" sur la r\xE9f\xE9rence sans role="${ROLE_BY_HASPOPUP[hasPopup]}" correspondant sur le panneau.`
625
+ );
626
+ }
627
+ return warnings;
628
+ }
629
+ getAuditPrefix() {
630
+ return "Wulf.Anchor";
631
+ }
632
+ getAuditTargetLabel() {
633
+ return this.floating.id ? `#${this.floating.id}` : `<${this.floating.tagName.toLowerCase()}>`;
634
+ }
635
+ destroy() {
636
+ if (this.isDestroyed) return;
637
+ this.isDestroyed = true;
638
+ this.stop();
639
+ this.restoreNativeStyles();
640
+ const fStyle = this.floating.style;
641
+ fStyle.position = this.savedFloatingStyles.position;
642
+ fStyle.left = this.savedFloatingStyles.left;
643
+ fStyle.top = this.savedFloatingStyles.top;
644
+ this.floating.style.removeProperty("--wulf-anchor-x");
645
+ this.floating.style.removeProperty("--wulf-anchor-y");
646
+ if (this.savedPlacementAttr === null) {
647
+ this.floating.removeAttribute("data-anchor-placement");
648
+ } else {
649
+ this.floating.setAttribute("data-anchor-placement", this.savedPlacementAttr);
650
+ }
651
+ if (this.options.arrow && this.savedArrowStyles) {
652
+ this.options.arrow.style.left = this.savedArrowStyles.left;
653
+ this.options.arrow.style.top = this.savedArrowStyles.top;
654
+ this.options.arrow.style.removeProperty("--wulf-anchor-arrow-x");
655
+ this.options.arrow.style.removeProperty("--wulf-anchor-arrow-y");
656
+ }
657
+ }
658
+ restoreNativeStyles() {
659
+ const rStyle = this.reference.style;
660
+ rStyle.anchorName = this.savedRefAnchorName;
661
+ const fStyle = this.floating.style;
662
+ fStyle.inset = this.savedFloatingStyles.inset;
663
+ fStyle.margin = this.savedFloatingStyles.margin;
664
+ fStyle.positionAnchor = this.savedFloatingStyles.positionAnchor;
665
+ fStyle.positionArea = this.savedFloatingStyles.positionArea;
666
+ fStyle.positionTryFallbacks = this.savedFloatingStyles.positionTryFallbacks;
667
+ this.nativeApplied = false;
668
+ }
669
+ saveInitialState() {
670
+ const rStyle = this.reference.style;
671
+ this.savedRefAnchorName = rStyle.anchorName ?? "";
672
+ const fStyle = this.floating.style;
673
+ this.savedFloatingStyles = {
674
+ position: fStyle.position,
675
+ left: fStyle.left,
676
+ top: fStyle.top,
677
+ inset: fStyle.inset,
678
+ margin: fStyle.margin,
679
+ positionAnchor: fStyle.positionAnchor ?? "",
680
+ positionArea: fStyle.positionArea ?? "",
681
+ positionTryFallbacks: fStyle.positionTryFallbacks ?? ""
682
+ };
683
+ this.savedPlacementAttr = this.floating.getAttribute("data-anchor-placement");
684
+ if (this.options.arrow) {
685
+ this.savedArrowStyles = {
686
+ left: this.options.arrow.style.left,
687
+ top: this.options.arrow.style.top
688
+ };
689
+ }
690
+ }
691
+ };
692
+ return __toCommonJS(index_exports);
693
+ })();
694
+ 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.Anchor) __set(__w, "Anchor", Object.assign(__e.Anchor, { Anchor: __e.Anchor, default: __e.Anchor })); }}
695
+ //# sourceMappingURL=anchor.global.js.map