@heroui/form
Version:
A form is a group of inputs that allows users submit data to a server and supports field validation errors.
44 lines (41 loc) • 2.17 kB
text/typescript
import { CSSProperties, ReactNode, ForwardedRef, Context, MutableRefObject } from 'react';
import { DOMProps as DOMProps$1, RefObject } from '@react-types/shared';
declare const DEFAULT_SLOT: unique symbol;
interface SlottedValue<T> {
slots?: Record<string | symbol, T>;
}
type WithRef<T, E> = T & {
ref?: ForwardedRef<E>;
};
type SlottedContextValue<T> = SlottedValue<T> | T | null | undefined;
type ContextValue<T, E> = SlottedContextValue<WithRef<T, E>>;
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, DOMProps$1 {
/** The children of the component. */
children?: ReactNode;
}
interface SlotProps {
/**
* A slot name for the component. Slots allow the component to receive props from a parent component.
* An explicit `null` value indicates that the local props completely override all props received from a parent.
*/
slot?: string | null;
}
/**
* Offers an object ref for a given callback ref or an object ref. Especially
* helfpul when passing forwarded refs (created using `React.forwardRef`) to
* React Aria hooks.
*
* @param ref The original ref intended to be used.
* @returns An object ref that updates the given ref.
* @see https://react.dev/reference/react/forwardRef
*/
declare function useObjectRef<T>(ref?: ((instance: T | null) => (() => void) | void) | MutableRefObject<T | null> | null): MutableRefObject<T | null>;
declare function useSlottedContext<T>(context: Context<SlottedContextValue<T>>, slot?: string | null): T | null | undefined;
declare function useContextProps<T, U extends SlotProps, E extends Element>(props: T & SlotProps, ref: ForwardedRef<E>, context: Context<ContextValue<U, E>>): [T, RefObject<E | null>];
export { type ContextValue, DEFAULT_SLOT, type DOMProps, type SlotProps, type SlottedContextValue, type StyleProps, type WithRef, useContextProps, useObjectRef, useSlottedContext };