UNPKG

@trail-ui/react

Version:
67 lines (64 loc) 3.68 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { DOMProps as DOMProps$1, AriaLabelingProps } from '@react-types/shared'; import react__default, { CSSProperties, ReactNode, ForwardedRef, RefCallback, RefObject, Ref } from 'react'; declare function forwardRef<T, P = object>(render: (props: P, ref: react__default.Ref<T>) => react__default.ReactElement | null): (props: P & react__default.RefAttributes<T>) => react__default.ReactElement | null; type forwardRefType = typeof forwardRef; interface StyleProps { /** The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. */ className?: string; /** The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. */ style?: CSSProperties; } interface DOMProps extends StyleProps { /** The children of the component. */ children?: ReactNode; } interface StyleRenderProps<T> { /** The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. */ className?: string | ((values: T) => string); /** The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. */ style?: CSSProperties | ((values: T) => CSSProperties); } interface RenderProps<T> extends StyleRenderProps<T> { /** The children of the component. A function may be provided to alter the children based on component state. */ children?: ReactNode | ((values: T) => ReactNode); } interface RenderPropsHookOptions<T> extends RenderProps<T>, DOMProps$1, AriaLabelingProps { values: T; defaultChildren?: ReactNode; defaultClassName?: string; } declare function useRenderProps<T>(props: RenderPropsHookOptions<T>): { className: string | undefined; style: react__default.CSSProperties | undefined; children: react__default.ReactNode; 'data-rac': string; }; type WithRef<T, E> = T & { ref?: ForwardedRef<E>; }; declare function useSlot(): [RefCallback<Element>, boolean]; declare function useEnterAnimation(ref: RefObject<HTMLElement>, isReady?: boolean): boolean; declare function useExitAnimation(ref: RefObject<HTMLElement>, isOpen: boolean): boolean; declare const HiddenContext: react__default.Context<boolean>; declare function Hidden(props: { children: ReactNode; }): react_jsx_runtime.JSX.Element; declare function createHideableComponent<T, P = object>(fn: (props: P, ref: react__default.Ref<T>) => react__default.ReactElement | null): (props: P & react__default.RefAttributes<T>) => react__default.ReactElement | null; /** * Filters out `data-*` attributes to keep them from being passed down and duplicated. * @param props */ declare function removeDataAttributes<T>(props: T): T; declare function useDOMRef<T extends HTMLElement = HTMLElement>(ref?: RefObject<T | null> | Ref<T | null>): react__default.RefObject<T>; interface RACValidation { /** * Whether to use native HTML form validation to prevent form submission * when the value is missing or invalid, or mark the field as required * or invalid via ARIA. * @default 'native' */ validationBehavior?: 'native' | 'aria'; } declare function replaceSpacesWithHyphens(str: string): string; export { DOMProps, Hidden, HiddenContext, RACValidation, RenderProps, StyleProps, StyleRenderProps, WithRef, createHideableComponent, forwardRefType, removeDataAttributes, replaceSpacesWithHyphens, useDOMRef, useEnterAnimation, useExitAnimation, useRenderProps, useSlot };