baseui
Version:
A React Component library implementing the Base design language
48 lines (47 loc) • 1.69 kB
TypeScript
import type { Offset, PopoverPlacement } from './types';
/**
* Returns the opposite of the specified position. Useful for tooltip
* positioning logic.
* Examples:
* top -> bottom
* left -> right
*/
export declare function getOppositePosition(position: string): string;
/**
* Determines whether or not the specified position is a vertical one (top or bottom)
*/
export declare function isVerticalPosition(position: string): boolean;
/**
* Simple utility function for capitalizing the first letter of a string
*/
export declare function capitalize(str: string): string;
/**
* Opposite of function above, converts from Popper.js placement
* to our placement prop
*/
export declare function fromPopperPlacement(placement: string): PopoverPlacement | null;
/**
* Splits something like 'topLeft' to ['top', 'left'] for easier usage
*/
export declare function splitPlacement(placement: PopoverPlacement): string[];
/**
* Returns margin styles to add spacing between the popover
* and its anchor.
*/
export declare function getPopoverMarginStyles(arrowSize: number, placement: PopoverPlacement, popoverMargin: number): {
[x: string]: string;
};
/**
* Returns CSS rules for the popover animation start keyframe
*/
export declare function getStartPosition(offset: Offset, placement: PopoverPlacement, arrowSize: number, popoverMargin: number): string;
/**
* Returns CSS rules for the popover animation end keyframe
*/
export declare function getEndPosition(offset: Offset): string;
/**
* Returns top/left styles to position the popover arrow
*/
export declare function getArrowPositionStyles(offsets: Offset, placement: PopoverPlacement): {
[x: string]: string;
};