@base-ui-components/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
52 lines (51 loc) • 2.91 kB
TypeScript
import * as React from 'react';
import type { TextDirection } from '../direction-provider/DirectionContext.js';
export interface Dimensions {
width: number;
height: number;
}
export declare const ARROW_UP = "ArrowUp";
export declare const ARROW_DOWN = "ArrowDown";
export declare const ARROW_LEFT = "ArrowLeft";
export declare const ARROW_RIGHT = "ArrowRight";
export declare const HOME = "Home";
export declare const END = "End";
export declare const HORIZONTAL_KEYS: string[];
export declare const HORIZONTAL_KEYS_WITH_EXTRA_KEYS: string[];
export declare const VERTICAL_KEYS: string[];
export declare const VERTICAL_KEYS_WITH_EXTRA_KEYS: string[];
export declare const ARROW_KEYS: string[];
export declare const ALL_KEYS: string[];
export declare function isDifferentRow(index: number, cols: number, prevRow: number): boolean;
export declare function isIndexOutOfBounds(listRef: React.MutableRefObject<Array<HTMLElement | null>>, index: number): boolean;
export declare function getMinIndex(listRef: React.MutableRefObject<Array<HTMLElement | null>>, disabledIndices: Array<number> | undefined): number;
export declare function getMaxIndex(listRef: React.MutableRefObject<Array<HTMLElement | null>>, disabledIndices: Array<number> | undefined): number;
export declare function findNonDisabledIndex(listRef: React.MutableRefObject<Array<HTMLElement | null>>, { startingIndex, decrement, disabledIndices, amount, }?: {
startingIndex?: number;
decrement?: boolean;
disabledIndices?: Array<number>;
amount?: number;
}): number;
export declare function getGridNavigatedIndex(elementsRef: React.MutableRefObject<Array<HTMLElement | null>>, { event, orientation, loop, cols, disabledIndices, minIndex, maxIndex, prevIndex, rtl, stopEvent: stop, }: {
event: React.KeyboardEvent;
orientation: 'horizontal' | 'vertical' | 'both';
loop: boolean;
cols: number;
disabledIndices: Array<number> | undefined;
minIndex: number;
maxIndex: number;
prevIndex: number;
rtl: boolean;
stopEvent?: boolean;
}): number;
/** For each cell index, gets the item index that occupies that cell */
export declare function buildCellMap(sizes: Array<{
width: number;
height: number;
}>, cols: number, dense: boolean): (number | undefined)[];
/** Gets cell index of an item's corner or -1 when index is -1. */
export declare function getCellIndexOfCorner(index: number, sizes: Dimensions[], cellMap: (number | undefined)[], cols: number, corner: 'tl' | 'tr' | 'bl' | 'br'): number;
/** Gets all cell indices that correspond to the specified indices */
export declare function getCellIndices(indices: (number | undefined)[], cellMap: (number | undefined)[]): number[];
export declare function isDisabled(list: Array<HTMLElement | null>, index: number, disabledIndices?: Array<number>): boolean;
export declare function getTextDirection(element: HTMLElement): TextDirection;