import { ReactNode } from 'react'; type OnScreenReactNode = Exclude; /** * Renders a UI component by returning a React component, or `false`, if nothing should be rendered. * * @returns {(React.FC|false)} Returns a React component to render, or `false`, if nothing should be rendered. */ type ComponentFactory = ( ...args: TComponentFactoryArguments ) => ((props?: TProps) => OnScreenReactNode) | false; /** * Enhances a UI component through decoration, replacement, or removal. */ type ComponentEnhancer = ( next: ComponentFactory ) => ComponentFactory; /** * Middleware for rendering a UI component. * * The middleware is a series of enhancers that are chained through functional composition. Each enhancer can: * * - Decorate: call the next enhancer to get its React component, then decorate it through UI composition * - Replace: return a React component without calling the next enhancer * - Remove: return `false` without calling the next enhancer * * The signature of the middleware is: * * ``` * (...args: SetupArguments) => (next: Enhancer) => (...args: ComponentFactoryArguments) => false | React.FC * ``` */ type ComponentMiddleware = ( ...args: TSetupArguments ) => ComponentEnhancer; export default ComponentMiddleware; export { ComponentEnhancer, ComponentFactory };