UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

43 lines (42 loc) 1.8 kB
import { Component, type ReactElement, type ReactNode } from "react"; import type { Callback } from "../../util/function.js"; import { type ButtonVariants } from "../form/Button.js"; import type { ChildProps, OptionalChildProps } from "../util/props.js"; export interface RetryButtonProps extends ButtonVariants, OptionalChildProps { } export declare function RetryButton({ children, ...props }: RetryButtonProps): ReactElement | null; export interface ErrorComponentProps { reason: unknown; } export interface CatcherProps extends ChildProps { /** Component to render an error (defaults to `<ErrorNotice />`) */ as: (props: ErrorComponentProps) => ReactElement; } type CatcherState = { /** The error that was caught. */ reason: unknown; }; /** * React component that provides an Error Boundary. * If an error occurs in any component under this, a general error will be shown to the user. */ export declare class Catcher extends Component<CatcherProps, CatcherState> { static defaultProps: Pick<CatcherProps, "as">; state: CatcherState; readonly retry: Callback; static getDerivedStateFromError(reason: unknown): CatcherState; render(): ReactNode; } export interface PageCatcherProps extends ChildProps { } /** Catch errors in a page. */ export declare function PageCatcher({ children }: PageCatcherProps): ReactElement; export interface ErrorNoticeProps extends ErrorComponentProps { } /** Output a `<Notice>` for an unknown error reason. */ export declare function ErrorNotice({ reason }: ErrorNoticeProps): ReactElement; export interface ErrorPageProps extends ErrorComponentProps { } /** Output a `<Page>` with an error `<Card>` for an unknown error reason. */ export declare function ErrorPage({ reason }: ErrorPageProps): ReactElement; export {};