@vtex/admin-ui
Version:
> VTEX admin component library
58 lines (57 loc) • 1.54 kB
TypeScript
import type { Dispatch } from 'react';
/**
* Keeps the state of the DataView component
* @example
* const view = useDataViewState()
*
* <DataView state={view} />
*/
export declare function useDataViewState(initialState?: DataViewStatusObject): DataViewState;
export interface DataViewStatusObject {
loading: boolean;
notFound: NotFoundState | null;
error: ErrorState | null;
empty: EmptyState | null;
}
export declare type DataViewStatus = 'ready' | 'loading' | 'not-found' | 'empty' | 'error';
export declare type DataViewStatusDispatch = Dispatch<Action>;
export interface DataViewState {
status: DataViewStatus;
statusObject: DataViewStatusObject;
setStatus: DataViewStatusDispatch;
}
interface NotFoundState {
message: string;
suggestion?: string;
}
interface ErrorState {
message: string;
action?: {
text: string;
onClick: () => void;
href?: string;
} | {
text: string;
href: string;
onClick?: () => void;
};
}
interface EmptyState {
message: string;
action?: {
text: string;
onClick: () => void;
href?: string;
} | {
text: string;
href: string;
onClick?: () => void;
};
}
declare type AliasedState<T, S> = {
type: T;
} & S;
declare type Action = {
type: 'ready' | 'loading';
} | AliasedState<'not-found', NotFoundState> | AliasedState<'error', ErrorState> | AliasedState<'empty', EmptyState>;
export {};