UNPKG

@redheadphone/react-json-grid

Version:

React Component that converts JSON to nested grid tables.

57 lines (53 loc) 1.62 kB
import React from 'react'; type keyPathNode = string | string[] | number | number[]; interface JSONGridProps { data: JSONObject; defaultExpandDepth?: number; defaultExpandKeyTree?: JSONObject; onSelect?: (keyPath: keyPathNode[]) => void; highlightSelected?: boolean; searchText?: string | null; theme?: string; customTheme?: Theme; } declare global { type keyPathNode = keyPathNode; type JSONGridProps = JSONGridProps; interface JSONObject { [key: string]: any; } interface NestedGridProps { level: number; keyPath: keyPathNode[]; dataKey?: string; data: JSONObject; highlightedElement: HTMLElement | null; highlightSelected: boolean; onSelect: (keyPath: keyPathNode[]) => void; setHighlightedElement: (element: HTMLElement | null) => void; defaultExpandDepth: number; defaultExpandKeyTree: JSONObject; searchText: string | null; } interface Theme { bgColor?: string; borderColor?: string; selectHighlightBgColor?: string; cellBorderColor?: string; keyColor?: string; indexColor?: string; numberColor?: string; booleanColor?: string; stringColor?: string; objectColor?: string; tableHeaderBgColor?: string; tableIconColor?: string; searchHighlightBgColor?: string; } interface Themes { [key: string]: Theme; } } declare const JSONGrid: React.FC<JSONGridProps>; export { JSONGrid as default }; export type { JSONGridProps, keyPathNode };