mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-22 06:00:07 +03:00
Fix types
This commit is contained in:
parent
99acb5b040
commit
9968ab38dc
|
@ -1,14 +1,15 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import JSONArrow from './JSONArrow';
|
import JSONArrow from './JSONArrow';
|
||||||
import { CircularPropsPassedThroughItemRange } from './types';
|
import type { CircularCache, CommonInternalProps } from './types';
|
||||||
|
|
||||||
interface Props extends CircularPropsPassedThroughItemRange {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: any;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
from: number;
|
from: number;
|
||||||
to: number;
|
to: number;
|
||||||
renderChildNodes: (props: Props, from: number, to: number) => React.ReactNode;
|
renderChildNodes: (props: Props, from: number, to: number) => React.ReactNode;
|
||||||
|
circularCache: CircularCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import JSONNestedNode from './JSONNestedNode';
|
import JSONNestedNode from './JSONNestedNode';
|
||||||
import { CircularPropsPassedThroughJSONNode } from './types';
|
import type { CommonInternalProps } from './types';
|
||||||
|
|
||||||
// Returns the "n Items" string for this node,
|
// Returns the "n Items" string for this node,
|
||||||
// generating and caching it if it hasn't been created yet.
|
// generating and caching it if it hasn't been created yet.
|
||||||
|
@ -11,7 +11,7 @@ function createItemString(data: any) {
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends CircularPropsPassedThroughJSONNode {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: any;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { StylingFunction } from 'react-base16-styling';
|
import type { StylingFunction } from 'react-base16-styling';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
styling: StylingFunction;
|
styling: StylingFunction;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import JSONNestedNode from './JSONNestedNode';
|
import JSONNestedNode from './JSONNestedNode';
|
||||||
import { CircularPropsPassedThroughJSONNode } from './types';
|
import type { CommonInternalProps } from './types';
|
||||||
|
|
||||||
// Returns the "n Items" string for this node,
|
// Returns the "n Items" string for this node,
|
||||||
// generating and caching it if it hasn't been created yet.
|
// generating and caching it if it hasn't been created yet.
|
||||||
|
@ -22,7 +22,7 @@ function createItemString(data: any, limit: number) {
|
||||||
return `${hasMore ? '>' : ''}${count} ${count !== 1 ? 'entries' : 'entry'}`;
|
return `${hasMore ? '>' : ''}${count} ${count !== 1 ? 'entries' : 'entry'}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends CircularPropsPassedThroughJSONNode {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: any;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,19 +4,16 @@ import JSONArrow from './JSONArrow';
|
||||||
import getCollectionEntries from './getCollectionEntries';
|
import getCollectionEntries from './getCollectionEntries';
|
||||||
import JSONNode from './JSONNode';
|
import JSONNode from './JSONNode';
|
||||||
import ItemRange from './ItemRange';
|
import ItemRange from './ItemRange';
|
||||||
import {
|
import type { CircularCache, CommonInternalProps } from './types';
|
||||||
CircularPropsPassedThroughJSONNestedNode,
|
|
||||||
CircularPropsPassedThroughRenderChildNodes,
|
|
||||||
} from './types';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders nested values (eg. objects, arrays, lists, etc.)
|
* Renders nested values (eg. objects, arrays, lists, etc.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface RenderChildNodesProps
|
export interface RenderChildNodesProps extends CommonInternalProps {
|
||||||
extends CircularPropsPassedThroughRenderChildNodes {
|
|
||||||
data: any;
|
data: any;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
|
circularCache: CircularCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Range {
|
interface Range {
|
||||||
|
@ -89,12 +86,14 @@ function renderChildNodes(
|
||||||
return childNodes;
|
return childNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends CircularPropsPassedThroughJSONNestedNode {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: any;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
nodeTypeIndicator: string;
|
nodeTypeIndicator: string;
|
||||||
createItemString: (data: any, collectionLimit: number) => string;
|
createItemString: (data: any, collectionLimit: number) => string;
|
||||||
expandable: boolean;
|
expandable: boolean;
|
||||||
|
circularCache: CircularCache;
|
||||||
|
level: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface State {
|
interface State {
|
||||||
|
|
|
@ -5,10 +5,9 @@ import JSONObjectNode from './JSONObjectNode';
|
||||||
import JSONArrayNode from './JSONArrayNode';
|
import JSONArrayNode from './JSONArrayNode';
|
||||||
import JSONIterableNode from './JSONIterableNode';
|
import JSONIterableNode from './JSONIterableNode';
|
||||||
import JSONValueNode from './JSONValueNode';
|
import JSONValueNode from './JSONValueNode';
|
||||||
import { CircularPropsPassedThroughJSONNode } from './types';
|
import type { CommonInternalProps, KeyPath } from './types';
|
||||||
|
|
||||||
interface Props extends CircularPropsPassedThroughJSONNode {
|
interface Props extends CommonInternalProps {
|
||||||
keyPath: (string | number)[];
|
|
||||||
value: any;
|
value: any;
|
||||||
isCustomNode: (value: any) => boolean;
|
isCustomNode: (value: any) => boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import JSONNestedNode from './JSONNestedNode';
|
import JSONNestedNode from './JSONNestedNode';
|
||||||
import { CircularPropsPassedThroughJSONNode } from './types';
|
import type { CommonInternalProps } from './types';
|
||||||
|
|
||||||
// Returns the "n Items" string for this node,
|
// Returns the "n Items" string for this node,
|
||||||
// generating and caching it if it hasn't been created yet.
|
// generating and caching it if it hasn't been created yet.
|
||||||
|
@ -10,7 +10,7 @@ function createItemString(data: any) {
|
||||||
return `${len} ${len !== 1 ? 'keys' : 'key'}`;
|
return `${len} ${len !== 1 ? 'keys' : 'key'}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends CircularPropsPassedThroughJSONNode {
|
interface Props extends CommonInternalProps {
|
||||||
data: any;
|
data: any;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { JSONValueNodeCircularPropsProvidedByJSONNode } from './types';
|
import type {
|
||||||
|
GetItemString,
|
||||||
|
Key,
|
||||||
|
KeyPath,
|
||||||
|
LabelRenderer,
|
||||||
|
Styling,
|
||||||
|
ValueRenderer,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders simple values (eg. strings, numbers, booleans, etc)
|
* Renders simple values (eg. strings, numbers, booleans, etc)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface Props extends JSONValueNodeCircularPropsProvidedByJSONNode {
|
interface Props {
|
||||||
|
getItemString: GetItemString;
|
||||||
|
key: Key;
|
||||||
|
keyPath: KeyPath;
|
||||||
|
labelRenderer: LabelRenderer;
|
||||||
nodeType: string;
|
nodeType: string;
|
||||||
|
styling: Styling;
|
||||||
value: any;
|
value: any;
|
||||||
|
valueRenderer: ValueRenderer;
|
||||||
valueGetter?: (value: any) => any;
|
valueGetter?: (value: any) => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import type { SortObjectKeys } from './types';
|
||||||
|
|
||||||
function getLength(type: string, collection: any) {
|
function getLength(type: string, collection: any) {
|
||||||
if (type === 'Object') {
|
if (type === 'Object') {
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
@ -16,7 +18,7 @@ function isIterableMap(collection: any) {
|
||||||
function getEntries(
|
function getEntries(
|
||||||
type: string,
|
type: string,
|
||||||
collection: any,
|
collection: any,
|
||||||
sortObjectKeys?: ((a: any, b: any) => number) | boolean | undefined,
|
sortObjectKeys: SortObjectKeys,
|
||||||
from = 0,
|
from = 0,
|
||||||
to = Infinity
|
to = Infinity
|
||||||
): { entries: { key: string | number; value: any }[]; hasMore?: boolean } {
|
): { entries: { key: string | number; value: any }[]; hasMore?: boolean } {
|
||||||
|
@ -96,7 +98,7 @@ function getRanges(from: number, to: number, limit: number) {
|
||||||
export default function getCollectionEntries(
|
export default function getCollectionEntries(
|
||||||
type: string,
|
type: string,
|
||||||
collection: any,
|
collection: any,
|
||||||
sortObjectKeys: ((a: any, b: any) => number) | boolean | undefined,
|
sortObjectKeys: SortObjectKeys,
|
||||||
limit: number,
|
limit: number,
|
||||||
from = 0,
|
from = 0,
|
||||||
to = Infinity
|
to = Infinity
|
||||||
|
|
|
@ -8,34 +8,29 @@ import JSONNode from './JSONNode';
|
||||||
import createStylingFromTheme from './createStylingFromTheme';
|
import createStylingFromTheme from './createStylingFromTheme';
|
||||||
import { invertTheme } from 'react-base16-styling';
|
import { invertTheme } from 'react-base16-styling';
|
||||||
import type { StylingValue, Theme } from 'react-base16-styling';
|
import type { StylingValue, Theme } from 'react-base16-styling';
|
||||||
import { CircularPropsPassedThroughJSONTree } from './types';
|
import type {
|
||||||
|
CommonExternalProps,
|
||||||
|
GetItemString,
|
||||||
|
IsCustomNode,
|
||||||
|
LabelRenderer,
|
||||||
|
ShouldExpandNode,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
interface Props extends CircularPropsPassedThroughJSONTree {
|
interface Props extends Partial<CommonExternalProps> {
|
||||||
data: any;
|
data: any;
|
||||||
theme?: Theme;
|
theme?: Theme;
|
||||||
invertTheme: boolean;
|
invertTheme?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const identity = (value: any) => value;
|
const identity = (value: any) => value;
|
||||||
const expandRootNode = (
|
const expandRootNode: ShouldExpandNode = (keyPath, data, level) => level === 0;
|
||||||
keyPath: (string | number)[],
|
const defaultItemString: GetItemString = (type, data, itemType, itemString) => (
|
||||||
data: any,
|
|
||||||
level: number
|
|
||||||
) => level === 0;
|
|
||||||
const defaultItemString = (
|
|
||||||
type: string,
|
|
||||||
data: any,
|
|
||||||
itemType: React.ReactNode,
|
|
||||||
itemString: string
|
|
||||||
) => (
|
|
||||||
<span>
|
<span>
|
||||||
{itemType} {itemString}
|
{itemType} {itemString}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
const defaultLabelRenderer = ([label]: (string | number)[]) => (
|
const defaultLabelRenderer: LabelRenderer = ([label]) => <span>{label}:</span>;
|
||||||
<span>{label}:</span>
|
const noCustomNode: IsCustomNode = () => false;
|
||||||
);
|
|
||||||
const noCustomNode = () => false;
|
|
||||||
|
|
||||||
export function JSONTree({
|
export function JSONTree({
|
||||||
data: value,
|
data: value,
|
||||||
|
@ -50,7 +45,7 @@ export function JSONTree({
|
||||||
postprocessValue = identity,
|
postprocessValue = identity,
|
||||||
isCustomNode = noCustomNode,
|
isCustomNode = noCustomNode,
|
||||||
collectionLimit = 50,
|
collectionLimit = 50,
|
||||||
sortObjectKeys,
|
sortObjectKeys = false,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const styling = useMemo(
|
const styling = useMemo(
|
||||||
() =>
|
() =>
|
||||||
|
|
|
@ -1,81 +1,63 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { StylingFunction } from 'react-base16-styling';
|
import { StylingFunction } from 'react-base16-styling';
|
||||||
|
|
||||||
interface SharedCircularPropsPassedThroughJSONTree {
|
export type Key = string | number;
|
||||||
keyPath: (string | number)[];
|
|
||||||
labelRenderer: (
|
|
||||||
keyPath: (string | number)[],
|
|
||||||
nodeType: string,
|
|
||||||
expanded: boolean,
|
|
||||||
expandable: boolean
|
|
||||||
) => React.ReactNode;
|
|
||||||
}
|
|
||||||
interface SharedCircularPropsProvidedByJSONTree
|
|
||||||
extends SharedCircularPropsPassedThroughJSONTree {
|
|
||||||
styling: StylingFunction;
|
|
||||||
}
|
|
||||||
interface JSONValueNodeCircularPropsPassedThroughJSONTree {
|
|
||||||
valueRenderer: (
|
|
||||||
valueAsString: any,
|
|
||||||
value: any,
|
|
||||||
...keyPath: (string | number)[]
|
|
||||||
) => React.ReactNode;
|
|
||||||
}
|
|
||||||
export type JSONValueNodeCircularPropsProvidedByJSONNode =
|
|
||||||
SharedCircularPropsProvidedByJSONTree &
|
|
||||||
JSONValueNodeCircularPropsPassedThroughJSONTree;
|
|
||||||
|
|
||||||
interface JSONNestedNodeCircularPropsPassedThroughJSONTree {
|
export type KeyPath = (string | number)[];
|
||||||
shouldExpandNode: (
|
|
||||||
keyPath: (string | number)[],
|
export type GetItemString = (
|
||||||
data: any,
|
nodeType: string,
|
||||||
level: number
|
data: any,
|
||||||
) => boolean;
|
itemType: React.ReactNode,
|
||||||
|
itemString: string,
|
||||||
|
keyPath: KeyPath
|
||||||
|
) => React.ReactNode;
|
||||||
|
|
||||||
|
export type LabelRenderer = (
|
||||||
|
keyPath: KeyPath,
|
||||||
|
nodeType: string,
|
||||||
|
expanded: boolean,
|
||||||
|
expandable: boolean
|
||||||
|
) => React.ReactNode;
|
||||||
|
|
||||||
|
export type ValueRenderer = (
|
||||||
|
valueAsString: any,
|
||||||
|
value: any,
|
||||||
|
...keyPath: KeyPath
|
||||||
|
) => React.ReactNode;
|
||||||
|
|
||||||
|
export type ShouldExpandNode = (
|
||||||
|
keyPath: KeyPath,
|
||||||
|
data: any,
|
||||||
|
level: number
|
||||||
|
) => boolean;
|
||||||
|
|
||||||
|
export type PostprocessValue = (value: any) => any;
|
||||||
|
|
||||||
|
export type IsCustomNode = (value: any) => boolean;
|
||||||
|
|
||||||
|
export type SortObjectKeys = ((a: any, b: any) => number) | boolean;
|
||||||
|
|
||||||
|
export type Styling = StylingFunction;
|
||||||
|
|
||||||
|
export type CircularCache = any[];
|
||||||
|
|
||||||
|
export interface CommonExternalProps {
|
||||||
|
keyPath: KeyPath;
|
||||||
|
labelRenderer: LabelRenderer;
|
||||||
|
valueRenderer: ValueRenderer;
|
||||||
|
shouldExpandNode: ShouldExpandNode;
|
||||||
hideRoot: boolean;
|
hideRoot: boolean;
|
||||||
getItemString: (
|
getItemString: GetItemString;
|
||||||
nodeType: string,
|
postprocessValue: PostprocessValue;
|
||||||
data: any,
|
isCustomNode: IsCustomNode;
|
||||||
itemType: React.ReactNode,
|
|
||||||
itemString: string,
|
|
||||||
keyPath: (string | number)[]
|
|
||||||
) => React.ReactNode;
|
|
||||||
postprocessValue: (value: any) => any;
|
|
||||||
isCustomNode: (value: any) => boolean;
|
|
||||||
collectionLimit: number;
|
collectionLimit: number;
|
||||||
sortObjectKeys?: ((a: any, b: any) => number) | boolean;
|
sortObjectKeys: SortObjectKeys;
|
||||||
}
|
}
|
||||||
export type CircularPropsPassedThroughJSONTree =
|
|
||||||
SharedCircularPropsPassedThroughJSONTree &
|
|
||||||
JSONValueNodeCircularPropsPassedThroughJSONTree &
|
|
||||||
JSONNestedNodeCircularPropsPassedThroughJSONTree;
|
|
||||||
|
|
||||||
interface JSONNestedNodeCircularPropsPassedThroughJSONNode
|
export interface CommonInternalProps extends CommonExternalProps {
|
||||||
extends JSONNestedNodeCircularPropsPassedThroughJSONTree {
|
styling: StylingFunction;
|
||||||
circularCache?: any[];
|
circularCache?: CircularCache;
|
||||||
isCircular?: boolean;
|
isCircular?: boolean;
|
||||||
level?: number;
|
level?: number;
|
||||||
}
|
}
|
||||||
export type CircularPropsPassedThroughJSONNode =
|
|
||||||
SharedCircularPropsProvidedByJSONTree &
|
|
||||||
JSONValueNodeCircularPropsPassedThroughJSONTree &
|
|
||||||
JSONNestedNodeCircularPropsPassedThroughJSONNode;
|
|
||||||
|
|
||||||
export interface JSONNestedNodeCircularPropsPassedThroughJSONNestedNode
|
|
||||||
extends JSONNestedNodeCircularPropsPassedThroughJSONNode {
|
|
||||||
circularCache: any[];
|
|
||||||
level: number;
|
|
||||||
}
|
|
||||||
export type CircularPropsPassedThroughJSONNestedNode =
|
|
||||||
SharedCircularPropsProvidedByJSONTree &
|
|
||||||
JSONValueNodeCircularPropsPassedThroughJSONTree &
|
|
||||||
JSONNestedNodeCircularPropsPassedThroughJSONNestedNode;
|
|
||||||
|
|
||||||
export type CircularPropsPassedThroughRenderChildNodes =
|
|
||||||
SharedCircularPropsProvidedByJSONTree &
|
|
||||||
JSONValueNodeCircularPropsPassedThroughJSONTree &
|
|
||||||
JSONNestedNodeCircularPropsPassedThroughJSONNestedNode;
|
|
||||||
|
|
||||||
export type CircularPropsPassedThroughItemRange =
|
|
||||||
SharedCircularPropsProvidedByJSONTree &
|
|
||||||
JSONValueNodeCircularPropsPassedThroughJSONTree &
|
|
||||||
JSONNestedNodeCircularPropsPassedThroughJSONNestedNode;
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user