import type { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, ErrorInfo, ReactNode } from 'react'; import { GrSystem } from 'react-icons/gr'; import { ErrorSuspenseBoundary as _ErrorSuspenseBoundary, Image as _Image, Link as _Link } from '../../components'; import { defineComponent, type ContextComponentType } from '../../components/ComponentProvider'; import { EmptyPlaceholder as _EmptyPlaceholder } from '../../components/formats/EmptyPlaceholder'; import { LoadingIndicator as _LoadingIndicator } from '../../loader'; enum ConsoleComponentName { SiteLogo = 'SiteLogo', LoadingIndicator = 'LoadingIndicator', EmptyPlaceholder = 'EmptyPlaceholder', ErrorSuspenseBoundary = 'ErrorSuspenseBoundary', Image = 'Image', Link = 'Link', } export type SiteLogoProps = ComponentPropsWithoutRef<'svg'>; type SiteLogo = ContextComponentType; export const SiteLogo = defineComponent({ name: ConsoleComponentName.SiteLogo, Component: GrSystem, }); export type LoadingIndicatorProps = ComponentPropsWithoutRef<'div'> & { title?: ReactNode; error?: Error; }; type LoadingIndicator = ContextComponentType; export const LoadingIndicator = defineComponent({ name: ConsoleComponentName.LoadingIndicator, Component: _LoadingIndicator, }); export type EmptyPlaceholderProps = Omit, 'as'> & { as?: E; children?: ReactNode; }; type EmptyPlaceholder = ContextComponentType>; export const EmptyPlaceholder = defineComponent({ name: ConsoleComponentName.EmptyPlaceholder, Component: _EmptyPlaceholder, }); export type ErrorSuspenseBoundaryProps = { fallback?: ReactNode; children: ReactNode; title?: ReactNode; onError?: (e: { error: Error; errorInfo: ErrorInfo }) => void; }; type ErrorSuspenseBoundary = ContextComponentType; export const ErrorSuspenseBoundary = defineComponent({ name: ConsoleComponentName.ErrorSuspenseBoundary, Component: _ErrorSuspenseBoundary, }); export type ImageProps = ComponentPropsWithRef<'img'>; export const Image = defineComponent({ name: ConsoleComponentName.Image, Component: _Image, }); export type LinkProps = Omit, 'href'> & { as?: E; href: string; }; type Link = ContextComponentType>; export const Link = defineComponent({ name: ConsoleComponentName.Link, Component: _Link, }); export const ConsoleComponent = { SiteLogo, LoadingIndicator, EmptyPlaceholder, ErrorSuspenseBoundary, Image, Link, } as const;