1 | import { NodeIndex } from './utils/tabOrder';
|
2 | declare type UnresolvedSolution = {};
|
3 | declare type ResolvedSolution = {
|
4 | prev: NodeIndex;
|
5 | next: NodeIndex;
|
6 | first: NodeIndex;
|
7 | last: NodeIndex;
|
8 | };
|
9 | /**
|
10 | * for a given `element` in a given `scope` returns focusable siblings
|
11 | * @param element - base element
|
12 | * @param scope - common parent. Can be document, but better to narrow it down for performance reasons
|
13 | * @returns {prev,next} - references to a focusable element before and after
|
14 | * @returns undefined - if operation is not applicable
|
15 | */
|
16 | export declare const getRelativeFocusable: (element: Element, scope: HTMLElement | HTMLElement[], useTabbables: boolean) => UnresolvedSolution | ResolvedSolution | undefined;
|
17 | declare type ScopeRef = HTMLElement | HTMLElement[];
|
18 | interface FocusNextOptions {
|
19 | /**
|
20 | * the component to "scope" focus in
|
21 | * @default document.body
|
22 | */
|
23 | scope?: ScopeRef;
|
24 | /**
|
25 | * enables cycling inside the scope
|
26 | * @default true
|
27 | */
|
28 | cycle?: boolean;
|
29 | /**
|
30 | * options for focus action to control it more precisely (ie. `{ preventScroll: true }`)
|
31 | */
|
32 | focusOptions?: FocusOptions;
|
33 | /**
|
34 | * scopes to only tabbable elements
|
35 | * set to false to include all focusable elements (tabindex -1)
|
36 | * @default true
|
37 | */
|
38 | onlyTabbable?: boolean;
|
39 | }
|
40 | /**
|
41 | * focuses next element in the tab-order
|
42 | * @param fromElement - common parent to scope active element search or tab cycle order
|
43 | * @param {FocusNextOptions} [options] - focus options
|
44 | */
|
45 | export declare const focusNextElement: (fromElement: Element, options?: FocusNextOptions) => void;
|
46 | /**
|
47 | * focuses prev element in the tab order
|
48 | * @param fromElement - common parent to scope active element search or tab cycle order
|
49 | * @param {FocusNextOptions} [options] - focus options
|
50 | */
|
51 | export declare const focusPrevElement: (fromElement: Element, options?: FocusNextOptions) => void;
|
52 | declare type FocusBoundaryOptions = Pick<FocusNextOptions, 'focusOptions' | 'onlyTabbable'>;
|
53 | /**
|
54 | * focuses first element in the tab-order
|
55 | * @param {FocusNextOptions} options - focus options
|
56 | */
|
57 | export declare const focusFirstElement: (scope: ScopeRef, options?: FocusBoundaryOptions) => void;
|
58 | /**
|
59 | * focuses last element in the tab order
|
60 | * @param {FocusNextOptions} options - focus options
|
61 | */
|
62 | export declare const focusLastElement: (scope: ScopeRef, options?: FocusBoundaryOptions) => void;
|
63 | export {};
|