import { type ComponentPropsWithRef, type ComponentPropsWithoutRef, type ElementType } from 'react'; export type AsProp = { /** * An override of the default HTML tag. * Can also be another React component. */ as?: As; }; /** * Allows for extending a set of props (`ExtendedProps`) by an overriding set of props * (`OverrideProps`), ensuring that any duplicates are overridden by the overriding * set of props. */ export type ExtendableProps = OverrideProps & Omit; /** * Allows for inheriting the props from the specified element type so that * props like children, className & style work, as well as element-specific * attributes like aria roles. The component (`C`) must be passed in. */ export type InheritableElementProps = ExtendableProps, Props>; /** * A more sophisticated version of `InheritableElementProps` where * the passed in `as` prop will determine which props can be included */ export type PolymorphicComponentProps = InheritableElementProps>; /** * Utility type to extract the `ref` prop from a polymorphic component */ export type PolymorphicRef = ComponentPropsWithRef['ref']; export type RefProps = { /** * A ref to the root element. */ ref?: PolymorphicRef; }; /** * A wrapper of `PolymorphicComponentProps` that also includes the `ref` * prop for the polymorphic component */ export type PolymorphicComponentPropsWithRef = PolymorphicComponentProps & RefProps; /** * A type that represents the exclusive props of `T` and `U`. * * Example usage: * * ```typescript * type A = { a: string, b: number }; * type B = { b: string, c: boolean }; * * type ExclusiveAB = Exclusive; * * // ExclusiveAB will be either: * // { a: string, b: number, c?: undefined } * // or * // { b: string, c: boolean, a?: undefined } * ``` */ export type Exclusive = (T & { [K in keyof U]?: undefined; }) | (U & { [K in keyof T]?: undefined; }); export type SetTimeoutReturn = ReturnType;