@lanyue/react-object-viewer
Version:
A flexible and lightweight object viewer component for React.
51 lines (49 loc) • 1.6 kB
TypeScript
import { ReactNode } from 'react';
import { getType } from './utils';
export declare enum Sort {
DEFAULT = 0,
DESC = 1,
ASC = 2
}
type Type = ReturnType<typeof getType>;
export type RenderValueFn = (type: Type, descriptor: TypedPropertyDescriptor<any>, o: {
level: number;
expand: boolean;
canExpand: boolean;
loadGetter: () => any;
setExpand: (expand: boolean) => void;
getValueString: typeof getValueString;
DefaultRenderValue: typeof RenderItemValue;
}) => ReactNode;
interface CtxType {
showLine: boolean;
showLevel: number;
showItems: number;
showInlineMax: number;
showIcon: boolean;
hideNonEnumerability: boolean;
sort: Sort;
canClickLabelExtend?: boolean;
renderValue?: RenderValueFn;
renderTypeIcon?: (type: Type, descriptor: TypedPropertyDescriptor<any>, level: number, DefaultIcon: typeof RenderTypeIcon) => ReactNode;
}
declare function getValueString({ type, descriptor }: {
type: Type;
descriptor: TypedPropertyDescriptor<any>;
}): string;
declare function RenderTypeIcon({ type }: {
type: Type;
descriptor: TypedPropertyDescriptor<any>;
}): import("react/jsx-runtime").JSX.Element | null;
declare function RenderItemValue(props: {
type: Type;
descriptor: TypedPropertyDescriptor<any>;
loadGetter: () => void;
}): import("react/jsx-runtime").JSX.Element;
export declare function ObjectViewer(props: {
value: any;
header?: ReactNode;
footer?: ReactNode;
attrs?: React.ComponentProps<'div'>;
} & Partial<CtxType>): import("react/jsx-runtime").JSX.Element;
export {};