import * as React from 'react'; export type GenericHTMLProps = React.HTMLAttributes & { ref?: React.Ref | undefined; }; export type AnchorUIEvent> = E & { preventAnchorUIHandler: () => void; }; type WithPreventAnchorUIHandler = T extends (event: infer E) => any ? E extends React.SyntheticEvent ? (event: AnchorUIEvent) => ReturnType : T : T extends undefined ? undefined : T; /** * Adds a `preventAnchorUIHandler` method to all event handlers. */ export type WithAnchorUIEvent = { [K in keyof T]: WithPreventAnchorUIHandler; }; /** * Shape of the render prop: a function that takes props to be spread on the element and component's state and returns a React element. * * @template Props Props to be spread on the rendered element. * @template State Component's internal state. */ export type ComponentRenderFn = (props: Props, state: State) => React.ReactElement; /** * Props shared by all Anchor UI components. * Contains `className` (string or callback taking the component's state as an argument) and `render` (function to customize rendering). */ export type AnchorUIComponentProps = Omit>, 'className'> & { /** * CSS class applied to the element, or a function that * returns a class based on the component’s state. */ className?: string | ((state: State) => string); /** * Allows you to replace the component’s HTML element * with a different tag, or compose it with another component. * * Accepts a `ReactElement` or a function that returns the element to render. */ render?: ComponentRenderFn | React.ReactElement>; }; /** * Simplifies the display of a type (without modifying it). * Taken from https://effectivetypescript.com/2022/02/25/gentips-4-display/ */ export type Simplify = T extends Function ? T : { [K in keyof T]: T[K]; }; export type RequiredExcept = Required> & Pick; export {};