mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-22 06:00:07 +03:00
Cleanup
This commit is contained in:
parent
5175bc0a00
commit
4c60c7d75a
|
@ -1,4 +1,4 @@
|
|||
import React from 'react';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import JSONArrow from './JSONArrow';
|
||||
import type { CircularCache, CommonInternalProps } from './types';
|
||||
|
||||
|
@ -9,43 +9,31 @@ interface Props extends CommonInternalProps {
|
|||
to: number;
|
||||
renderChildNodes: (props: Props, from: number, to: number) => React.ReactNode;
|
||||
circularCache: CircularCache;
|
||||
level: number;
|
||||
}
|
||||
|
||||
interface State {
|
||||
expanded: boolean;
|
||||
}
|
||||
export default function ItemRange(props: Props) {
|
||||
const { styling, from, to, renderChildNodes, nodeType } = props;
|
||||
|
||||
export default class ItemRange extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = { expanded: false };
|
||||
}
|
||||
const [expanded, setExpanded] = useState<boolean>(false);
|
||||
const handleClick = useCallback(() => {
|
||||
setExpanded(!expanded);
|
||||
}, [expanded]);
|
||||
|
||||
render() {
|
||||
const { styling, from, to, renderChildNodes, nodeType } = this.props;
|
||||
|
||||
return this.state.expanded ? (
|
||||
<div {...styling('itemRange', this.state.expanded)}>
|
||||
{renderChildNodes(this.props, from, to)}
|
||||
return expanded ? (
|
||||
<div {...styling('itemRange', expanded)}>
|
||||
{renderChildNodes(props, from, to)}
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
{...styling('itemRange', this.state.expanded)}
|
||||
onClick={this.handleClick}
|
||||
>
|
||||
<div {...styling('itemRange', expanded)} onClick={handleClick}>
|
||||
<JSONArrow
|
||||
nodeType={nodeType}
|
||||
styling={styling}
|
||||
expanded={false}
|
||||
onClick={this.handleClick}
|
||||
onClick={handleClick}
|
||||
arrowStyle="double"
|
||||
/>
|
||||
{`${from} ... ${to}`}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
handleClick = () => {
|
||||
this.setState({ expanded: !this.state.expanded });
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ interface Props extends CommonInternalProps {
|
|||
}
|
||||
|
||||
// Configures <JSONNestedNode> to render an Array
|
||||
const JSONArrayNode: React.FunctionComponent<Props> = ({ data, ...props }) => (
|
||||
export default function JSONArrayNode({ data, ...props }: Props) {
|
||||
return (
|
||||
<JSONNestedNode
|
||||
{...props}
|
||||
data={data}
|
||||
|
@ -26,5 +27,4 @@ const JSONArrayNode: React.FunctionComponent<Props> = ({ data, ...props }) => (
|
|||
expandable={data.length > 0}
|
||||
/>
|
||||
);
|
||||
|
||||
export default JSONArrayNode;
|
||||
}
|
||||
|
|
|
@ -9,13 +9,14 @@ interface Props {
|
|||
onClick: React.MouseEventHandler<HTMLDivElement>;
|
||||
}
|
||||
|
||||
const JSONArrow: React.FunctionComponent<Props> = ({
|
||||
export default function JSONArrow({
|
||||
styling,
|
||||
arrowStyle = 'single',
|
||||
expanded,
|
||||
nodeType,
|
||||
onClick,
|
||||
}) => (
|
||||
}: Props) {
|
||||
return (
|
||||
<div {...styling('arrowContainer', arrowStyle)} onClick={onClick}>
|
||||
<div {...styling(['arrow', 'arrowSign'], nodeType, expanded, arrowStyle)}>
|
||||
{'\u25B6'}
|
||||
|
@ -25,5 +26,4 @@ const JSONArrow: React.FunctionComponent<Props> = ({
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default JSONArrow;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ interface Props extends CommonInternalProps {
|
|||
}
|
||||
|
||||
// Configures <JSONNestedNode> to render an iterable
|
||||
const JSONIterableNode: React.FunctionComponent<Props> = ({ ...props }) => {
|
||||
export default function JSONIterableNode(props: Props) {
|
||||
return (
|
||||
<JSONNestedNode
|
||||
{...props}
|
||||
|
@ -38,6 +38,4 @@ const JSONIterableNode: React.FunctionComponent<Props> = ({ ...props }) => {
|
|||
expandable
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default JSONIterableNode;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ export interface RenderChildNodesProps extends CommonInternalProps {
|
|||
data: any;
|
||||
nodeType: string;
|
||||
circularCache: CircularCache;
|
||||
level: number;
|
||||
}
|
||||
|
||||
interface Range {
|
||||
|
|
|
@ -8,10 +8,9 @@ import type { CommonInternalProps } from './types';
|
|||
|
||||
interface Props extends CommonInternalProps {
|
||||
value: any;
|
||||
isCustomNode: (value: any) => boolean;
|
||||
}
|
||||
|
||||
const JSONNode: React.FunctionComponent<Props> = ({
|
||||
export default function JSONNode({
|
||||
getItemString,
|
||||
keyPath,
|
||||
labelRenderer,
|
||||
|
@ -20,7 +19,7 @@ const JSONNode: React.FunctionComponent<Props> = ({
|
|||
valueRenderer,
|
||||
isCustomNode,
|
||||
...rest
|
||||
}) => {
|
||||
}: Props) {
|
||||
const nodeType = isCustomNode(value) ? 'Custom' : objType(value);
|
||||
|
||||
const simpleNodeProps = {
|
||||
|
@ -100,6 +99,4 @@ const JSONNode: React.FunctionComponent<Props> = ({
|
|||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default JSONNode;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ interface Props extends CommonInternalProps {
|
|||
}
|
||||
|
||||
// Configures <JSONNestedNode> to render an Object
|
||||
const JSONObjectNode: React.FunctionComponent<Props> = ({ data, ...props }) => (
|
||||
export default function JSONObjectNode({ data, ...props }: Props) {
|
||||
return (
|
||||
<JSONNestedNode
|
||||
{...props}
|
||||
data={data}
|
||||
|
@ -25,5 +26,4 @@ const JSONObjectNode: React.FunctionComponent<Props> = ({ data, ...props }) => (
|
|||
expandable={Object.getOwnPropertyNames(data).length > 0}
|
||||
/>
|
||||
);
|
||||
|
||||
export default JSONObjectNode;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ interface Props {
|
|||
valueGetter?: (value: any) => any;
|
||||
}
|
||||
|
||||
const JSONValueNode: React.FunctionComponent<Props> = ({
|
||||
export default function JSONValueNode({
|
||||
nodeType,
|
||||
styling,
|
||||
labelRenderer,
|
||||
|
@ -32,7 +32,8 @@ const JSONValueNode: React.FunctionComponent<Props> = ({
|
|||
valueRenderer,
|
||||
value,
|
||||
valueGetter = (value) => value,
|
||||
}) => (
|
||||
}: Props) {
|
||||
return (
|
||||
<li {...styling('value', nodeType, keyPath)}>
|
||||
<label {...styling(['label', 'valueLabel'], nodeType, keyPath)}>
|
||||
{labelRenderer(keyPath, nodeType, false, false)}
|
||||
|
@ -42,5 +43,4 @@ const JSONValueNode: React.FunctionComponent<Props> = ({
|
|||
</span>
|
||||
</li>
|
||||
);
|
||||
|
||||
export default JSONValueNode;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import type { CurriedFunction1 } from 'lodash';
|
||||
import {
|
||||
import { createStyling } from 'react-base16-styling';
|
||||
import type {
|
||||
Base16Theme,
|
||||
createStyling,
|
||||
StylingConfig,
|
||||
StylingFunction,
|
||||
Theme,
|
||||
} from 'react-base16-styling';
|
||||
import solarized from './themes/solarized';
|
||||
import { StylingFunction, Theme } from 'react-base16-styling/src';
|
||||
|
||||
const colorMap = (theme: Base16Theme) => ({
|
||||
BACKGROUND_COLOR: theme.base00,
|
||||
|
|
|
@ -74,4 +74,4 @@ export function JSONTree({
|
|||
);
|
||||
}
|
||||
|
||||
export { StylingValue };
|
||||
export type { StylingValue };
|
||||
|
|
|
@ -58,6 +58,6 @@ export interface CommonExternalProps {
|
|||
export interface CommonInternalProps extends CommonExternalProps {
|
||||
styling: StylingFunction;
|
||||
circularCache?: CircularCache;
|
||||
isCircular?: boolean;
|
||||
level?: number;
|
||||
isCircular?: boolean;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user