@radix-ng/primitives 1.0.0-beta.2 → 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.
- package/LICENSE +1 -1
- package/README.md +76 -6
- package/fesm2022/radix-ng-primitives-accordion.mjs +5 -3
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs +31 -24
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-autocomplete.mjs +1744 -0
- package/fesm2022/radix-ng-primitives-autocomplete.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-calendar.mjs +5 -3
- package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-combobox.mjs +1399 -606
- package/fesm2022/radix-ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-config.mjs +13 -4
- package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-context-menu.mjs +51 -10
- package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +1345 -64
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-date-field.mjs +5 -3
- package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +271 -145
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-direction-provider.mjs +70 -0
- package/fesm2022/radix-ng-primitives-direction-provider.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +519 -184
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-drawer.mjs +154 -64
- package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-field.mjs +3 -2
- package/fesm2022/radix-ng-primitives-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-floating-focus-manager.mjs +517 -0
- package/fesm2022/radix-ng-primitives-floating-focus-manager.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-focus-scope.mjs +296 -70
- package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menu.mjs +894 -299
- package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menubar.mjs +32 -4
- package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs +176 -207
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popover.mjs +250 -250
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popper.mjs +94 -45
- package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-portal.mjs +107 -17
- package/fesm2022/radix-ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs +262 -79
- package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-preview-card.mjs +172 -218
- package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-roving-focus.mjs +4 -2
- package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-scroll-area.mjs +5 -4
- package/fesm2022/radix-ng-primitives-scroll-area.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select.mjs +303 -234
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +5 -3
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-stepper.mjs +5 -3
- package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-time-field.mjs +5 -3
- package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toast.mjs +15 -36
- package/fesm2022/radix-ng-primitives-toast.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +5 -3
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toolbar.mjs +5 -3
- package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip.mjs +105 -145
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
- package/package.json +14 -1
- package/types/radix-ng-primitives-accordion.d.ts +4 -3
- package/types/radix-ng-primitives-alert-dialog.d.ts +17 -11
- package/types/radix-ng-primitives-autocomplete.d.ts +661 -0
- package/types/radix-ng-primitives-calendar.d.ts +5 -3
- package/types/radix-ng-primitives-combobox.d.ts +727 -293
- package/types/radix-ng-primitives-config.d.ts +1 -1
- package/types/radix-ng-primitives-context-menu.d.ts +15 -5
- package/types/radix-ng-primitives-core.d.ts +762 -14
- package/types/radix-ng-primitives-date-field.d.ts +3 -2
- package/types/radix-ng-primitives-dialog.d.ts +107 -55
- package/types/radix-ng-primitives-direction-provider.d.ts +41 -0
- package/types/radix-ng-primitives-dismissable-layer.d.ts +147 -99
- package/types/radix-ng-primitives-drawer.d.ts +49 -22
- package/types/radix-ng-primitives-field.d.ts +1 -0
- package/types/radix-ng-primitives-floating-focus-manager.d.ts +175 -0
- package/types/radix-ng-primitives-focus-scope.d.ts +132 -1
- package/types/radix-ng-primitives-menu.d.ts +204 -112
- package/types/radix-ng-primitives-navigation-menu.d.ts +61 -101
- package/types/radix-ng-primitives-popover.d.ts +82 -115
- package/types/radix-ng-primitives-popper.d.ts +46 -10
- package/types/radix-ng-primitives-portal.d.ts +53 -8
- package/types/radix-ng-primitives-presence.d.ts +98 -17
- package/types/radix-ng-primitives-preview-card.d.ts +63 -95
- package/types/radix-ng-primitives-roving-focus.d.ts +7 -6
- package/types/radix-ng-primitives-scroll-area.d.ts +2 -2
- package/types/radix-ng-primitives-select.d.ts +192 -158
- package/types/radix-ng-primitives-slider.d.ts +5 -4
- package/types/radix-ng-primitives-stepper.d.ts +4 -3
- package/types/radix-ng-primitives-time-field.d.ts +3 -2
- package/types/radix-ng-primitives-toast.d.ts +7 -7
- package/types/radix-ng-primitives-toggle-group.d.ts +5 -4
- package/types/radix-ng-primitives-toolbar.d.ts +3 -2
- package/types/radix-ng-primitives-tooltip.d.ts +48 -84
|
@@ -13,6 +13,8 @@ interface RdxDrawerRegistration {
|
|
|
13
13
|
id: string;
|
|
14
14
|
/** The drawer popup's measured size (px) along its dismiss axis. */
|
|
15
15
|
height: Signal<number>;
|
|
16
|
+
/** 0..1 live dismiss progress of this drawer. */
|
|
17
|
+
swipeProgress: Signal<number>;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* App-level coordinator that tracks every open drawer so background content can react to them
|
|
@@ -30,6 +32,8 @@ declare class RdxDrawerProvider {
|
|
|
30
32
|
readonly frontmost: Signal<RdxDrawerRegistration | null>;
|
|
31
33
|
/** The frontmost drawer's measured size (px), or `0` when none is open. */
|
|
32
34
|
readonly frontmostHeight: Signal<number>;
|
|
35
|
+
/** The frontmost drawer's live dismiss progress, or `0` when none is open. */
|
|
36
|
+
readonly swipeProgress: Signal<number>;
|
|
33
37
|
/** Register an open drawer; returns a disposer that removes it. */
|
|
34
38
|
register(registration: RdxDrawerRegistration): () => void;
|
|
35
39
|
static ɵfac: i0.ɵɵFactoryDeclaration<RdxDrawerProvider, never>;
|
|
@@ -62,6 +66,10 @@ type RdxDrawerRelease = {
|
|
|
62
66
|
interface RdxDrawerSwipeConfig {
|
|
63
67
|
/** The popup element the gesture lives on (CSS variables + data attributes are written here). */
|
|
64
68
|
element: () => HTMLElement;
|
|
69
|
+
/** Gesture boundary used to discover scrollable ancestors around the popup. */
|
|
70
|
+
boundary?: () => HTMLElement;
|
|
71
|
+
/** Visible size along the dismiss axis, used to normalize live swipe progress. */
|
|
72
|
+
size?: () => number;
|
|
65
73
|
/** Active swipe direction. */
|
|
66
74
|
direction: Signal<RdxDrawerSwipeDirection>;
|
|
67
75
|
/** Whether the gesture is currently armed (typically `open`). */
|
|
@@ -109,8 +117,8 @@ declare function useDrawerSwipe(config: RdxDrawerSwipeConfig): void;
|
|
|
109
117
|
* - a string — `'148px'` (pixels), `'30rem'` (root-em), `'40%'` (fraction of size), or a bare number
|
|
110
118
|
* as above.
|
|
111
119
|
*
|
|
112
|
-
* Order the `snapPoints` array ascending by openness; the
|
|
113
|
-
*
|
|
120
|
+
* Order the `snapPoints` array ascending by openness; the first entry is the default the drawer opens
|
|
121
|
+
* to when `defaultSnapPoint` is not set.
|
|
114
122
|
*/
|
|
115
123
|
type RdxDrawerSnapPoint = number | string;
|
|
116
124
|
/**
|
|
@@ -166,6 +174,12 @@ interface RdxDrawerRootContext {
|
|
|
166
174
|
swipeProgress: Signal<number>;
|
|
167
175
|
/** Reports gesture progress from the popup's swipe engine. */
|
|
168
176
|
setSwipeProgress: (value: number) => void;
|
|
177
|
+
/** Whether the drawer is currently being revealed from a SwipeArea. */
|
|
178
|
+
openingSwipeActive: Signal<boolean>;
|
|
179
|
+
/** Pointer travel (px) inward from the SwipeArea while revealing the drawer. */
|
|
180
|
+
openingSwipeDistance: Signal<number>;
|
|
181
|
+
/** Starts or updates the SwipeArea reveal gesture. */
|
|
182
|
+
setOpeningSwipe: (active: boolean, distance: number) => void;
|
|
169
183
|
/** Configured snap points (empty when the drawer has none). */
|
|
170
184
|
snapPoints: Signal<readonly RdxDrawerSnapPoint[]>;
|
|
171
185
|
/** Whether the drawer rests at discrete snap points. */
|
|
@@ -208,12 +222,12 @@ declare class RdxDrawerRoot {
|
|
|
208
222
|
readonly swipeDirection: i0.InputSignal<RdxDrawerSwipeDirection>;
|
|
209
223
|
/**
|
|
210
224
|
* Resting positions the drawer snaps to along the dismiss axis. Order ascending by openness; the
|
|
211
|
-
*
|
|
225
|
+
* first entry is the default the drawer opens to. Omit for a plain open/closed drawer.
|
|
212
226
|
*/
|
|
213
227
|
readonly snapPoints: i0.InputSignal<readonly RdxDrawerSnapPoint[] | undefined>;
|
|
214
228
|
/** The active snap point (controlled / uncontrolled with `[(snapPoint)]`). */
|
|
215
229
|
readonly snapPoint: i0.ModelSignal<RdxDrawerSnapPoint | null>;
|
|
216
|
-
/** The snap point the drawer opens to when uncontrolled; defaults to the
|
|
230
|
+
/** The snap point the drawer opens to when uncontrolled; defaults to the first point. */
|
|
217
231
|
readonly defaultSnapPoint: i0.InputSignal<RdxDrawerSnapPoint | undefined>;
|
|
218
232
|
/** Step at most one snap point per release instead of letting velocity skip points. */
|
|
219
233
|
readonly snapToSequentialPoints: i0.InputSignalWithTransform<boolean, BooleanInput>;
|
|
@@ -221,6 +235,9 @@ declare class RdxDrawerRoot {
|
|
|
221
235
|
readonly onSnapPointChange: i0.OutputEmitterRef<RdxDrawerSnapPoint>;
|
|
222
236
|
/** 0..1 progress of the active dismiss gesture, written by the popup's swipe engine. */
|
|
223
237
|
readonly swipeProgress: i0.WritableSignal<number>;
|
|
238
|
+
/** Live SwipeArea reveal state; the popup converts distance into its measured-axis movement. */
|
|
239
|
+
readonly openingSwipeActive: i0.WritableSignal<boolean>;
|
|
240
|
+
readonly openingSwipeDistance: i0.WritableSignal<number>;
|
|
224
241
|
readonly normalizedSnapPoints: Signal<readonly RdxDrawerSnapPoint[]>;
|
|
225
242
|
readonly hasSnapPoints: Signal<boolean>;
|
|
226
243
|
/** Whether a drawer nested inside this one is open (reuses the dialog's nesting detection). */
|
|
@@ -252,41 +269,47 @@ declare class RdxDrawerTrigger {
|
|
|
252
269
|
/**
|
|
253
270
|
* An off-canvas region (typically pinned to a screen edge) that opens the drawer when swiped inward.
|
|
254
271
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* pointer-drag lifecycle so capture/cancel handling stays consistent with the popup gesture.
|
|
272
|
+
* Opens the drawer at the start of a drag so its popup can follow the pointer live. Releasing past
|
|
273
|
+
* the threshold settles open; releasing before it or cancelling animates the drawer back out.
|
|
258
274
|
*/
|
|
259
275
|
declare class RdxDrawerSwipeArea {
|
|
260
276
|
private readonly drawerContext;
|
|
261
277
|
private readonly dialogContext;
|
|
262
|
-
/** Direction the
|
|
278
|
+
/** Direction the opening gesture travels; defaults to the opposite of the root's dismiss direction. */
|
|
263
279
|
readonly swipeDirection: i0.InputSignal<RdxDrawerSwipeDirection | undefined>;
|
|
264
280
|
/** Whether the swipe area should ignore user interaction. */
|
|
265
281
|
readonly disabled: i0.InputSignalWithTransform<boolean, BooleanInput>;
|
|
266
282
|
protected readonly isOpen: i0.Signal<boolean>;
|
|
267
283
|
protected readonly direction: i0.Signal<RdxDrawerSwipeDirection>;
|
|
284
|
+
protected readonly resolvedTouchAction: i0.Signal<"pan-y" | "pan-x">;
|
|
268
285
|
protected readonly swiping: i0.WritableSignal<boolean>;
|
|
269
286
|
private startX;
|
|
270
287
|
private startY;
|
|
288
|
+
private distance;
|
|
271
289
|
constructor();
|
|
272
290
|
static ɵfac: i0.ɵɵFactoryDeclaration<RdxDrawerSwipeArea, never>;
|
|
273
291
|
static ɵdir: i0.ɵɵDirectiveDeclaration<RdxDrawerSwipeArea, "[rdxDrawerSwipeArea]", ["rdxDrawerSwipeArea"], { "swipeDirection": { "alias": "swipeDirection"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
274
292
|
}
|
|
275
293
|
|
|
276
294
|
/**
|
|
277
|
-
*
|
|
295
|
+
* Structural directive that teleports the drawer content (backdrop + popup) into a container (default
|
|
296
|
+
* `document.body`) while the drawer is open, keeping it mounted until its CSS exit `@keyframes`
|
|
297
|
+
* finish. It composes the structural {@link RdxDialogPortal}, inheriting the dialog presence context.
|
|
298
|
+
*
|
|
299
|
+
* Use the explicit `<ng-template rdxDrawerPortal>` form; pass `[container]` for a custom target.
|
|
278
300
|
*/
|
|
279
|
-
declare class
|
|
280
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<
|
|
281
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<
|
|
301
|
+
declare class RdxDrawerPortal {
|
|
302
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RdxDrawerPortal, never>;
|
|
303
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<RdxDrawerPortal, "ng-template[rdxDrawerPortal]", ["rdxDrawerPortal"], {}, {}, never, never, true, [{ directive: typeof i1.RdxDialogPortal; inputs: { "container": "container"; }; outputs: {}; }]>;
|
|
282
304
|
}
|
|
283
|
-
|
|
284
305
|
/**
|
|
285
|
-
*
|
|
306
|
+
* Dev-mode guard: `rdxDrawerPortal` is now structural, so the old `<div rdxDrawerPortal>` markup would
|
|
307
|
+
* silently stop portaling — fail loudly instead.
|
|
286
308
|
*/
|
|
287
|
-
declare class
|
|
288
|
-
|
|
289
|
-
static
|
|
309
|
+
declare class RdxDrawerPortalMisuseGuard {
|
|
310
|
+
constructor();
|
|
311
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<RdxDrawerPortalMisuseGuard, never>;
|
|
312
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<RdxDrawerPortalMisuseGuard, "[rdxDrawerPortal]:not(ng-template)", never, {}, {}, never, never, true, never>;
|
|
290
313
|
}
|
|
291
314
|
|
|
292
315
|
/**
|
|
@@ -336,6 +359,9 @@ declare class RdxDrawerPopup {
|
|
|
336
359
|
protected readonly frontmostHeightPx: i0.Signal<string | null>;
|
|
337
360
|
constructor();
|
|
338
361
|
private axisSize;
|
|
362
|
+
private axisElementSize;
|
|
363
|
+
private swipeBoundary;
|
|
364
|
+
private visibleAxisSize;
|
|
339
365
|
private resolveRelease;
|
|
340
366
|
static ɵfac: i0.ɵɵFactoryDeclaration<RdxDrawerPopup, never>;
|
|
341
367
|
static ɵdir: i0.ɵɵDirectiveDeclaration<RdxDrawerPopup, "[rdxDrawerPopup]", ["rdxDrawerPopup"], {}, {}, never, never, true, [{ directive: typeof i1.RdxDialogPopup; inputs: {}; outputs: { "escapeKeyDown": "escapeKeyDown"; "pointerDownOutside": "pointerDownOutside"; "focusOutside": "focusOutside"; "interactOutside": "interactOutside"; "openAutoFocus": "openAutoFocus"; "closeAutoFocus": "closeAutoFocus"; }; }]>;
|
|
@@ -384,6 +410,7 @@ declare class RdxDrawerClose {
|
|
|
384
410
|
* Reads the nearest {@link RdxDrawerProvider} and exposes styling hooks; the visual transform is
|
|
385
411
|
* consumer CSS (headless):
|
|
386
412
|
* - `[data-active]` — present while at least one drawer is open.
|
|
413
|
+
* - `--drawer-swipe-progress` — 0..1 live dismiss progress of the frontmost drawer.
|
|
387
414
|
* - `--nested-drawers` — the number of open drawers.
|
|
388
415
|
* - `--drawer-frontmost-height` — the frontmost drawer's measured size, in pixels.
|
|
389
416
|
*/
|
|
@@ -396,9 +423,9 @@ declare class RdxDrawerIndent {
|
|
|
396
423
|
/**
|
|
397
424
|
* The page background layer that scales/indents while any drawer is open.
|
|
398
425
|
*
|
|
399
|
-
* Behaves like {@link RdxDrawerIndent} (same `[data-active]` / `--
|
|
400
|
-
* `--drawer-frontmost-height` contract); kept as a distinct part so the page
|
|
401
|
-
* indented content can be styled independently, mirroring Base UI.
|
|
426
|
+
* Behaves like {@link RdxDrawerIndent} (same `[data-active]` / `--drawer-swipe-progress` /
|
|
427
|
+
* `--nested-drawers` / `--drawer-frontmost-height` contract); kept as a distinct part so the page
|
|
428
|
+
* backdrop and the indented content can be styled independently, mirroring Base UI.
|
|
402
429
|
*/
|
|
403
430
|
declare class RdxDrawerIndentBackground {
|
|
404
431
|
protected readonly provider: RdxDrawerProvider | null;
|
|
@@ -418,9 +445,9 @@ declare function createRdxDrawerHandle<Payload = unknown>(): RdxDrawerHandle<Pay
|
|
|
418
445
|
declare const drawerImports: (typeof RdxDrawerProviderDirective)[];
|
|
419
446
|
declare class RdxDrawerModule {
|
|
420
447
|
static ɵfac: i0.ɵɵFactoryDeclaration<RdxDrawerModule, never>;
|
|
421
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<RdxDrawerModule, never, [typeof RdxDrawerProviderDirective, typeof RdxDrawerRoot, typeof RdxDrawerTrigger, typeof RdxDrawerSwipeArea, typeof
|
|
448
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<RdxDrawerModule, never, [typeof RdxDrawerProviderDirective, typeof RdxDrawerRoot, typeof RdxDrawerTrigger, typeof RdxDrawerSwipeArea, typeof RdxDrawerPortal, typeof RdxDrawerPortalMisuseGuard, typeof RdxDrawerBackdrop, typeof RdxDrawerViewport, typeof RdxDrawerPopup, typeof RdxDrawerContent, typeof RdxDrawerTitle, typeof RdxDrawerDescription, typeof RdxDrawerClose, typeof RdxDrawerIndent, typeof RdxDrawerIndentBackground], [typeof RdxDrawerProviderDirective, typeof RdxDrawerRoot, typeof RdxDrawerTrigger, typeof RdxDrawerSwipeArea, typeof RdxDrawerPortal, typeof RdxDrawerPortalMisuseGuard, typeof RdxDrawerBackdrop, typeof RdxDrawerViewport, typeof RdxDrawerPopup, typeof RdxDrawerContent, typeof RdxDrawerTitle, typeof RdxDrawerDescription, typeof RdxDrawerClose, typeof RdxDrawerIndent, typeof RdxDrawerIndentBackground]>;
|
|
422
449
|
static ɵinj: i0.ɵɵInjectorDeclaration<RdxDrawerModule>;
|
|
423
450
|
}
|
|
424
451
|
|
|
425
|
-
export { RdxDrawerBackdrop, RdxDrawerClose, RdxDrawerContent, RdxDrawerDescription, RdxDrawerHandle, RdxDrawerIndent, RdxDrawerIndentBackground, RdxDrawerModule, RdxDrawerPopup, RdxDrawerPortal,
|
|
452
|
+
export { RdxDrawerBackdrop, RdxDrawerClose, RdxDrawerContent, RdxDrawerDescription, RdxDrawerHandle, RdxDrawerIndent, RdxDrawerIndentBackground, RdxDrawerModule, RdxDrawerPopup, RdxDrawerPortal, RdxDrawerPortalMisuseGuard, RdxDrawerProvider, RdxDrawerProviderDirective, RdxDrawerRoot, RdxDrawerSwipeArea, RdxDrawerTitle, RdxDrawerTrigger, RdxDrawerViewport, buildSnapEntries, createRdxDrawerHandle, dismissUnitVector, drawerImports, injectRdxDrawerRootContext, provideRdxDrawerProvider, provideRdxDrawerRootContext, resolveSnapTarget, snapPointReveal, useDrawerSwipe };
|
|
426
453
|
export type { RdxDrawerRegistration, RdxDrawerRelease, RdxDrawerRootContext, RdxDrawerSnapEntry, RdxDrawerSnapPoint, RdxDrawerSnapResolveOptions, RdxDrawerSnapTarget, RdxDrawerSwipeConfig, RdxDrawerSwipeDirection };
|
|
@@ -188,6 +188,7 @@ declare class RdxFieldLabel {
|
|
|
188
188
|
*/
|
|
189
189
|
readonly id: _angular_core.InputSignal<string>;
|
|
190
190
|
readonly htmlFor: () => string;
|
|
191
|
+
constructor();
|
|
191
192
|
protected readonly dataAttr: (value: boolean) => "" | undefined;
|
|
192
193
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxFieldLabel, never>;
|
|
193
194
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxFieldLabel, "[rdxFieldLabel]", ["rdxFieldLabel"], { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { InjectionToken, Provider } from '@angular/core';
|
|
3
|
+
import { BooleanInput } from '@radix-ng/primitives/core';
|
|
4
|
+
import * as i1 from '@radix-ng/primitives/focus-scope';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How a popup was opened / closed (Base UI `InteractionType`). `null` = a **programmatic** open (prefer
|
|
8
|
+
* the previously-focused element); `''` = an **unknown** interaction. The two are deliberately distinct
|
|
9
|
+
* (Base UI keys `preferPreviousFocus = openInteractionType == null` off exactly this).
|
|
10
|
+
*/
|
|
11
|
+
type RdxInteractionType = 'mouse' | 'touch' | 'pen' | 'keyboard' | '' | null;
|
|
12
|
+
/** A focus target: an element, a getter, or `null`. */
|
|
13
|
+
type RdxFocusTarget = HTMLElement | (() => HTMLElement | null) | null;
|
|
14
|
+
/** `initialFocus` policy (ADR 0017 §2) — a target, `false`, or an open-interaction callback. */
|
|
15
|
+
type RdxInitialFocus = RdxFocusTarget | false | ((openInteractionType: RdxInteractionType) => RdxFocusTarget | false);
|
|
16
|
+
/** `returnFocus` policy (ADR 0017 §2) — a target/boolean or a callback receiving the **close** interaction type. */
|
|
17
|
+
type RdxReturnFocus = RdxFocusTarget | boolean | ((closeInteractionType: RdxInteractionType) => RdxFocusTarget | boolean);
|
|
18
|
+
/** Normalizes a DOM event into Base UI-like interaction intent for focus policy decisions. */
|
|
19
|
+
declare function getInteractionTypeFromEvent(event?: Event): RdxInteractionType;
|
|
20
|
+
/** Resolves an {@link RdxFocusTarget} (element | getter | null) to a concrete element. */
|
|
21
|
+
declare function resolveFocusTarget(target: RdxFocusTarget): HTMLElement | null;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves an {@link RdxInitialFocus} policy against how the popup opened.
|
|
24
|
+
*/
|
|
25
|
+
declare function resolveInitialFocus(policy: RdxInitialFocus, openInteractionType: RdxInteractionType): HTMLElement | null | false;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves an {@link RdxReturnFocus} policy against how the popup closed. `false` = do not return focus;
|
|
28
|
+
* `true` = the default (return to the previously-focused element); an element = return there.
|
|
29
|
+
*/
|
|
30
|
+
declare function resolveReturnFocus(policy: RdxReturnFocus, closeInteractionType: RdxInteractionType): HTMLElement | boolean | null;
|
|
31
|
+
/**
|
|
32
|
+
* DI seam for a **composing primitive** (Dialog / Popover / Menu) to drive the manager's gates from its
|
|
33
|
+
* own root context instead of template-bound inputs (which a primitive cannot set). Each field falls
|
|
34
|
+
* back to the manager's input, then to the documented default. Mirrors {@link RdxFocusScopeConfig}.
|
|
35
|
+
*/
|
|
36
|
+
interface RdxFloatingFocusManagerConfig {
|
|
37
|
+
modal?: () => boolean;
|
|
38
|
+
inert?: () => boolean;
|
|
39
|
+
enabled?: () => boolean;
|
|
40
|
+
closeOnFocusOut?: () => boolean;
|
|
41
|
+
initialFocus?: () => RdxInitialFocus;
|
|
42
|
+
returnFocus?: () => RdxReturnFocus;
|
|
43
|
+
openInteractionType?: () => RdxInteractionType;
|
|
44
|
+
closeInteractionType?: () => RdxInteractionType;
|
|
45
|
+
}
|
|
46
|
+
declare const RDX_FLOATING_FOCUS_MANAGER_CONFIG: InjectionToken<RdxFloatingFocusManagerConfig>;
|
|
47
|
+
/** Provides a {@link RdxFloatingFocusManagerConfig} for an enclosing primitive's focus manager. */
|
|
48
|
+
declare function provideFloatingFocusManagerConfig(factory: () => RdxFloatingFocusManagerConfig): Provider;
|
|
49
|
+
/**
|
|
50
|
+
* `RdxFloatingFocusManager` (ADR 0017 Phase 1b skeleton) — the Angular counterpart of Base UI's
|
|
51
|
+
* `FloatingFocusManager`. It is a **coordinator** that composes three low-level focus parts (it never
|
|
52
|
+
* inherits them, which would re-fuse trap + popup policy): the **reworked {@link RdxFocusScope}** (the
|
|
53
|
+
* trap, via `hostDirectives`), the portal-focus bridge, and owner-`Document` guards. Per ADR 0017 §1/§2
|
|
54
|
+
* its policies are **independent**, none derived from `modal`.
|
|
55
|
+
*
|
|
56
|
+
* **This skeleton wires the composition + lifecycle gates:**
|
|
57
|
+
* - `enabled` — the manager's active-ness (`mounted && !hover-open`). When off, **no trap** (and, later,
|
|
58
|
+
* no aria-hidden / no marker — Phase 2).
|
|
59
|
+
* - `modal` → `RdxFocusScope.trapped`: the effective trap is `enabled() && modal()`, pushed into the
|
|
60
|
+
* composed focus scope through its config token (the composition seam).
|
|
61
|
+
* - `loop` is forwarded to `RdxFocusScope`.
|
|
62
|
+
* - `initialFocus` / `returnFocus` are **orchestrated** here (the §2 policy contract, incl. the
|
|
63
|
+
* interaction-type callback forms): `initialFocus` via the scope's `mountAutoFocus` hook, `returnFocus`
|
|
64
|
+
* via the scope's `returnFocus` config seam (resolved at the scope's queued post-unmount frame). The
|
|
65
|
+
* portal-focus bridge remains a later-phase dependency.
|
|
66
|
+
*/
|
|
67
|
+
declare class RdxFloatingFocusManager {
|
|
68
|
+
/** Manager active-ness (ADR 0017 §2): the popup is mounted **and** not hover-opened. */
|
|
69
|
+
readonly enabled: _angular_core.InputSignalWithTransform<boolean | undefined, BooleanInput>;
|
|
70
|
+
/** Modal popup → focus trap. Combined with `enabled` to drive the composed `RdxFocusScope`. */
|
|
71
|
+
readonly modal: _angular_core.InputSignalWithTransform<boolean | undefined, BooleanInput>;
|
|
72
|
+
/**
|
|
73
|
+
* Whether outside elements receive the real `inert` attribute. Defaults to the effective `modal` value,
|
|
74
|
+
* but primitives can split focus trapping from pointer/AT isolation (Base UI `modal="trap-focus"`).
|
|
75
|
+
*/
|
|
76
|
+
readonly inert: _angular_core.InputSignalWithTransform<boolean | undefined, BooleanInput>;
|
|
77
|
+
/** Where focus goes when the popup opens (ADR 0017 §2). */
|
|
78
|
+
readonly initialFocus: _angular_core.InputSignal<RdxInitialFocus | undefined>;
|
|
79
|
+
/** Where focus returns when the popup closes (ADR 0017 §2). */
|
|
80
|
+
readonly returnFocus: _angular_core.InputSignal<RdxReturnFocus | undefined>;
|
|
81
|
+
/**
|
|
82
|
+
* Whether a **non-modal** popup closes when focus leaves to an unrelated node (Base UI
|
|
83
|
+
* `closeOnFocusOut`, default `true`; Dialog sets it to `!disablePointerDismissal`). Modal popups
|
|
84
|
+
* never close on focus-out (the trap keeps focus in).
|
|
85
|
+
*/
|
|
86
|
+
readonly closeOnFocusOut: _angular_core.InputSignalWithTransform<boolean | undefined, BooleanInput>;
|
|
87
|
+
/**
|
|
88
|
+
* Emitted when focus leaves a non-modal popup to a node **unrelated** to the floating tree (ADR 0017
|
|
89
|
+
* §3) — the consumer should close the popup. This is the focus-manager's focus-out close (it reads
|
|
90
|
+
* the shared tree), replacing the dismissal capability's focus-out at the ADR 0015 Phase-4 cutover.
|
|
91
|
+
*/
|
|
92
|
+
readonly focusOut: _angular_core.OutputEmitterRef<FocusEvent>;
|
|
93
|
+
/** Optional DI config a composing primitive provides to drive the gates (input wins over config). */
|
|
94
|
+
private readonly config;
|
|
95
|
+
/** Effective gates: `input ?? config ?? default`. */
|
|
96
|
+
readonly effectiveEnabled: _angular_core.Signal<boolean>;
|
|
97
|
+
readonly effectiveModal: _angular_core.Signal<boolean>;
|
|
98
|
+
readonly effectiveInert: _angular_core.Signal<boolean>;
|
|
99
|
+
readonly effectiveCloseOnFocusOut: _angular_core.Signal<boolean>;
|
|
100
|
+
readonly effectiveInitialFocus: _angular_core.Signal<false | HTMLElement | ((openInteractionType: RdxInteractionType) => RdxFocusTarget | false) | null>;
|
|
101
|
+
readonly effectiveReturnFocus: _angular_core.Signal<boolean | HTMLElement | ((closeInteractionType: RdxInteractionType) => RdxFocusTarget | boolean)>;
|
|
102
|
+
readonly effectiveOpenInteractionType: _angular_core.Signal<RdxInteractionType>;
|
|
103
|
+
readonly effectiveCloseInteractionType: _angular_core.Signal<RdxInteractionType>;
|
|
104
|
+
/** The effective trap state the composed `RdxFocusScope` reads via its config token. */
|
|
105
|
+
readonly trapped: _angular_core.Signal<boolean>;
|
|
106
|
+
private readonly focusScopeConfig;
|
|
107
|
+
private readonly host;
|
|
108
|
+
private readonly isBrowser;
|
|
109
|
+
/** The shared per-popup context (open / triggers / elements), if a primitive root provides one. */
|
|
110
|
+
private readonly rootContext;
|
|
111
|
+
/** The registration handle for this node, used to read the shared tree (ancestors / descendants). */
|
|
112
|
+
private readonly registration;
|
|
113
|
+
private readonly _interactionType;
|
|
114
|
+
/** How the popup was most recently interacted with — fed to the initial/return focus policy callbacks. */
|
|
115
|
+
readonly interactionType: _angular_core.Signal<RdxInteractionType>;
|
|
116
|
+
constructor();
|
|
117
|
+
/** Records the most recent open/close interaction (pointer type or keyboard) for the focus policies. */
|
|
118
|
+
private trackInteractionType;
|
|
119
|
+
/**
|
|
120
|
+
* Initial-focus orchestration (ADR 0017 §2). The manager owns the focus *policy*; it intercepts the
|
|
121
|
+
* composed {@link RdxFocusScope}'s preventable `mountAutoFocus` (its designed extension point) and
|
|
122
|
+
* applies the `initialFocus` policy, falling back to the scope's first-tabbable default when the
|
|
123
|
+
* policy is `null`. (`returnFocus` is orchestrated separately via the config seam — see
|
|
124
|
+
* {@link resolveReturnFocusTarget} — because it must run during the scope's queued *post-unmount* frame.)
|
|
125
|
+
*/
|
|
126
|
+
private wireFocusOrchestration;
|
|
127
|
+
/**
|
|
128
|
+
* Resolves the {@link returnFocus} policy against the **close** interaction type for the composed
|
|
129
|
+
* focus scope to apply at unmount (ADR 0017 §2). Mirrors Base UI's `getReturnElement`:
|
|
130
|
+
* - `false` → `false` (the scope suppresses return-focus);
|
|
131
|
+
* - `true` / `null` → `undefined` (the scope's default — return to the element focused before mount);
|
|
132
|
+
* - an element (direct or from a callback) → that element (returned **explicitly**, bypassing the
|
|
133
|
+
* "focus moved elsewhere" guard).
|
|
134
|
+
*/
|
|
135
|
+
private resolveReturnFocusTarget;
|
|
136
|
+
/**
|
|
137
|
+
* Base UI's `defaultInitialFocus`: on a **touch** open, focus the popup itself instead of its first
|
|
138
|
+
* tabbable control, so a soft keyboard (Android) does not pop up over the popup. Any other interaction
|
|
139
|
+
* returns `null`, keeping the focus scope's first-tabbable default. The popup is made programmatically
|
|
140
|
+
* focusable (`tabindex="-1"`) if it isn't already.
|
|
141
|
+
*/
|
|
142
|
+
private defaultInitialFocus;
|
|
143
|
+
/**
|
|
144
|
+
* Manager-owned post-open fallback. Some popup types open from a trigger event that fired before the
|
|
145
|
+
* manager existed, and some policies resolve their final target only after a couple of renders. Re-run
|
|
146
|
+
* the initial-focus policy for a few animation frames while the popup is open so the target can settle.
|
|
147
|
+
*/
|
|
148
|
+
private wireInitialFocusFallback;
|
|
149
|
+
private scheduleInitialFocusFallback;
|
|
150
|
+
private applyInitialFocusFallback;
|
|
151
|
+
/**
|
|
152
|
+
* Close-on-focus-out (ADR 0017 §3): a **non-modal** active popup closes when focus moves to a node
|
|
153
|
+
* unrelated to the floating tree — not the popup, its trigger(s), a focus guard, or an ancestor /
|
|
154
|
+
* descendant popup — and not during a pointer press (a drag must not close it). Mirrors Base UI's
|
|
155
|
+
* `FloatingFocusManager` `!modal` branch (`movedToUnrelatedNode`).
|
|
156
|
+
*/
|
|
157
|
+
private wireCloseOnFocusOut;
|
|
158
|
+
/**
|
|
159
|
+
* The marker keep-set is intentionally narrow: the popup/focus host only. Own sibling roots such as a
|
|
160
|
+
* user backdrop are DOM-footprint bookkeeping, not marker keep-set members.
|
|
161
|
+
*/
|
|
162
|
+
private avoidElements;
|
|
163
|
+
private isFloatingOpen;
|
|
164
|
+
/** Whether `relatedTarget` is inside the popup, its trigger(s), or an ancestor / descendant popup. */
|
|
165
|
+
private isRelatedTargetInside;
|
|
166
|
+
private contextContains;
|
|
167
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxFloatingFocusManager, never>;
|
|
168
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxFloatingFocusManager, "[rdxFloatingFocusManager]", ["rdxFloatingFocusManager"], { "enabled": { "alias": "enabled"; "required": false; "isSignal": true; }; "modal": { "alias": "modal"; "required": false; "isSignal": true; }; "inert": { "alias": "inert"; "required": false; "isSignal": true; }; "initialFocus": { "alias": "initialFocus"; "required": false; "isSignal": true; }; "returnFocus": { "alias": "returnFocus"; "required": false; "isSignal": true; }; "closeOnFocusOut": { "alias": "closeOnFocusOut"; "required": false; "isSignal": true; }; }, { "focusOut": "focusOut"; }, never, never, true, [{ directive: typeof i1.RdxFocusScope; inputs: { "loop": "loop"; }; outputs: {}; }]>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The neutral "outside the active floating layer" marker (Base UI `data-base-ui-inert`). */
|
|
172
|
+
declare const RDX_FLOATING_MARKER = "data-rdx-floating-inert";
|
|
173
|
+
|
|
174
|
+
export { RDX_FLOATING_FOCUS_MANAGER_CONFIG, RDX_FLOATING_MARKER, RdxFloatingFocusManager, getInteractionTypeFromEvent, provideFloatingFocusManagerConfig, resolveFocusTarget, resolveInitialFocus, resolveReturnFocus };
|
|
175
|
+
export type { RdxFloatingFocusManagerConfig, RdxFocusTarget, RdxInitialFocus, RdxInteractionType, RdxReturnFocus };
|
|
@@ -3,6 +3,49 @@ import { WritableSignal, Signal, InjectionToken, Provider } from '@angular/core'
|
|
|
3
3
|
import * as _radix_ng_primitives_core from '@radix-ng/primitives/core';
|
|
4
4
|
import { BooleanInput } from '@radix-ng/primitives/core';
|
|
5
5
|
|
|
6
|
+
/** Marks the leading / trailing focus-guard spans (Base UI `data-base-ui-focus-guard`). */
|
|
7
|
+
declare const FOCUS_GUARD_ATTR = "data-rdx-focus-guard";
|
|
8
|
+
/** Visually-hidden, off-flow style for a focus guard / `aria-owns` anchor (Base UI `visuallyHidden`). */
|
|
9
|
+
declare const FOCUS_GUARD_STYLE: Partial<CSSStyleDeclaration>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a visually-hidden, **tabbable** focus-guard `<span>` — the Angular counterpart of Base UI's
|
|
12
|
+
* `FocusGuard`. The portal-focus bridge places one before and one after the portal content so a Tab into
|
|
13
|
+
* (or out of) the portal lands on a guard, which then redirects focus to the right boundary.
|
|
14
|
+
*/
|
|
15
|
+
declare function createFocusGuard(ownerDocument: Document): HTMLSpanElement;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a visually-hidden `<span aria-owns="…">` that links the portal node into the trigger's tab /
|
|
18
|
+
* AT order (Base UI's single `aria-owns` anchor). The manager places it next to the trigger.
|
|
19
|
+
*/
|
|
20
|
+
declare function createAriaOwnsAnchor(ownerDocument: Document, portalId: string): HTMLSpanElement;
|
|
21
|
+
/**
|
|
22
|
+
* Makes every tabbable descendant of `container` **non-tabbable** (`tabindex="-1"`), saving each one's
|
|
23
|
+
* original tabindex so {@link enableFocusInside} can restore it. Base UI `disableFocusInside`: a
|
|
24
|
+
* non-modal portal keeps its content untabbable until focus is actually inside it, so a Tab from the
|
|
25
|
+
* trigger steps onto the guard instead of jumping into the content.
|
|
26
|
+
*/
|
|
27
|
+
declare function disableFocusInside(container: HTMLElement): void;
|
|
28
|
+
/** Restores the tabbability that {@link disableFocusInside} suspended. Base UI `enableFocusInside`. */
|
|
29
|
+
declare function enableFocusInside(container: HTMLElement): void;
|
|
30
|
+
/**
|
|
31
|
+
* Whether a focus event crossed the `container` boundary — its `relatedTarget` (the other side of the
|
|
32
|
+
* focus move) is `null` or outside `container` (Base UI `isOutsideEvent`). Shadow-DOM-aware via
|
|
33
|
+
* {@link composedContains}.
|
|
34
|
+
*/
|
|
35
|
+
declare function isOutsideEvent(event: FocusEvent, container: Element): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The portal-focus bridge's **tabbability toggle** (Base UI `FloatingPortal` capture-phase `onFocus`).
|
|
38
|
+
* While `portalNode` is mounted (and `enabled`), it makes the portal content tabbable **only when focus
|
|
39
|
+
* is inside it**: focus entering from outside re-enables tabbability, focus leaving to outside disables
|
|
40
|
+
* it again. Listens on the **capture** phase so it settles before the focus manager's guards react.
|
|
41
|
+
*
|
|
42
|
+
* Must be called in an injection context. The initial disable-on-mount and the guard-span placement are
|
|
43
|
+
* the manager's responsibility (Phase 1b); this owns only the dynamic in/out toggle.
|
|
44
|
+
*/
|
|
45
|
+
declare function useFocusGuardsTabbability(portalNode: () => HTMLElement | null, options?: {
|
|
46
|
+
enabled?: () => boolean;
|
|
47
|
+
}): void;
|
|
48
|
+
|
|
6
49
|
interface FocusScopeAPI {
|
|
7
50
|
paused: WritableSignal<boolean>;
|
|
8
51
|
pause(): void;
|
|
@@ -23,6 +66,8 @@ declare class RdxFocusScope {
|
|
|
23
66
|
private readonly destroyRef;
|
|
24
67
|
private readonly elementRef;
|
|
25
68
|
private readonly config;
|
|
69
|
+
/** The host's owner `Document` — all focus listeners / reads are scoped here, never global `document`. */
|
|
70
|
+
private readonly ownerDocument;
|
|
26
71
|
/**
|
|
27
72
|
* When `true`, tabbing from last item will focus first tabbable
|
|
28
73
|
* and shift+tab from first item will focus last tababble.
|
|
@@ -59,6 +104,15 @@ declare class RdxFocusScope {
|
|
|
59
104
|
readonly focusScope: FocusScopeAPI;
|
|
60
105
|
private alive;
|
|
61
106
|
constructor();
|
|
107
|
+
/**
|
|
108
|
+
* Whether the interaction that unmounted this scope already moved focus to a legitimate element
|
|
109
|
+
* **outside** it — e.g. an outside press onto an interactive control in a non-modal layer (ADR 0017
|
|
110
|
+
* §2, finding #3). Returning focus to the previously-focused element would then *steal* it back from
|
|
111
|
+
* what the user just acted on. Focus that fell to `<body>` / `null` (a backdrop press, Escape, or the
|
|
112
|
+
* focused element being removed) is **not** "moved" — return focus normally so keyboard users land
|
|
113
|
+
* back on the trigger. The page never scroll-jumps either way: {@link focus} uses `preventScroll`.
|
|
114
|
+
*/
|
|
115
|
+
private shouldPreserveMovedFocus;
|
|
62
116
|
handleKeyDown(event: KeyboardEvent): void;
|
|
63
117
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<RdxFocusScope, never>;
|
|
64
118
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<RdxFocusScope, "[rdxFocusScope]", never, { "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "trapped": { "alias": "trapped"; "required": false; "isSignal": true; }; }, { "mountAutoFocus": "mountAutoFocus"; "unmountAutoFocus": "unmountAutoFocus"; }, never, never, true, never>;
|
|
@@ -66,9 +120,86 @@ declare class RdxFocusScope {
|
|
|
66
120
|
|
|
67
121
|
type RdxFocusScopeConfig = {
|
|
68
122
|
trapped: Signal<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* Optional return-focus policy override (ADR 0017 `returnFocus`), resolved by an enclosing
|
|
125
|
+
* {@link RdxFloatingFocusManager} at **unmount time**. The focus scope owns the *timing* (its queued
|
|
126
|
+
* post-unmount focus); this lets the manager own the *target*:
|
|
127
|
+
* - `false` → do **not** return focus;
|
|
128
|
+
* - an `HTMLElement` → return focus there **explicitly** (bypasses the moved-focus guard, matching
|
|
129
|
+
* Base UI's `hasExplicitReturnFocus`);
|
|
130
|
+
* - `undefined` → default behavior (return to the element focused before mount, with the guard).
|
|
131
|
+
*/
|
|
132
|
+
returnFocus?: () => HTMLElement | false | undefined;
|
|
69
133
|
};
|
|
70
134
|
declare const RdxFocusScopeConfigToken: InjectionToken<RdxFocusScopeConfig>;
|
|
71
135
|
declare function provideRdxFocusScopeConfig(factory: () => RdxFocusScopeConfig): Provider;
|
|
72
136
|
|
|
73
|
-
|
|
137
|
+
declare const AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
138
|
+
declare const AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
139
|
+
declare const EVENT_OPTIONS: {
|
|
140
|
+
bubbles: boolean;
|
|
141
|
+
cancelable: boolean;
|
|
142
|
+
};
|
|
143
|
+
type FocusableTarget = HTMLElement | {
|
|
144
|
+
focus: () => void;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* The real target of a (possibly retargeted) event, piercing shadow boundaries via `composedPath()`.
|
|
148
|
+
* Falls back to `event.target` when `composedPath` is unavailable.
|
|
149
|
+
*/
|
|
150
|
+
declare function getEventTarget(event: Event): EventTarget | null;
|
|
151
|
+
/**
|
|
152
|
+
* Shadow-DOM-aware containment: whether `node` is `container` or lives inside it, crossing shadow roots
|
|
153
|
+
* via their `host` (unlike `Node.contains`, which stops at a shadow boundary).
|
|
154
|
+
*/
|
|
155
|
+
declare function composedContains(container: Node, node: Node | null): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Attempts focusing the first element in a list of candidates.
|
|
158
|
+
* Stops when focus has actually moved.
|
|
159
|
+
*/
|
|
160
|
+
declare function focusFirst(candidates: HTMLElement[], { select }?: {
|
|
161
|
+
select?: boolean | undefined;
|
|
162
|
+
}): true | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Returns a list of potential tabbable candidates.
|
|
165
|
+
*
|
|
166
|
+
* NOTE: This is only a close approximation. For example it doesn't take into account cases like when
|
|
167
|
+
* elements are not visible. This cannot be worked out easily by just reading a property, but rather
|
|
168
|
+
* necessitate runtime knowledge (computed styles, etc). We deal with these cases separately.
|
|
169
|
+
*
|
|
170
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
|
|
171
|
+
* Credit: https://github.com/discord/focus-layers/blob/master/src/util/wrapFocus.tsx#L1
|
|
172
|
+
*/
|
|
173
|
+
declare function getTabbableCandidates(container: HTMLElement): HTMLElement[];
|
|
174
|
+
declare function isHidden(node: HTMLElement, { upTo }: {
|
|
175
|
+
upTo?: HTMLElement;
|
|
176
|
+
}): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Returns the first visible element in a list.
|
|
179
|
+
* NOTE: Only checks visibility up to the `container`.
|
|
180
|
+
*/
|
|
181
|
+
declare function findVisible(elements: HTMLElement[], container: HTMLElement): HTMLElement | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Returns the first and last tabbable elements inside a container.
|
|
184
|
+
*/
|
|
185
|
+
declare function getTabbableEdges(container: HTMLElement): readonly [HTMLElement | undefined, HTMLElement | undefined];
|
|
186
|
+
/**
|
|
187
|
+
* The next tabbable in the document after the current focus (Base UI `getNextTabbable`) — used by the
|
|
188
|
+
* portal-focus bridge's trailing guard to step focus past the popup. Falls back to `reference`.
|
|
189
|
+
*/
|
|
190
|
+
declare function getNextTabbable(reference: Element | null): HTMLElement | null;
|
|
191
|
+
/** The previous tabbable in the document before the current focus (Base UI `getPreviousTabbable`). */
|
|
192
|
+
declare function getPreviousTabbable(reference: Element | null): HTMLElement | null;
|
|
193
|
+
/** The tabbable immediately after `reference` in the document, wrapping (Base UI `getTabbableAfterElement`). */
|
|
194
|
+
declare function getTabbableAfterElement(reference: Element | null): HTMLElement | null;
|
|
195
|
+
/** The tabbable immediately before `reference` in the document, wrapping (Base UI `getTabbableBeforeElement`). */
|
|
196
|
+
declare function getTabbableBeforeElement(reference: Element | null): HTMLElement | null;
|
|
197
|
+
declare function isSelectableInput(element: any): element is FocusableTarget & {
|
|
198
|
+
select: () => void;
|
|
199
|
+
};
|
|
200
|
+
declare function focus(element?: FocusableTarget | null, { select }?: {
|
|
201
|
+
select?: boolean | undefined;
|
|
202
|
+
}): void;
|
|
203
|
+
|
|
204
|
+
export { AUTOFOCUS_ON_MOUNT, AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS, FOCUS_GUARD_ATTR, FOCUS_GUARD_STYLE, RdxFocusScope, RdxFocusScopeConfigToken, composedContains, createAriaOwnsAnchor, createFocusGuard, disableFocusInside, enableFocusInside, findVisible, focus, focusFirst, getEventTarget, getNextTabbable, getPreviousTabbable, getTabbableAfterElement, getTabbableBeforeElement, getTabbableCandidates, getTabbableEdges, injectFocusScopeContext, isHidden, isOutsideEvent, isSelectableInput, provideFocusScopeContext, provideRdxFocusScopeConfig, useFocusGuardsTabbability };
|
|
74
205
|
export type { FocusScopeContext, RdxFocusScopeConfig };
|