@radix-ng/primitives 1.0.0-beta.3 → 1.0.0-beta.4

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 (97) hide show
  1. package/README.md +1 -1
  2. package/fesm2022/radix-ng-primitives-accordion.mjs +5 -3
  3. package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
  4. package/fesm2022/radix-ng-primitives-alert-dialog.mjs +3 -2
  5. package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
  6. package/fesm2022/radix-ng-primitives-autocomplete.mjs +617 -659
  7. package/fesm2022/radix-ng-primitives-autocomplete.mjs.map +1 -1
  8. package/fesm2022/radix-ng-primitives-calendar.mjs +5 -3
  9. package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
  10. package/fesm2022/radix-ng-primitives-combobox.mjs +1305 -572
  11. package/fesm2022/radix-ng-primitives-combobox.mjs.map +1 -1
  12. package/fesm2022/radix-ng-primitives-config.mjs +13 -4
  13. package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
  14. package/fesm2022/radix-ng-primitives-context-menu.mjs +51 -10
  15. package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
  16. package/fesm2022/radix-ng-primitives-core.mjs +1345 -64
  17. package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
  18. package/fesm2022/radix-ng-primitives-date-field.mjs +5 -3
  19. package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
  20. package/fesm2022/radix-ng-primitives-dialog.mjs +240 -112
  21. package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
  22. package/fesm2022/radix-ng-primitives-direction-provider.mjs +70 -0
  23. package/fesm2022/radix-ng-primitives-direction-provider.mjs.map +1 -0
  24. package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +519 -184
  25. package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
  26. package/fesm2022/radix-ng-primitives-drawer.mjs +3 -3
  27. package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -1
  28. package/fesm2022/radix-ng-primitives-field.mjs +3 -2
  29. package/fesm2022/radix-ng-primitives-field.mjs.map +1 -1
  30. package/fesm2022/radix-ng-primitives-floating-focus-manager.mjs +517 -0
  31. package/fesm2022/radix-ng-primitives-floating-focus-manager.mjs.map +1 -0
  32. package/fesm2022/radix-ng-primitives-focus-scope.mjs +296 -70
  33. package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
  34. package/fesm2022/radix-ng-primitives-menu.mjs +861 -286
  35. package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
  36. package/fesm2022/radix-ng-primitives-menubar.mjs +32 -4
  37. package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
  38. package/fesm2022/radix-ng-primitives-navigation-menu.mjs +144 -159
  39. package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
  40. package/fesm2022/radix-ng-primitives-popover.mjs +220 -205
  41. package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
  42. package/fesm2022/radix-ng-primitives-popper.mjs +94 -51
  43. package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
  44. package/fesm2022/radix-ng-primitives-presence.mjs +1 -1
  45. package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
  46. package/fesm2022/radix-ng-primitives-preview-card.mjs +141 -173
  47. package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -1
  48. package/fesm2022/radix-ng-primitives-roving-focus.mjs +4 -2
  49. package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
  50. package/fesm2022/radix-ng-primitives-scroll-area.mjs +5 -4
  51. package/fesm2022/radix-ng-primitives-scroll-area.mjs.map +1 -1
  52. package/fesm2022/radix-ng-primitives-select.mjs +211 -156
  53. package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
  54. package/fesm2022/radix-ng-primitives-slider.mjs +5 -3
  55. package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
  56. package/fesm2022/radix-ng-primitives-stepper.mjs +5 -3
  57. package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
  58. package/fesm2022/radix-ng-primitives-time-field.mjs +5 -3
  59. package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
  60. package/fesm2022/radix-ng-primitives-toast.mjs +15 -36
  61. package/fesm2022/radix-ng-primitives-toast.mjs.map +1 -1
  62. package/fesm2022/radix-ng-primitives-toggle-group.mjs +5 -3
  63. package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
  64. package/fesm2022/radix-ng-primitives-toolbar.mjs +5 -3
  65. package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
  66. package/fesm2022/radix-ng-primitives-tooltip.mjs +73 -110
  67. package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
  68. package/package.json +10 -1
  69. package/types/radix-ng-primitives-accordion.d.ts +4 -3
  70. package/types/radix-ng-primitives-autocomplete.d.ts +217 -152
  71. package/types/radix-ng-primitives-calendar.d.ts +5 -3
  72. package/types/radix-ng-primitives-combobox.d.ts +672 -283
  73. package/types/radix-ng-primitives-config.d.ts +1 -1
  74. package/types/radix-ng-primitives-context-menu.d.ts +15 -5
  75. package/types/radix-ng-primitives-core.d.ts +762 -14
  76. package/types/radix-ng-primitives-date-field.d.ts +3 -2
  77. package/types/radix-ng-primitives-dialog.d.ts +77 -32
  78. package/types/radix-ng-primitives-direction-provider.d.ts +41 -0
  79. package/types/radix-ng-primitives-dismissable-layer.d.ts +147 -99
  80. package/types/radix-ng-primitives-field.d.ts +1 -0
  81. package/types/radix-ng-primitives-floating-focus-manager.d.ts +175 -0
  82. package/types/radix-ng-primitives-focus-scope.d.ts +132 -1
  83. package/types/radix-ng-primitives-menu.d.ts +186 -103
  84. package/types/radix-ng-primitives-navigation-menu.d.ts +37 -75
  85. package/types/radix-ng-primitives-popover.d.ts +59 -92
  86. package/types/radix-ng-primitives-popper.d.ts +39 -9
  87. package/types/radix-ng-primitives-preview-card.d.ts +39 -72
  88. package/types/radix-ng-primitives-roving-focus.d.ts +7 -6
  89. package/types/radix-ng-primitives-scroll-area.d.ts +2 -2
  90. package/types/radix-ng-primitives-select.d.ts +145 -108
  91. package/types/radix-ng-primitives-slider.d.ts +5 -4
  92. package/types/radix-ng-primitives-stepper.d.ts +4 -3
  93. package/types/radix-ng-primitives-time-field.d.ts +3 -2
  94. package/types/radix-ng-primitives-toast.d.ts +7 -7
  95. package/types/radix-ng-primitives-toggle-group.d.ts +5 -4
  96. package/types/radix-ng-primitives-toolbar.d.ts +3 -2
  97. package/types/radix-ng-primitives-tooltip.d.ts +24 -67
@@ -0,0 +1,517 @@
1
+ import { isPlatformBrowser } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, booleanAttribute, signal, input, output, inject, computed, ElementRef, PLATFORM_ID, effect, DestroyRef, Directive } from '@angular/core';
4
+ import { RDX_FLOATING_ROOT_CONTEXT, RDX_FLOATING_REGISTRATION } from '@radix-ng/primitives/core';
5
+ import * as i1 from '@radix-ng/primitives/focus-scope';
6
+ import { provideRdxFocusScopeConfig, RdxFocusScopeConfigToken, RdxFocusScope, FOCUS_GUARD_ATTR, composedContains } from '@radix-ng/primitives/focus-scope';
7
+
8
+ /** The neutral "outside the active floating layer" marker (Base UI `data-base-ui-inert`). */
9
+ const RDX_FLOATING_MARKER = 'data-rdx-floating-inert';
10
+ /** Per-element, per-attribute ref-counts. Keyed by element, so they are naturally per-`Document`. */
11
+ const controlCounters = {
12
+ inert: new WeakMap(),
13
+ 'aria-hidden': new WeakMap()
14
+ };
15
+ /** Elements that already carried the control attribute before we touched them — left in place on undo. */
16
+ const preExistingControlled = {
17
+ inert: new WeakSet(),
18
+ 'aria-hidden': new WeakSet()
19
+ };
20
+ let markerCounters = new WeakMap();
21
+ let lockCount = 0;
22
+ function unwrapHost(node) {
23
+ if (!node) {
24
+ return null;
25
+ }
26
+ return node instanceof ShadowRoot ? node.host : unwrapHost(node.parentNode);
27
+ }
28
+ /** Maps each target to the element actually inside `parent` (piercing shadow hosts), dropping the rest. */
29
+ function correctElements(parent, targets) {
30
+ return targets
31
+ .map((target) => {
32
+ if (parent.contains(target)) {
33
+ return target;
34
+ }
35
+ const host = unwrapHost(target);
36
+ return host && parent.contains(host) ? host : null;
37
+ })
38
+ .filter((element) => element != null);
39
+ }
40
+ /** The set of nodes on the path from each target up to the root — the "keep" subtree. */
41
+ function buildKeepSet(targets) {
42
+ const keep = new Set();
43
+ targets.forEach((target) => {
44
+ let node = target;
45
+ while (node && !keep.has(node)) {
46
+ keep.add(node);
47
+ node = node.parentNode;
48
+ }
49
+ });
50
+ return keep;
51
+ }
52
+ /** Collects every element outside the kept subtree (a sibling of the kept ancestor chain). */
53
+ function collectOutsideElements(root, keep, stop) {
54
+ const outside = [];
55
+ const walk = (parent) => {
56
+ if (!parent || stop.has(parent)) {
57
+ return;
58
+ }
59
+ Array.from(parent.children).forEach((node) => {
60
+ if (node.nodeName.toLowerCase() === 'script') {
61
+ return;
62
+ }
63
+ if (keep.has(node)) {
64
+ walk(node);
65
+ }
66
+ else {
67
+ outside.push(node);
68
+ }
69
+ });
70
+ };
71
+ walk(root);
72
+ return outside;
73
+ }
74
+ function markOthers(avoidElements, options = {}) {
75
+ const { ariaHidden = false, inert = false, mark = true } = options;
76
+ const first = avoidElements[0];
77
+ if (!first) {
78
+ return () => { };
79
+ }
80
+ const body = first.ownerDocument.body;
81
+ const avoid = correctElements(body, avoidElements);
82
+ // `inert` wins over `aria-hidden` (it already removes the subtree from the a11y tree, Base UI).
83
+ const controlAttribute = inert ? 'inert' : ariaHidden ? 'aria-hidden' : null;
84
+ const controlledElements = [];
85
+ const markedElements = [];
86
+ if (controlAttribute) {
87
+ const counters = controlCounters[controlAttribute];
88
+ const preExisting = preExistingControlled[controlAttribute];
89
+ // `aria-live` regions stay announceable, so keep them out of the controlled set too.
90
+ const live = correctElements(body, Array.from(body.querySelectorAll('[aria-live]')));
91
+ const controlElements = avoid.concat(live);
92
+ const targets = collectOutsideElements(body, buildKeepSet(controlElements), new Set(controlElements));
93
+ targets.forEach((node) => {
94
+ const attr = node.getAttribute(controlAttribute);
95
+ const already = attr !== null && attr !== 'false';
96
+ const count = (counters.get(node) ?? 0) + 1;
97
+ counters.set(node, count);
98
+ controlledElements.push(node);
99
+ if (count === 1 && already) {
100
+ preExisting.add(node);
101
+ }
102
+ if (!already) {
103
+ node.setAttribute(controlAttribute, controlAttribute === 'inert' ? '' : 'true');
104
+ }
105
+ });
106
+ }
107
+ if (mark) {
108
+ const targets = collectOutsideElements(body, buildKeepSet(avoid), new Set(avoid));
109
+ targets.forEach((node) => {
110
+ const count = (markerCounters.get(node) ?? 0) + 1;
111
+ markerCounters.set(node, count);
112
+ markedElements.push(node);
113
+ if (count === 1) {
114
+ node.setAttribute(RDX_FLOATING_MARKER, '');
115
+ }
116
+ });
117
+ }
118
+ lockCount += 1;
119
+ return () => {
120
+ if (controlAttribute) {
121
+ const counters = controlCounters[controlAttribute];
122
+ const preExisting = preExistingControlled[controlAttribute];
123
+ controlledElements.forEach((element) => {
124
+ const count = (counters.get(element) ?? 0) - 1;
125
+ counters.set(element, count);
126
+ if (count === 0) {
127
+ if (!preExisting.has(element)) {
128
+ element.removeAttribute(controlAttribute);
129
+ }
130
+ preExisting.delete(element);
131
+ }
132
+ });
133
+ }
134
+ markedElements.forEach((element) => {
135
+ const count = (markerCounters.get(element) ?? 0) - 1;
136
+ markerCounters.set(element, count);
137
+ if (count === 0) {
138
+ element.removeAttribute(RDX_FLOATING_MARKER);
139
+ }
140
+ });
141
+ lockCount -= 1;
142
+ if (lockCount === 0) {
143
+ // No active locks anywhere — drop the ref-count tables so detached elements can be GC'd.
144
+ controlCounters.inert = new WeakMap();
145
+ controlCounters['aria-hidden'] = new WeakMap();
146
+ preExistingControlled.inert = new WeakSet();
147
+ preExistingControlled['aria-hidden'] = new WeakSet();
148
+ markerCounters = new WeakMap();
149
+ }
150
+ };
151
+ }
152
+
153
+ /** Normalizes a DOM event into Base UI-like interaction intent for focus policy decisions. */
154
+ function getInteractionTypeFromEvent(event) {
155
+ if (!event) {
156
+ return null;
157
+ }
158
+ if (typeof KeyboardEvent !== 'undefined' && event instanceof KeyboardEvent) {
159
+ return 'keyboard';
160
+ }
161
+ if ('pointerType' in event && typeof event.pointerType === 'string') {
162
+ return (event.pointerType || 'mouse');
163
+ }
164
+ if (typeof MouseEvent !== 'undefined' && event instanceof MouseEvent) {
165
+ return event.detail === 0 ? 'keyboard' : 'mouse';
166
+ }
167
+ return '';
168
+ }
169
+ /** Resolves an {@link RdxFocusTarget} (element | getter | null) to a concrete element. */
170
+ function resolveFocusTarget(target) {
171
+ return typeof target === 'function' ? target() : target;
172
+ }
173
+ /**
174
+ * Resolves an {@link RdxInitialFocus} policy against how the popup opened.
175
+ */
176
+ function resolveInitialFocus(policy, openInteractionType) {
177
+ const resolved = typeof policy === 'function' ? policy(openInteractionType) : policy;
178
+ return resolved === false ? false : resolveFocusTarget(resolved);
179
+ }
180
+ /**
181
+ * Resolves an {@link RdxReturnFocus} policy against how the popup closed. `false` = do not return focus;
182
+ * `true` = the default (return to the previously-focused element); an element = return there.
183
+ */
184
+ function resolveReturnFocus(policy, closeInteractionType) {
185
+ const resolved = typeof policy === 'function' ? policy(closeInteractionType) : policy;
186
+ return typeof resolved === 'boolean' ? resolved : resolveFocusTarget(resolved);
187
+ }
188
+ const RDX_FLOATING_FOCUS_MANAGER_CONFIG = new InjectionToken('RdxFloatingFocusManagerConfig');
189
+ /** Provides a {@link RdxFloatingFocusManagerConfig} for an enclosing primitive's focus manager. */
190
+ function provideFloatingFocusManagerConfig(factory) {
191
+ return { provide: RDX_FLOATING_FOCUS_MANAGER_CONFIG, useFactory: factory };
192
+ }
193
+ /** Coerces a boolean-ish input while preserving `undefined` ("not set" → fall back to the config). */
194
+ function coerceOptionalBoolean(value) {
195
+ return value === undefined ? undefined : booleanAttribute(value);
196
+ }
197
+ /**
198
+ * Provides a {@link RdxFocusScopeConfig} whose `trapped` is a **writable** signal, so the enclosing
199
+ * {@link RdxFloatingFocusManager} can drive it from its `modal`/`enabled` policy after construction. The
200
+ * factory has **no** dependency on the manager instance, so it cannot deadlock the host-directive
201
+ * construction order (the manager later injects this same config and writes the signal).
202
+ */
203
+ function provideManagedFocusScopeConfig() {
204
+ return provideRdxFocusScopeConfig(() => ({ trapped: signal(false) }));
205
+ }
206
+ /**
207
+ * `RdxFloatingFocusManager` (ADR 0017 Phase 1b skeleton) — the Angular counterpart of Base UI's
208
+ * `FloatingFocusManager`. It is a **coordinator** that composes three low-level focus parts (it never
209
+ * inherits them, which would re-fuse trap + popup policy): the **reworked {@link RdxFocusScope}** (the
210
+ * trap, via `hostDirectives`), the portal-focus bridge, and owner-`Document` guards. Per ADR 0017 §1/§2
211
+ * its policies are **independent**, none derived from `modal`.
212
+ *
213
+ * **This skeleton wires the composition + lifecycle gates:**
214
+ * - `enabled` — the manager's active-ness (`mounted && !hover-open`). When off, **no trap** (and, later,
215
+ * no aria-hidden / no marker — Phase 2).
216
+ * - `modal` → `RdxFocusScope.trapped`: the effective trap is `enabled() && modal()`, pushed into the
217
+ * composed focus scope through its config token (the composition seam).
218
+ * - `loop` is forwarded to `RdxFocusScope`.
219
+ * - `initialFocus` / `returnFocus` are **orchestrated** here (the §2 policy contract, incl. the
220
+ * interaction-type callback forms): `initialFocus` via the scope's `mountAutoFocus` hook, `returnFocus`
221
+ * via the scope's `returnFocus` config seam (resolved at the scope's queued post-unmount frame). The
222
+ * portal-focus bridge remains a later-phase dependency.
223
+ */
224
+ class RdxFloatingFocusManager {
225
+ constructor() {
226
+ /** Manager active-ness (ADR 0017 §2): the popup is mounted **and** not hover-opened. */
227
+ this.enabled = input(undefined, { ...(ngDevMode ? { debugName: "enabled" } : /* istanbul ignore next */ {}), transform: coerceOptionalBoolean });
228
+ /** Modal popup → focus trap. Combined with `enabled` to drive the composed `RdxFocusScope`. */
229
+ this.modal = input(undefined, { ...(ngDevMode ? { debugName: "modal" } : /* istanbul ignore next */ {}), transform: coerceOptionalBoolean });
230
+ /**
231
+ * Whether outside elements receive the real `inert` attribute. Defaults to the effective `modal` value,
232
+ * but primitives can split focus trapping from pointer/AT isolation (Base UI `modal="trap-focus"`).
233
+ */
234
+ this.inert = input(undefined, { ...(ngDevMode ? { debugName: "inert" } : /* istanbul ignore next */ {}), transform: coerceOptionalBoolean });
235
+ /** Where focus goes when the popup opens (ADR 0017 §2). */
236
+ this.initialFocus = input(undefined, ...(ngDevMode ? [{ debugName: "initialFocus" }] : /* istanbul ignore next */ []));
237
+ /** Where focus returns when the popup closes (ADR 0017 §2). */
238
+ this.returnFocus = input(undefined, ...(ngDevMode ? [{ debugName: "returnFocus" }] : /* istanbul ignore next */ []));
239
+ /**
240
+ * Whether a **non-modal** popup closes when focus leaves to an unrelated node (Base UI
241
+ * `closeOnFocusOut`, default `true`; Dialog sets it to `!disablePointerDismissal`). Modal popups
242
+ * never close on focus-out (the trap keeps focus in).
243
+ */
244
+ this.closeOnFocusOut = input(undefined, { ...(ngDevMode ? { debugName: "closeOnFocusOut" } : /* istanbul ignore next */ {}), transform: coerceOptionalBoolean });
245
+ /**
246
+ * Emitted when focus leaves a non-modal popup to a node **unrelated** to the floating tree (ADR 0017
247
+ * §3) — the consumer should close the popup. This is the focus-manager's focus-out close (it reads
248
+ * the shared tree), replacing the dismissal capability's focus-out at the ADR 0015 Phase-4 cutover.
249
+ */
250
+ this.focusOut = output();
251
+ /** Optional DI config a composing primitive provides to drive the gates (input wins over config). */
252
+ this.config = inject(RDX_FLOATING_FOCUS_MANAGER_CONFIG, { optional: true });
253
+ /** Effective gates: `input ?? config ?? default`. */
254
+ this.effectiveEnabled = computed(() => this.enabled() ?? this.config?.enabled?.() ?? true, ...(ngDevMode ? [{ debugName: "effectiveEnabled" }] : /* istanbul ignore next */ []));
255
+ this.effectiveModal = computed(() => this.modal() ?? this.config?.modal?.() ?? false, ...(ngDevMode ? [{ debugName: "effectiveModal" }] : /* istanbul ignore next */ []));
256
+ this.effectiveInert = computed(() => this.inert() ?? this.config?.inert?.() ?? this.effectiveModal(), ...(ngDevMode ? [{ debugName: "effectiveInert" }] : /* istanbul ignore next */ []));
257
+ this.effectiveCloseOnFocusOut = computed(() => this.closeOnFocusOut() ?? this.config?.closeOnFocusOut?.() ?? true, ...(ngDevMode ? [{ debugName: "effectiveCloseOnFocusOut" }] : /* istanbul ignore next */ []));
258
+ this.effectiveInitialFocus = computed(() => this.initialFocus() !== undefined ? this.initialFocus() : (this.config?.initialFocus?.() ?? null), ...(ngDevMode ? [{ debugName: "effectiveInitialFocus" }] : /* istanbul ignore next */ []));
259
+ this.effectiveReturnFocus = computed(() => this.returnFocus() !== undefined ? this.returnFocus() : (this.config?.returnFocus?.() ?? true), ...(ngDevMode ? [{ debugName: "effectiveReturnFocus" }] : /* istanbul ignore next */ []));
260
+ this.effectiveOpenInteractionType = computed(() => this.config?.openInteractionType?.() ?? this._interactionType(), ...(ngDevMode ? [{ debugName: "effectiveOpenInteractionType" }] : /* istanbul ignore next */ []));
261
+ this.effectiveCloseInteractionType = computed(() => this.config?.closeInteractionType?.() ?? this._interactionType(), ...(ngDevMode ? [{ debugName: "effectiveCloseInteractionType" }] : /* istanbul ignore next */ []));
262
+ /** The effective trap state the composed `RdxFocusScope` reads via its config token. */
263
+ this.trapped = computed(() => this.effectiveEnabled() && this.effectiveModal(), ...(ngDevMode ? [{ debugName: "trapped" }] : /* istanbul ignore next */ []));
264
+ // The config this directive provides — its `trapped` signal is writable so we can drive it, and we
265
+ // attach a `returnFocus` resolver the composed focus scope calls at unmount (ADR 0017 `returnFocus`).
266
+ this.focusScopeConfig = inject(RdxFocusScopeConfigToken);
267
+ this.host = inject(ElementRef).nativeElement;
268
+ this.isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
269
+ /** The shared per-popup context (open / triggers / elements), if a primitive root provides one. */
270
+ this.rootContext = inject(RDX_FLOATING_ROOT_CONTEXT, { optional: true });
271
+ /** The registration handle for this node, used to read the shared tree (ancestors / descendants). */
272
+ this.registration = inject(RDX_FLOATING_REGISTRATION, { optional: true });
273
+ this._interactionType = signal('', ...(ngDevMode ? [{ debugName: "_interactionType" }] : /* istanbul ignore next */ []));
274
+ /** How the popup was most recently interacted with — fed to the initial/return focus policy callbacks. */
275
+ this.interactionType = this._interactionType.asReadonly();
276
+ effect(() => this.focusScopeConfig.trapped.set(this.trapped()));
277
+ // Own the return-focus *target* (the composed focus scope owns the *timing*): the scope calls this
278
+ // in its queued post-unmount frame, resolving the `returnFocus` policy against the close interaction.
279
+ this.focusScopeConfig.returnFocus = () => this.resolveReturnFocusTarget();
280
+ if (!this.isBrowser) {
281
+ return; // SSR: no DOM marking / listeners.
282
+ }
283
+ // Marker pass (ADR 0017 §3) — applied to outside elements while the manager is active **and the
284
+ // popup is open**, independent of `modal`. Read by ADR 0015's outside-press guard.
285
+ effect((onCleanup) => {
286
+ if (!this.effectiveEnabled() || !this.isFloatingOpen()) {
287
+ return;
288
+ }
289
+ onCleanup(markOthers(this.avoidElements(), { ariaHidden: false, mark: true }));
290
+ });
291
+ // Pointer/AT isolation pass — apply the real `inert` attribute to outside elements only when the
292
+ // composing primitive asks for outside interaction to be blocked. This is intentionally separate from
293
+ // focus trapping: Base UI `modal="trap-focus"` traps focus but leaves outside pointer interaction
294
+ // enabled.
295
+ effect((onCleanup) => {
296
+ if (!this.effectiveEnabled() || !this.isFloatingOpen() || !this.effectiveInert()) {
297
+ return;
298
+ }
299
+ onCleanup(markOthers(this.avoidElements(), { inert: true, mark: false }));
300
+ });
301
+ this.trackInteractionType();
302
+ this.wireCloseOnFocusOut();
303
+ this.wireFocusOrchestration();
304
+ this.wireInitialFocusFallback();
305
+ }
306
+ /** Records the most recent open/close interaction (pointer type or keyboard) for the focus policies. */
307
+ trackInteractionType() {
308
+ const ownerDocument = this.host.ownerDocument;
309
+ const onPointer = (event) => {
310
+ this._interactionType.set((event.pointerType || 'mouse'));
311
+ };
312
+ const onKey = () => this._interactionType.set('keyboard');
313
+ ownerDocument.addEventListener('pointerdown', onPointer, true);
314
+ ownerDocument.addEventListener('keydown', onKey, true);
315
+ inject(DestroyRef).onDestroy(() => {
316
+ ownerDocument.removeEventListener('pointerdown', onPointer, true);
317
+ ownerDocument.removeEventListener('keydown', onKey, true);
318
+ });
319
+ }
320
+ /**
321
+ * Initial-focus orchestration (ADR 0017 §2). The manager owns the focus *policy*; it intercepts the
322
+ * composed {@link RdxFocusScope}'s preventable `mountAutoFocus` (its designed extension point) and
323
+ * applies the `initialFocus` policy, falling back to the scope's first-tabbable default when the
324
+ * policy is `null`. (`returnFocus` is orchestrated separately via the config seam — see
325
+ * {@link resolveReturnFocusTarget} — because it must run during the scope's queued *post-unmount* frame.)
326
+ */
327
+ wireFocusOrchestration() {
328
+ const focusScope = inject(RdxFocusScope);
329
+ focusScope.mountAutoFocus.subscribe((event) => {
330
+ const interactionType = this.effectiveOpenInteractionType();
331
+ const target = resolveInitialFocus(this.effectiveInitialFocus(), interactionType) ??
332
+ this.defaultInitialFocus(interactionType);
333
+ if (target === false) {
334
+ event.preventDefault();
335
+ return;
336
+ }
337
+ if (target) {
338
+ event.preventDefault(); // override the scope's first-tabbable default
339
+ target.focus();
340
+ }
341
+ });
342
+ }
343
+ /**
344
+ * Resolves the {@link returnFocus} policy against the **close** interaction type for the composed
345
+ * focus scope to apply at unmount (ADR 0017 §2). Mirrors Base UI's `getReturnElement`:
346
+ * - `false` → `false` (the scope suppresses return-focus);
347
+ * - `true` / `null` → `undefined` (the scope's default — return to the element focused before mount);
348
+ * - an element (direct or from a callback) → that element (returned **explicitly**, bypassing the
349
+ * "focus moved elsewhere" guard).
350
+ */
351
+ resolveReturnFocusTarget() {
352
+ const resolved = resolveReturnFocus(this.effectiveReturnFocus(), this.effectiveCloseInteractionType());
353
+ if (resolved === false) {
354
+ return false;
355
+ }
356
+ if (resolved === true || resolved == null) {
357
+ return undefined;
358
+ }
359
+ return resolved;
360
+ }
361
+ /**
362
+ * Base UI's `defaultInitialFocus`: on a **touch** open, focus the popup itself instead of its first
363
+ * tabbable control, so a soft keyboard (Android) does not pop up over the popup. Any other interaction
364
+ * returns `null`, keeping the focus scope's first-tabbable default. The popup is made programmatically
365
+ * focusable (`tabindex="-1"`) if it isn't already.
366
+ */
367
+ defaultInitialFocus(interactionType) {
368
+ if (interactionType !== 'touch') {
369
+ return null;
370
+ }
371
+ const popup = (this.rootContext?.floatingElement ?? this.host);
372
+ if (!popup.hasAttribute('tabindex')) {
373
+ popup.setAttribute('tabindex', '-1');
374
+ }
375
+ return popup;
376
+ }
377
+ /**
378
+ * Manager-owned post-open fallback. Some popup types open from a trigger event that fired before the
379
+ * manager existed, and some policies resolve their final target only after a couple of renders. Re-run
380
+ * the initial-focus policy for a few animation frames while the popup is open so the target can settle.
381
+ */
382
+ wireInitialFocusFallback() {
383
+ effect(() => {
384
+ if (!this.effectiveEnabled() || !this.isFloatingOpen()) {
385
+ return;
386
+ }
387
+ this.scheduleInitialFocusFallback();
388
+ });
389
+ }
390
+ scheduleInitialFocusFallback(attempt = 0) {
391
+ const view = this.host.ownerDocument.defaultView ?? globalThis;
392
+ view.requestAnimationFrame(() => this.applyInitialFocusFallback(attempt));
393
+ }
394
+ applyInitialFocusFallback(attempt) {
395
+ if (!this.effectiveEnabled() || !this.isFloatingOpen()) {
396
+ return;
397
+ }
398
+ const popup = (this.rootContext?.floatingElement ?? this.host);
399
+ const activeElement = this.host.ownerDocument.activeElement;
400
+ if (activeElement instanceof HTMLElement && popup.contains(activeElement)) {
401
+ return;
402
+ }
403
+ const interactionType = this.effectiveOpenInteractionType();
404
+ const resolved = resolveInitialFocus(this.effectiveInitialFocus(), interactionType);
405
+ if (resolved === false) {
406
+ return;
407
+ }
408
+ const target = resolved ?? this.defaultInitialFocus(interactionType);
409
+ if (target && activeElement !== target) {
410
+ target.focus({ preventScroll: true });
411
+ }
412
+ if (attempt < 2) {
413
+ this.scheduleInitialFocusFallback(attempt + 1);
414
+ }
415
+ }
416
+ /**
417
+ * Close-on-focus-out (ADR 0017 §3): a **non-modal** active popup closes when focus moves to a node
418
+ * unrelated to the floating tree — not the popup, its trigger(s), a focus guard, or an ancestor /
419
+ * descendant popup — and not during a pointer press (a drag must not close it). Mirrors Base UI's
420
+ * `FloatingFocusManager` `!modal` branch (`movedToUnrelatedNode`).
421
+ */
422
+ wireCloseOnFocusOut() {
423
+ const ownerDocument = this.host.ownerDocument;
424
+ let pointerDown = false;
425
+ const onPointerDown = () => {
426
+ pointerDown = true;
427
+ };
428
+ const onPointerUp = () => {
429
+ pointerDown = false;
430
+ };
431
+ const onFocusOut = (event) => {
432
+ if (!this.effectiveEnabled() || !this.effectiveCloseOnFocusOut() || this.effectiveModal() || pointerDown) {
433
+ return;
434
+ }
435
+ const relatedTarget = event.relatedTarget;
436
+ if (!relatedTarget) {
437
+ return; // focus left to nothing (tab-away / window blur) — let the browser handle it
438
+ }
439
+ if (relatedTarget instanceof Element && relatedTarget.hasAttribute(FOCUS_GUARD_ATTR)) {
440
+ return; // moved onto a focus guard — still inside the focus system
441
+ }
442
+ if (this.isRelatedTargetInside(relatedTarget)) {
443
+ return; // moved to a related node (trigger / ancestor / descendant) — keep open
444
+ }
445
+ this.focusOut.emit(event);
446
+ };
447
+ ownerDocument.addEventListener('pointerdown', onPointerDown, true);
448
+ ownerDocument.addEventListener('pointerup', onPointerUp, true);
449
+ ownerDocument.addEventListener('focusout', onFocusOut, true);
450
+ inject(DestroyRef).onDestroy(() => {
451
+ ownerDocument.removeEventListener('pointerdown', onPointerDown, true);
452
+ ownerDocument.removeEventListener('pointerup', onPointerUp, true);
453
+ ownerDocument.removeEventListener('focusout', onFocusOut, true);
454
+ });
455
+ }
456
+ /**
457
+ * The marker keep-set is intentionally narrow: the popup/focus host only. Own sibling roots such as a
458
+ * user backdrop are DOM-footprint bookkeeping, not marker keep-set members.
459
+ */
460
+ avoidElements() {
461
+ return [this.host];
462
+ }
463
+ isFloatingOpen() {
464
+ return this.rootContext?.open() ?? true;
465
+ }
466
+ /** Whether `relatedTarget` is inside the popup, its trigger(s), or an ancestor / descendant popup. */
467
+ isRelatedTargetInside(relatedTarget) {
468
+ const floating = this.rootContext?.floatingElement ?? this.host;
469
+ if (composedContains(floating, relatedTarget)) {
470
+ return true;
471
+ }
472
+ if (this.rootContext && this.contextContains(this.rootContext, relatedTarget)) {
473
+ return true;
474
+ }
475
+ const node = this.registration?.node() ?? null;
476
+ if (node) {
477
+ for (const ancestor of node.tree.ancestors(node)) {
478
+ if (ancestor.context && this.contextContains(ancestor.context, relatedTarget)) {
479
+ return true;
480
+ }
481
+ }
482
+ for (const child of node.tree.children(node, { onlyOpen: true })) {
483
+ if (child.context && this.contextContains(child.context, relatedTarget)) {
484
+ return true;
485
+ }
486
+ }
487
+ }
488
+ return false;
489
+ }
490
+ contextContains(context, relatedTarget) {
491
+ if (context.floatingElement && composedContains(context.floatingElement, relatedTarget)) {
492
+ return true;
493
+ }
494
+ if (context.referenceElement && composedContains(context.referenceElement, relatedTarget)) {
495
+ return true;
496
+ }
497
+ return context.triggers.contains(relatedTarget);
498
+ }
499
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxFloatingFocusManager, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
500
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxFloatingFocusManager, isStandalone: true, selector: "[rdxFloatingFocusManager]", inputs: { enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null }, modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, inert: { classPropertyName: "inert", publicName: "inert", isSignal: true, isRequired: false, transformFunction: null }, initialFocus: { classPropertyName: "initialFocus", publicName: "initialFocus", isSignal: true, isRequired: false, transformFunction: null }, returnFocus: { classPropertyName: "returnFocus", publicName: "returnFocus", isSignal: true, isRequired: false, transformFunction: null }, closeOnFocusOut: { classPropertyName: "closeOnFocusOut", publicName: "closeOnFocusOut", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { focusOut: "focusOut" }, providers: [provideManagedFocusScopeConfig()], exportAs: ["rdxFloatingFocusManager"], hostDirectives: [{ directive: i1.RdxFocusScope, inputs: ["loop", "loop"] }], ngImport: i0 }); }
501
+ }
502
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxFloatingFocusManager, decorators: [{
503
+ type: Directive,
504
+ args: [{
505
+ selector: '[rdxFloatingFocusManager]',
506
+ exportAs: 'rdxFloatingFocusManager',
507
+ hostDirectives: [{ directive: RdxFocusScope, inputs: ['loop'] }],
508
+ providers: [provideManagedFocusScopeConfig()]
509
+ }]
510
+ }], ctorParameters: () => [], propDecorators: { enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "enabled", required: false }] }], modal: [{ type: i0.Input, args: [{ isSignal: true, alias: "modal", required: false }] }], inert: [{ type: i0.Input, args: [{ isSignal: true, alias: "inert", required: false }] }], initialFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialFocus", required: false }] }], returnFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "returnFocus", required: false }] }], closeOnFocusOut: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnFocusOut", required: false }] }], focusOut: [{ type: i0.Output, args: ["focusOut"] }] } });
511
+
512
+ /**
513
+ * Generated bundle index. Do not edit.
514
+ */
515
+
516
+ export { RDX_FLOATING_FOCUS_MANAGER_CONFIG, RDX_FLOATING_MARKER, RdxFloatingFocusManager, getInteractionTypeFromEvent, provideFloatingFocusManagerConfig, resolveFocusTarget, resolveInitialFocus, resolveReturnFocus };
517
+ //# sourceMappingURL=radix-ng-primitives-floating-focus-manager.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radix-ng-primitives-floating-focus-manager.mjs","sources":["../../../packages/primitives/floating-focus-manager/src/mark-others.ts","../../../packages/primitives/floating-focus-manager/src/floating-focus-manager.ts","../../../packages/primitives/floating-focus-manager/radix-ng-primitives-floating-focus-manager.ts"],"sourcesContent":["/**\n * `markOthers` — the Angular port of Base UI's `floating-ui-react/utils/markOthers` (ADR 0017 §3). It\n * isolates a popup from the rest of the page by walking the owner `Document`'s `<body>` and applying an\n * attribute to every element **outside** the kept (`avoidElements`) subtree — siblings of the popup's\n * ancestor chain — leaving the popup, its ancestors, and any `[aria-live]` region untouched.\n *\n * Two independent passes (Base UI makes two separate calls, never bundling them):\n * - **control attribute** — either `inert` (the real attribute: non-interactive **and** removed from the\n * a11y tree) or `aria-hidden=\"true\"` (AT-only). `inert` takes precedence and is what replaces the\n * global body pointer-lock for modal isolation (ADR 0017 §3 / finding #4): it blocks pointer + focus\n * on outside content **scoped** to siblings of the popup's ancestor chain, so independent overlays at a\n * higher layer are unaffected (unlike `body { pointer-events: none }`).\n * - **`mark`** — a neutral marker attribute ({@link RDX_FLOATING_MARKER}) applied whenever the focus\n * manager is active; read by ADR 0015's outside-press guard to detect third-party-injected subtrees.\n *\n * Per-**element**, per-**attribute** ref-counting (`WeakMap<Element, number>`) lets overlapping popups\n * compose: an element controlled by two popups is only cleared when both undo. An element that already\n * carried the control attribute before the call is recorded and left in place on undo.\n *\n * @returns an `Undo` that reverses exactly what this call applied.\n */\nexport type Undo = () => void;\n\nexport interface MarkOthersOptions {\n /** Apply `aria-hidden=\"true\"` to outside elements (AT-only isolation). Ignored when `inert` is set. */\n ariaHidden?: boolean;\n /**\n * Apply the real `inert` attribute to outside elements — non-interactive **and** a11y-hidden in one.\n * Takes precedence over `ariaHidden`; this is the scoped replacement for the body pointer-lock.\n */\n inert?: boolean;\n /** Apply the neutral {@link RDX_FLOATING_MARKER} to outside elements. Default `true`. */\n mark?: boolean;\n}\n\n/** The neutral \"outside the active floating layer\" marker (Base UI `data-base-ui-inert`). */\nexport const RDX_FLOATING_MARKER = 'data-rdx-floating-inert';\n\n/** The mutually-exclusive control attribute (Base UI: `inert` wins over `aria-hidden`). */\ntype ControlAttribute = 'inert' | 'aria-hidden';\n\n/** Per-element, per-attribute ref-counts. Keyed by element, so they are naturally per-`Document`. */\nconst controlCounters: Record<ControlAttribute, WeakMap<Element, number>> = {\n inert: new WeakMap(),\n 'aria-hidden': new WeakMap()\n};\n/** Elements that already carried the control attribute before we touched them — left in place on undo. */\nconst preExistingControlled: Record<ControlAttribute, WeakSet<Element>> = {\n inert: new WeakSet(),\n 'aria-hidden': new WeakSet()\n};\nlet markerCounters = new WeakMap<Element, number>();\nlet lockCount = 0;\n\nfunction unwrapHost(node: Node | null): Element | null {\n if (!node) {\n return null;\n }\n return node instanceof ShadowRoot ? node.host : unwrapHost(node.parentNode);\n}\n\n/** Maps each target to the element actually inside `parent` (piercing shadow hosts), dropping the rest. */\nfunction correctElements(parent: HTMLElement, targets: Element[]): Element[] {\n return targets\n .map((target) => {\n if (parent.contains(target)) {\n return target;\n }\n const host = unwrapHost(target);\n return host && parent.contains(host) ? host : null;\n })\n .filter((element): element is Element => element != null);\n}\n\n/** The set of nodes on the path from each target up to the root — the \"keep\" subtree. */\nfunction buildKeepSet(targets: Element[]): Set<Node> {\n const keep = new Set<Node>();\n targets.forEach((target) => {\n let node: Node | null = target;\n while (node && !keep.has(node)) {\n keep.add(node);\n node = node.parentNode;\n }\n });\n return keep;\n}\n\n/** Collects every element outside the kept subtree (a sibling of the kept ancestor chain). */\nfunction collectOutsideElements(root: HTMLElement, keep: Set<Node>, stop: Set<Node>): Element[] {\n const outside: Element[] = [];\n const walk = (parent: Element | null): void => {\n if (!parent || stop.has(parent)) {\n return;\n }\n Array.from(parent.children).forEach((node) => {\n if (node.nodeName.toLowerCase() === 'script') {\n return;\n }\n if (keep.has(node)) {\n walk(node);\n } else {\n outside.push(node);\n }\n });\n };\n walk(root);\n return outside;\n}\n\nexport function markOthers(avoidElements: Element[], options: MarkOthersOptions = {}): Undo {\n const { ariaHidden = false, inert = false, mark = true } = options;\n const first = avoidElements[0];\n if (!first) {\n return () => {};\n }\n const body = first.ownerDocument.body;\n const avoid = correctElements(body, avoidElements);\n\n // `inert` wins over `aria-hidden` (it already removes the subtree from the a11y tree, Base UI).\n const controlAttribute: ControlAttribute | null = inert ? 'inert' : ariaHidden ? 'aria-hidden' : null;\n const controlledElements: Element[] = [];\n const markedElements: Element[] = [];\n\n if (controlAttribute) {\n const counters = controlCounters[controlAttribute];\n const preExisting = preExistingControlled[controlAttribute];\n // `aria-live` regions stay announceable, so keep them out of the controlled set too.\n const live = correctElements(body, Array.from(body.querySelectorAll('[aria-live]')));\n const controlElements = avoid.concat(live);\n const targets = collectOutsideElements(body, buildKeepSet(controlElements), new Set<Node>(controlElements));\n\n targets.forEach((node) => {\n const attr = node.getAttribute(controlAttribute);\n const already = attr !== null && attr !== 'false';\n const count = (counters.get(node) ?? 0) + 1;\n counters.set(node, count);\n controlledElements.push(node);\n\n if (count === 1 && already) {\n preExisting.add(node);\n }\n if (!already) {\n node.setAttribute(controlAttribute, controlAttribute === 'inert' ? '' : 'true');\n }\n });\n }\n\n if (mark) {\n const targets = collectOutsideElements(body, buildKeepSet(avoid), new Set<Node>(avoid));\n targets.forEach((node) => {\n const count = (markerCounters.get(node) ?? 0) + 1;\n markerCounters.set(node, count);\n markedElements.push(node);\n if (count === 1) {\n node.setAttribute(RDX_FLOATING_MARKER, '');\n }\n });\n }\n\n lockCount += 1;\n\n return () => {\n if (controlAttribute) {\n const counters = controlCounters[controlAttribute];\n const preExisting = preExistingControlled[controlAttribute];\n controlledElements.forEach((element) => {\n const count = (counters.get(element) ?? 0) - 1;\n counters.set(element, count);\n if (count === 0) {\n if (!preExisting.has(element)) {\n element.removeAttribute(controlAttribute);\n }\n preExisting.delete(element);\n }\n });\n }\n\n markedElements.forEach((element) => {\n const count = (markerCounters.get(element) ?? 0) - 1;\n markerCounters.set(element, count);\n if (count === 0) {\n element.removeAttribute(RDX_FLOATING_MARKER);\n }\n });\n\n lockCount -= 1;\n if (lockCount === 0) {\n // No active locks anywhere — drop the ref-count tables so detached elements can be GC'd.\n controlCounters.inert = new WeakMap();\n controlCounters['aria-hidden'] = new WeakMap();\n preExistingControlled.inert = new WeakSet();\n preExistingControlled['aria-hidden'] = new WeakSet();\n markerCounters = new WeakMap();\n }\n };\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n booleanAttribute,\n computed,\n DestroyRef,\n Directive,\n effect,\n ElementRef,\n inject,\n InjectionToken,\n input,\n output,\n PLATFORM_ID,\n Provider,\n signal,\n WritableSignal\n} from '@angular/core';\nimport {\n BooleanInput,\n RDX_FLOATING_REGISTRATION,\n RDX_FLOATING_ROOT_CONTEXT,\n RdxFloatingRootContext\n} from '@radix-ng/primitives/core';\nimport {\n composedContains,\n FOCUS_GUARD_ATTR,\n provideRdxFocusScopeConfig,\n RdxFocusScope,\n RdxFocusScopeConfig,\n RdxFocusScopeConfigToken\n} from '@radix-ng/primitives/focus-scope';\nimport { markOthers } from './mark-others';\n\n/**\n * How a popup was opened / closed (Base UI `InteractionType`). `null` = a **programmatic** open (prefer\n * the previously-focused element); `''` = an **unknown** interaction. The two are deliberately distinct\n * (Base UI keys `preferPreviousFocus = openInteractionType == null` off exactly this).\n */\nexport type RdxInteractionType = 'mouse' | 'touch' | 'pen' | 'keyboard' | '' | null;\n\n/** A focus target: an element, a getter, or `null`. */\nexport type RdxFocusTarget = HTMLElement | (() => HTMLElement | null) | null;\n\n/** `initialFocus` policy (ADR 0017 §2) — a target, `false`, or an open-interaction callback. */\nexport type RdxInitialFocus =\n | RdxFocusTarget\n | false\n | ((openInteractionType: RdxInteractionType) => RdxFocusTarget | false);\n\n/** `returnFocus` policy (ADR 0017 §2) — a target/boolean or a callback receiving the **close** interaction type. */\nexport type RdxReturnFocus =\n | RdxFocusTarget\n | boolean\n | ((closeInteractionType: RdxInteractionType) => RdxFocusTarget | boolean);\n\n/** Normalizes a DOM event into Base UI-like interaction intent for focus policy decisions. */\nexport function getInteractionTypeFromEvent(event?: Event): RdxInteractionType {\n if (!event) {\n return null;\n }\n\n if (typeof KeyboardEvent !== 'undefined' && event instanceof KeyboardEvent) {\n return 'keyboard';\n }\n\n if ('pointerType' in event && typeof event.pointerType === 'string') {\n return (event.pointerType || 'mouse') as RdxInteractionType;\n }\n\n if (typeof MouseEvent !== 'undefined' && event instanceof MouseEvent) {\n return event.detail === 0 ? 'keyboard' : 'mouse';\n }\n\n return '';\n}\n\n/** Resolves an {@link RdxFocusTarget} (element | getter | null) to a concrete element. */\nexport function resolveFocusTarget(target: RdxFocusTarget): HTMLElement | null {\n return typeof target === 'function' ? target() : target;\n}\n\n/**\n * Resolves an {@link RdxInitialFocus} policy against how the popup opened.\n */\nexport function resolveInitialFocus(\n policy: RdxInitialFocus,\n openInteractionType: RdxInteractionType\n): HTMLElement | null | false {\n const resolved = typeof policy === 'function' ? policy(openInteractionType) : policy;\n return resolved === false ? false : resolveFocusTarget(resolved);\n}\n\n/**\n * Resolves an {@link RdxReturnFocus} policy against how the popup closed. `false` = do not return focus;\n * `true` = the default (return to the previously-focused element); an element = return there.\n */\nexport function resolveReturnFocus(\n policy: RdxReturnFocus,\n closeInteractionType: RdxInteractionType\n): HTMLElement | boolean | null {\n const resolved = typeof policy === 'function' ? policy(closeInteractionType) : policy;\n return typeof resolved === 'boolean' ? resolved : resolveFocusTarget(resolved);\n}\n\n/**\n * DI seam for a **composing primitive** (Dialog / Popover / Menu) to drive the manager's gates from its\n * own root context instead of template-bound inputs (which a primitive cannot set). Each field falls\n * back to the manager's input, then to the documented default. Mirrors {@link RdxFocusScopeConfig}.\n */\nexport interface RdxFloatingFocusManagerConfig {\n modal?: () => boolean;\n inert?: () => boolean;\n enabled?: () => boolean;\n closeOnFocusOut?: () => boolean;\n initialFocus?: () => RdxInitialFocus;\n returnFocus?: () => RdxReturnFocus;\n openInteractionType?: () => RdxInteractionType;\n closeInteractionType?: () => RdxInteractionType;\n}\n\nexport const RDX_FLOATING_FOCUS_MANAGER_CONFIG = new InjectionToken<RdxFloatingFocusManagerConfig>(\n 'RdxFloatingFocusManagerConfig'\n);\n\n/** Provides a {@link RdxFloatingFocusManagerConfig} for an enclosing primitive's focus manager. */\nexport function provideFloatingFocusManagerConfig(factory: () => RdxFloatingFocusManagerConfig): Provider {\n return { provide: RDX_FLOATING_FOCUS_MANAGER_CONFIG, useFactory: factory };\n}\n\n/** Coerces a boolean-ish input while preserving `undefined` (\"not set\" → fall back to the config). */\nfunction coerceOptionalBoolean(value: BooleanInput | undefined): boolean | undefined {\n return value === undefined ? undefined : booleanAttribute(value);\n}\n\n/**\n * Provides a {@link RdxFocusScopeConfig} whose `trapped` is a **writable** signal, so the enclosing\n * {@link RdxFloatingFocusManager} can drive it from its `modal`/`enabled` policy after construction. The\n * factory has **no** dependency on the manager instance, so it cannot deadlock the host-directive\n * construction order (the manager later injects this same config and writes the signal).\n */\nfunction provideManagedFocusScopeConfig(): Provider {\n return provideRdxFocusScopeConfig((): RdxFocusScopeConfig => ({ trapped: signal(false) }));\n}\n\n/**\n * `RdxFloatingFocusManager` (ADR 0017 Phase 1b skeleton) — the Angular counterpart of Base UI's\n * `FloatingFocusManager`. It is a **coordinator** that composes three low-level focus parts (it never\n * inherits them, which would re-fuse trap + popup policy): the **reworked {@link RdxFocusScope}** (the\n * trap, via `hostDirectives`), the portal-focus bridge, and owner-`Document` guards. Per ADR 0017 §1/§2\n * its policies are **independent**, none derived from `modal`.\n *\n * **This skeleton wires the composition + lifecycle gates:**\n * - `enabled` — the manager's active-ness (`mounted && !hover-open`). When off, **no trap** (and, later,\n * no aria-hidden / no marker — Phase 2).\n * - `modal` → `RdxFocusScope.trapped`: the effective trap is `enabled() && modal()`, pushed into the\n * composed focus scope through its config token (the composition seam).\n * - `loop` is forwarded to `RdxFocusScope`.\n * - `initialFocus` / `returnFocus` are **orchestrated** here (the §2 policy contract, incl. the\n * interaction-type callback forms): `initialFocus` via the scope's `mountAutoFocus` hook, `returnFocus`\n * via the scope's `returnFocus` config seam (resolved at the scope's queued post-unmount frame). The\n * portal-focus bridge remains a later-phase dependency.\n */\n@Directive({\n selector: '[rdxFloatingFocusManager]',\n exportAs: 'rdxFloatingFocusManager',\n hostDirectives: [{ directive: RdxFocusScope, inputs: ['loop'] }],\n providers: [provideManagedFocusScopeConfig()]\n})\nexport class RdxFloatingFocusManager {\n /** Manager active-ness (ADR 0017 §2): the popup is mounted **and** not hover-opened. */\n readonly enabled = input(undefined, { transform: coerceOptionalBoolean });\n\n /** Modal popup → focus trap. Combined with `enabled` to drive the composed `RdxFocusScope`. */\n readonly modal = input(undefined, { transform: coerceOptionalBoolean });\n\n /**\n * Whether outside elements receive the real `inert` attribute. Defaults to the effective `modal` value,\n * but primitives can split focus trapping from pointer/AT isolation (Base UI `modal=\"trap-focus\"`).\n */\n readonly inert = input(undefined, { transform: coerceOptionalBoolean });\n\n /** Where focus goes when the popup opens (ADR 0017 §2). */\n readonly initialFocus = input<RdxInitialFocus | undefined>(undefined);\n\n /** Where focus returns when the popup closes (ADR 0017 §2). */\n readonly returnFocus = input<RdxReturnFocus | undefined>(undefined);\n\n /**\n * Whether a **non-modal** popup closes when focus leaves to an unrelated node (Base UI\n * `closeOnFocusOut`, default `true`; Dialog sets it to `!disablePointerDismissal`). Modal popups\n * never close on focus-out (the trap keeps focus in).\n */\n readonly closeOnFocusOut = input(undefined, { transform: coerceOptionalBoolean });\n\n /**\n * Emitted when focus leaves a non-modal popup to a node **unrelated** to the floating tree (ADR 0017\n * §3) — the consumer should close the popup. This is the focus-manager's focus-out close (it reads\n * the shared tree), replacing the dismissal capability's focus-out at the ADR 0015 Phase-4 cutover.\n */\n readonly focusOut = output<FocusEvent>();\n\n /** Optional DI config a composing primitive provides to drive the gates (input wins over config). */\n private readonly config = inject(RDX_FLOATING_FOCUS_MANAGER_CONFIG, { optional: true });\n\n /** Effective gates: `input ?? config ?? default`. */\n readonly effectiveEnabled = computed(() => this.enabled() ?? this.config?.enabled?.() ?? true);\n readonly effectiveModal = computed(() => this.modal() ?? this.config?.modal?.() ?? false);\n readonly effectiveInert = computed(() => this.inert() ?? this.config?.inert?.() ?? this.effectiveModal());\n readonly effectiveCloseOnFocusOut = computed(\n () => this.closeOnFocusOut() ?? this.config?.closeOnFocusOut?.() ?? true\n );\n readonly effectiveInitialFocus = computed(() =>\n this.initialFocus() !== undefined ? this.initialFocus()! : (this.config?.initialFocus?.() ?? null)\n );\n readonly effectiveReturnFocus = computed(() =>\n this.returnFocus() !== undefined ? this.returnFocus()! : (this.config?.returnFocus?.() ?? true)\n );\n readonly effectiveOpenInteractionType = computed(\n () => this.config?.openInteractionType?.() ?? this._interactionType()\n );\n readonly effectiveCloseInteractionType = computed(\n () => this.config?.closeInteractionType?.() ?? this._interactionType()\n );\n\n /** The effective trap state the composed `RdxFocusScope` reads via its config token. */\n readonly trapped = computed(() => this.effectiveEnabled() && this.effectiveModal());\n\n // The config this directive provides — its `trapped` signal is writable so we can drive it, and we\n // attach a `returnFocus` resolver the composed focus scope calls at unmount (ADR 0017 `returnFocus`).\n private readonly focusScopeConfig = inject(RdxFocusScopeConfigToken) as {\n trapped: WritableSignal<boolean>;\n returnFocus?: () => HTMLElement | false | undefined;\n };\n\n private readonly host = inject(ElementRef).nativeElement as HTMLElement;\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /** The shared per-popup context (open / triggers / elements), if a primitive root provides one. */\n private readonly rootContext = inject(RDX_FLOATING_ROOT_CONTEXT, { optional: true });\n /** The registration handle for this node, used to read the shared tree (ancestors / descendants). */\n private readonly registration = inject(RDX_FLOATING_REGISTRATION, { optional: true });\n\n private readonly _interactionType = signal<RdxInteractionType>('');\n /** How the popup was most recently interacted with — fed to the initial/return focus policy callbacks. */\n readonly interactionType = this._interactionType.asReadonly();\n\n constructor() {\n effect(() => this.focusScopeConfig.trapped.set(this.trapped()));\n\n // Own the return-focus *target* (the composed focus scope owns the *timing*): the scope calls this\n // in its queued post-unmount frame, resolving the `returnFocus` policy against the close interaction.\n this.focusScopeConfig.returnFocus = () => this.resolveReturnFocusTarget();\n\n if (!this.isBrowser) {\n return; // SSR: no DOM marking / listeners.\n }\n\n // Marker pass (ADR 0017 §3) — applied to outside elements while the manager is active **and the\n // popup is open**, independent of `modal`. Read by ADR 0015's outside-press guard.\n effect((onCleanup) => {\n if (!this.effectiveEnabled() || !this.isFloatingOpen()) {\n return;\n }\n onCleanup(markOthers(this.avoidElements(), { ariaHidden: false, mark: true }));\n });\n\n // Pointer/AT isolation pass — apply the real `inert` attribute to outside elements only when the\n // composing primitive asks for outside interaction to be blocked. This is intentionally separate from\n // focus trapping: Base UI `modal=\"trap-focus\"` traps focus but leaves outside pointer interaction\n // enabled.\n effect((onCleanup) => {\n if (!this.effectiveEnabled() || !this.isFloatingOpen() || !this.effectiveInert()) {\n return;\n }\n onCleanup(markOthers(this.avoidElements(), { inert: true, mark: false }));\n });\n\n this.trackInteractionType();\n this.wireCloseOnFocusOut();\n this.wireFocusOrchestration();\n this.wireInitialFocusFallback();\n }\n\n /** Records the most recent open/close interaction (pointer type or keyboard) for the focus policies. */\n private trackInteractionType(): void {\n const ownerDocument = this.host.ownerDocument;\n const onPointer = (event: Event): void => {\n this._interactionType.set(((event as PointerEvent).pointerType || 'mouse') as RdxInteractionType);\n };\n const onKey = (): void => this._interactionType.set('keyboard');\n\n ownerDocument.addEventListener('pointerdown', onPointer, true);\n ownerDocument.addEventListener('keydown', onKey, true);\n inject(DestroyRef).onDestroy(() => {\n ownerDocument.removeEventListener('pointerdown', onPointer, true);\n ownerDocument.removeEventListener('keydown', onKey, true);\n });\n }\n\n /**\n * Initial-focus orchestration (ADR 0017 §2). The manager owns the focus *policy*; it intercepts the\n * composed {@link RdxFocusScope}'s preventable `mountAutoFocus` (its designed extension point) and\n * applies the `initialFocus` policy, falling back to the scope's first-tabbable default when the\n * policy is `null`. (`returnFocus` is orchestrated separately via the config seam — see\n * {@link resolveReturnFocusTarget} — because it must run during the scope's queued *post-unmount* frame.)\n */\n private wireFocusOrchestration(): void {\n const focusScope = inject(RdxFocusScope);\n\n focusScope.mountAutoFocus.subscribe((event) => {\n const interactionType = this.effectiveOpenInteractionType();\n const target =\n resolveInitialFocus(this.effectiveInitialFocus(), interactionType) ??\n this.defaultInitialFocus(interactionType);\n if (target === false) {\n event.preventDefault();\n return;\n }\n if (target) {\n event.preventDefault(); // override the scope's first-tabbable default\n target.focus();\n }\n });\n }\n\n /**\n * Resolves the {@link returnFocus} policy against the **close** interaction type for the composed\n * focus scope to apply at unmount (ADR 0017 §2). Mirrors Base UI's `getReturnElement`:\n * - `false` → `false` (the scope suppresses return-focus);\n * - `true` / `null` → `undefined` (the scope's default — return to the element focused before mount);\n * - an element (direct or from a callback) → that element (returned **explicitly**, bypassing the\n * \"focus moved elsewhere\" guard).\n */\n private resolveReturnFocusTarget(): HTMLElement | false | undefined {\n const resolved = resolveReturnFocus(this.effectiveReturnFocus(), this.effectiveCloseInteractionType());\n if (resolved === false) {\n return false;\n }\n if (resolved === true || resolved == null) {\n return undefined;\n }\n return resolved;\n }\n\n /**\n * Base UI's `defaultInitialFocus`: on a **touch** open, focus the popup itself instead of its first\n * tabbable control, so a soft keyboard (Android) does not pop up over the popup. Any other interaction\n * returns `null`, keeping the focus scope's first-tabbable default. The popup is made programmatically\n * focusable (`tabindex=\"-1\"`) if it isn't already.\n */\n private defaultInitialFocus(interactionType: RdxInteractionType): HTMLElement | null {\n if (interactionType !== 'touch') {\n return null;\n }\n const popup = (this.rootContext?.floatingElement ?? this.host) as HTMLElement;\n if (!popup.hasAttribute('tabindex')) {\n popup.setAttribute('tabindex', '-1');\n }\n return popup;\n }\n\n /**\n * Manager-owned post-open fallback. Some popup types open from a trigger event that fired before the\n * manager existed, and some policies resolve their final target only after a couple of renders. Re-run\n * the initial-focus policy for a few animation frames while the popup is open so the target can settle.\n */\n private wireInitialFocusFallback(): void {\n effect(() => {\n if (!this.effectiveEnabled() || !this.isFloatingOpen()) {\n return;\n }\n\n this.scheduleInitialFocusFallback();\n });\n }\n\n private scheduleInitialFocusFallback(attempt = 0): void {\n const view = this.host.ownerDocument.defaultView ?? globalThis;\n view.requestAnimationFrame(() => this.applyInitialFocusFallback(attempt));\n }\n\n private applyInitialFocusFallback(attempt: number): void {\n if (!this.effectiveEnabled() || !this.isFloatingOpen()) {\n return;\n }\n\n const popup = (this.rootContext?.floatingElement ?? this.host) as HTMLElement;\n const activeElement = this.host.ownerDocument.activeElement;\n\n if (activeElement instanceof HTMLElement && popup.contains(activeElement)) {\n return;\n }\n\n const interactionType = this.effectiveOpenInteractionType();\n const resolved = resolveInitialFocus(this.effectiveInitialFocus(), interactionType);\n if (resolved === false) {\n return;\n }\n\n const target = resolved ?? this.defaultInitialFocus(interactionType);\n if (target && activeElement !== target) {\n target.focus({ preventScroll: true });\n }\n\n if (attempt < 2) {\n this.scheduleInitialFocusFallback(attempt + 1);\n }\n }\n\n /**\n * Close-on-focus-out (ADR 0017 §3): a **non-modal** active popup closes when focus moves to a node\n * unrelated to the floating tree — not the popup, its trigger(s), a focus guard, or an ancestor /\n * descendant popup — and not during a pointer press (a drag must not close it). Mirrors Base UI's\n * `FloatingFocusManager` `!modal` branch (`movedToUnrelatedNode`).\n */\n private wireCloseOnFocusOut(): void {\n const ownerDocument = this.host.ownerDocument;\n let pointerDown = false;\n\n const onPointerDown = (): void => {\n pointerDown = true;\n };\n const onPointerUp = (): void => {\n pointerDown = false;\n };\n const onFocusOut = (event: FocusEvent): void => {\n if (!this.effectiveEnabled() || !this.effectiveCloseOnFocusOut() || this.effectiveModal() || pointerDown) {\n return;\n }\n const relatedTarget = event.relatedTarget as Node | null;\n if (!relatedTarget) {\n return; // focus left to nothing (tab-away / window blur) — let the browser handle it\n }\n if (relatedTarget instanceof Element && relatedTarget.hasAttribute(FOCUS_GUARD_ATTR)) {\n return; // moved onto a focus guard — still inside the focus system\n }\n if (this.isRelatedTargetInside(relatedTarget)) {\n return; // moved to a related node (trigger / ancestor / descendant) — keep open\n }\n this.focusOut.emit(event);\n };\n\n ownerDocument.addEventListener('pointerdown', onPointerDown, true);\n ownerDocument.addEventListener('pointerup', onPointerUp, true);\n ownerDocument.addEventListener('focusout', onFocusOut, true);\n\n inject(DestroyRef).onDestroy(() => {\n ownerDocument.removeEventListener('pointerdown', onPointerDown, true);\n ownerDocument.removeEventListener('pointerup', onPointerUp, true);\n ownerDocument.removeEventListener('focusout', onFocusOut, true);\n });\n }\n\n /**\n * The marker keep-set is intentionally narrow: the popup/focus host only. Own sibling roots such as a\n * user backdrop are DOM-footprint bookkeeping, not marker keep-set members.\n */\n private avoidElements(): Element[] {\n return [this.host];\n }\n\n private isFloatingOpen(): boolean {\n return this.rootContext?.open() ?? true;\n }\n\n /** Whether `relatedTarget` is inside the popup, its trigger(s), or an ancestor / descendant popup. */\n private isRelatedTargetInside(relatedTarget: Node): boolean {\n const floating = this.rootContext?.floatingElement ?? this.host;\n if (composedContains(floating, relatedTarget)) {\n return true;\n }\n if (this.rootContext && this.contextContains(this.rootContext, relatedTarget)) {\n return true;\n }\n\n const node = this.registration?.node() ?? null;\n if (node) {\n for (const ancestor of node.tree.ancestors(node)) {\n if (ancestor.context && this.contextContains(ancestor.context, relatedTarget)) {\n return true;\n }\n }\n for (const child of node.tree.children(node, { onlyOpen: true })) {\n if (child.context && this.contextContains(child.context, relatedTarget)) {\n return true;\n }\n }\n }\n return false;\n }\n\n private contextContains(context: RdxFloatingRootContext, relatedTarget: Node): boolean {\n if (context.floatingElement && composedContains(context.floatingElement, relatedTarget)) {\n return true;\n }\n if (context.referenceElement && composedContains(context.referenceElement, relatedTarget)) {\n return true;\n }\n return context.triggers.contains(relatedTarget);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAmCA;AACO,MAAM,mBAAmB,GAAG;AAKnC;AACA,MAAM,eAAe,GAAuD;IACxE,KAAK,EAAE,IAAI,OAAO,EAAE;IACpB,aAAa,EAAE,IAAI,OAAO;CAC7B;AACD;AACA,MAAM,qBAAqB,GAA+C;IACtE,KAAK,EAAE,IAAI,OAAO,EAAE;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