1 | import React from 'react';
|
2 | import { TextAccessorFn } from './Accessors';
|
3 | declare type FocusListContext = {
|
4 | focusedItem: any | undefined;
|
5 | activeId?: string;
|
6 | map: WeakMap<HTMLElement, any>;
|
7 | };
|
8 | export declare const FocusListContext: React.Context<FocusListContext | null>;
|
9 | export interface FocusProps {
|
10 | children: any;
|
11 | textAccessor: TextAccessorFn;
|
12 | }
|
13 | export interface FocusList<TDataItem = unknown> {
|
14 | size(): number;
|
15 | focus: (el: HTMLElement | null | undefined) => void;
|
16 | first: () => HTMLElement | undefined;
|
17 | last: () => HTMLElement | undefined;
|
18 | prev(opts?: FocusOptions): HTMLElement | undefined;
|
19 | next(opts?: FocusOptions): HTMLElement | undefined;
|
20 | hasFocused: () => boolean;
|
21 | getFocused: () => TDataItem | undefined;
|
22 | toDataItem: (el: HTMLElement) => TDataItem | undefined;
|
23 | context: FocusListContext;
|
24 | get(): [HTMLElement[], HTMLElement | undefined];
|
25 | }
|
26 | interface FocusOptions {
|
27 | behavior?: 'clear' | 'stop' | 'loop';
|
28 | }
|
29 | interface FocusListOptions<TDataItem> {
|
30 | scope: React.MutableRefObject<HTMLElement | null>;
|
31 | anchorItem?: TDataItem;
|
32 | focusFirstItem?: boolean;
|
33 | scopeSelector?: string;
|
34 | activeId?: string;
|
35 | }
|
36 | export declare function useListOption<TDataItem, T extends HTMLElement>(dataItem: TDataItem): readonly [React.RefObject<T>, boolean, string | undefined];
|
37 | export declare const useFocusList: <TDataItem>({ scope: listRef, anchorItem, focusFirstItem, scopeSelector, activeId, }: FocusListOptions<TDataItem>) => FocusList<TDataItem>;
|
38 | export {};
|
39 |
|
\ | No newline at end of file |