UNPKG

@coreui/react-pro

Version:

UI Components Library for React.js

47 lines (46 loc) 2.25 kB
import React from 'react'; /** * Gets all focusable child elements within a container. * Uses a comprehensive selector to find elements that can receive focus. * @param element - The container element to search within * @returns Array of focusable HTML elements */ export declare const focusableChildren: (element: HTMLElement) => HTMLElement[]; /** * Extracts the ref from a React element, handling version differences between React 18 and 19+. * * In React 18 and earlier, refs are stored directly on the element object. * In React 19+, refs are stored in the element's props object due to changes in React's internals. * This function automatically detects the React version and uses the appropriate access pattern. * @param child - The React element to extract the ref from * @returns The ref attached to the element, or undefined if no ref is present */ export declare const getChildRef: (child: React.ReactElement) => React.Ref<HTMLElement> | undefined; /** * Checks if an element is disabled. * Considers various ways an element can be disabled including CSS classes and attributes. * @param element - The HTML element to check * @returns True if the element is disabled, false otherwise */ export declare const isDisabled: (element: HTMLElement) => boolean; /** * Type guard to check if an object is an Element. * Handles edge cases including jQuery objects. * @param object - The object to check * @returns True if the object is an Element, false otherwise */ export declare const isElement: (object: unknown) => object is Element; /** * Checks if an element is visible in the DOM. * Considers client rects and computed visibility styles, handling edge cases like details elements. * @param element - The HTML element to check for visibility * @returns True if the element is visible, false otherwise */ export declare const isVisible: (element: HTMLElement) => boolean; /** * Merges multiple React refs into a single ref callback. * Handles both function refs and ref objects, gracefully ignoring failures. * @param refs - Array of React refs to merge * @returns A ref callback that applies to all provided refs */ export declare const mergeRefs: <T>(...refs: (React.Ref<T> | undefined)[]) => (node: T) => void;