import type { ElementType, ReactNode } from "react"; import type { EmptyStateProps, FilteredEmptyStateProps } from "../EmptyState/EmptyStateProps"; /** Failed-load panel (`role="alert"`); `onRetry` adds an outline Retry button, `action` adds more. */ export interface ErrorStateProps { /** Defaults to "Couldn't load this". */ title?: string; /** Defaults to a generic "something went wrong, try again" line. */ description?: string; /** Icon component in the error-tinted badge; defaults to AlertTriangle. */ icon?: ElementType; /** Renders an outline Retry button; omit it and no retry button appears. */ onRetry?: () => void; /** Retry button text; defaults to "Retry". */ retryLabel?: string; /** Puts the Retry button in its loading state; no effect without `onRetry`. */ isRetrying?: boolean; /** Extra node(s) rendered after the Retry button. */ action?: ReactNode; /** Passed to EmptyState; defaults to "md". */ size?: EmptyStateProps["size"]; /** Minimum height of the panel, passed to EmptyState. */ minH?: EmptyStateProps["minH"]; } /** Copy for the no-access panel; each field falls back to a generic default. */ export interface QueryStateForbiddenProps { /** Defaults to "You don't have access". */ title?: string; /** Defaults to a line asking the reader to request access. */ description?: string; /** Defaults to a lock icon. */ icon?: ElementType; /** Node(s) under the description, e.g. a "Request access" button. */ action?: ReactNode; } /** Picks loading → forbidden → error → empty → children; `children` may be a function so data is read only when ready. */ export interface QueryStateBoundaryProps { /** Checked first — wins over forbidden, error and empty — unless `hasData` is true. */ isLoading?: boolean; /** Shown after loading, before error (e.g. HTTP 403); a function is only called when `error` is set. */ isForbidden?: boolean | ((error: unknown) => boolean); /** Copy and action for the no-access panel (`role="status"`, never error-tinted). */ forbidden?: QueryStateForbiddenProps; /** True keeps children on screen during a refetch instead of the loading state. Default false. */ hasData?: boolean; /** Anything except undefined, null or false shows the error state — so 0 and "" count. */ error?: unknown; /** Checked only after loading and error are ruled out. */ isEmpty?: boolean; /** With `isEmpty`, shows FilteredEmptyState instead of `empty`/`emptyFallback`: the list is empty because of the filters, not first-run. */ isFiltered?: boolean; /** Props for the FilteredEmptyState shown when `isEmpty` and `isFiltered`; `scale="card"` drops the boundary's `minH`. */ filteredEmpty?: FilteredEmptyStateProps; /** Replaces the default skeleton rows. */ loadingFallback?: ReactNode; /** Replaces the default EmptyState entirely; `empty` is then ignored. */ emptyFallback?: ReactNode; /** Props for the default EmptyState; ignored when `emptyFallback` is set. */ empty?: EmptyStateProps; /** Overrides ErrorState's default title. */ errorTitle?: string; /** Static text, or a function of the error to derive it; ErrorState's default when omitted. */ errorDescription?: string | ((error: unknown) => string); /** Adds a Retry button to the error state. */ onRetry?: () => void; /** Shows the Retry button spinner; no effect without `onRetry`. */ isRetrying?: boolean; /** Min height of the error and empty states, not loading; defaults to "24rem". */ minH?: EmptyStateProps["minH"]; /** Content for the ready state; pass a function to read data only when it exists. */ children: ReactNode | (() => ReactNode); }