mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 08:30:02 +03:00
react-json-tree
This commit is contained in:
parent
00462b10ce
commit
4c0f527329
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"presets": [
|
|
||||||
["@babel/preset-env", { "targets": "defaults", "modules": false }],
|
|
||||||
"@babel/preset-react",
|
|
||||||
"@babel/preset-typescript"
|
|
||||||
],
|
|
||||||
"plugins": ["@babel/plugin-transform-runtime"]
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"presets": [
|
|
||||||
["@babel/preset-env", { "targets": "defaults" }],
|
|
||||||
"@babel/preset-react",
|
|
||||||
"@babel/preset-typescript"
|
|
||||||
],
|
|
||||||
"plugins": ["@babel/plugin-transform-runtime"]
|
|
||||||
}
|
|
12
packages/react-json-tree/jest.config.cjs
Normal file
12
packages/react-json-tree/jest.config.cjs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
module.exports = {
|
||||||
|
extensionsToTreatAsEsm: ['.ts', '.tsx'],
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^(\\.{1,2}/.*)\\.js$': '$1',
|
||||||
|
},
|
||||||
|
transform: {
|
||||||
|
'^.+\\.tsx?$': [
|
||||||
|
'ts-jest',
|
||||||
|
{ tsconfig: 'tsconfig.test.json', useESM: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
|
@ -1,7 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
preset: 'ts-jest',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }],
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: ['node_modules/(?!.pnpm|react-base16-styling)'],
|
|
||||||
};
|
|
|
@ -22,47 +22,29 @@
|
||||||
"lib",
|
"lib",
|
||||||
"src"
|
"src"
|
||||||
],
|
],
|
||||||
"main": "lib/cjs/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "lib/esm/index.js",
|
"types": "lib/index.d.ts",
|
||||||
"types": "lib/types/index.d.ts",
|
"type": "module",
|
||||||
"unpkg": "lib/umd/react-json-tree.umd.js",
|
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/reduxjs/redux-devtools.git"
|
"url": "https://github.com/reduxjs/redux-devtools.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "pnpm run build:cjs && pnpm run build:esm && pnpm run build:types && pnpm run build:umd",
|
"build": "tsc",
|
||||||
"build:cjs": "babel src --extensions \".ts,.tsx\" --out-dir lib/cjs",
|
|
||||||
"build:esm": "babel src --config-file ./babel.config.esm.json --extensions \".ts,.tsx\" --out-dir lib/esm",
|
|
||||||
"build:types": "tsc --emitDeclarationOnly",
|
|
||||||
"build:umd": "rollup -c",
|
|
||||||
"clean": "rimraf lib",
|
"clean": "rimraf lib",
|
||||||
"test": "jest",
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
||||||
"lint": "eslint . --ext .ts,.tsx",
|
"lint": "eslint . --ext .ts,.tsx",
|
||||||
"type-check": "tsc --noEmit",
|
"type-check": "tsc --noEmit",
|
||||||
"prepack": "pnpm run clean && pnpm run build",
|
"prepack": "pnpm run clean && pnpm run build",
|
||||||
"prepublish": "pnpm run type-check && pnpm run lint && pnpm run test"
|
"prepublish": "pnpm run lint && pnpm run test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.24.1",
|
|
||||||
"@types/lodash": "^4.17.0",
|
"@types/lodash": "^4.17.0",
|
||||||
"react-base16-styling": "^0.9.1"
|
"react-base16-styling": "^0.9.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.24.1",
|
|
||||||
"@babel/core": "^7.24.3",
|
|
||||||
"@babel/eslint-parser": "^7.24.1",
|
|
||||||
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
||||||
"@babel/preset-env": "^7.24.3",
|
|
||||||
"@babel/preset-react": "^7.24.1",
|
|
||||||
"@babel/preset-typescript": "^7.24.1",
|
|
||||||
"@rollup/plugin-babel": "^6.0.4",
|
|
||||||
"@rollup/plugin-commonjs": "^25.0.7",
|
|
||||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^20.11.30",
|
|
||||||
"@types/react": "^18.2.72",
|
"@types/react": "^18.2.72",
|
||||||
"@types/react-test-renderer": "^18.0.7",
|
"@types/react-test-renderer": "^18.0.7",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
||||||
|
@ -76,10 +58,8 @@
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-test-renderer": "^18.2.0",
|
"react-test-renderer": "^18.2.0",
|
||||||
"rimraf": "^5.0.5",
|
"rimraf": "^5.0.5",
|
||||||
"rollup": "^4.13.0",
|
|
||||||
"rollup-plugin-typescript2": "^0.36.0",
|
"rollup-plugin-typescript2": "^0.36.0",
|
||||||
"ts-jest": "^29.1.2",
|
"ts-jest": "^29.1.2",
|
||||||
"tslib": "^2.6.2",
|
|
||||||
"typescript": "~5.3.3"
|
"typescript": "~5.3.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
import typescript from 'rollup-plugin-typescript2';
|
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
|
||||||
import commonjs from '@rollup/plugin-commonjs';
|
|
||||||
import babel from '@rollup/plugin-babel';
|
|
||||||
import terser from '@rollup/plugin-terser';
|
|
||||||
|
|
||||||
const config = [
|
|
||||||
{
|
|
||||||
input: 'src/index.tsx',
|
|
||||||
output: {
|
|
||||||
name: 'ReactJsonTree',
|
|
||||||
file: 'lib/umd/react-json-tree.js',
|
|
||||||
format: 'umd',
|
|
||||||
globals: {
|
|
||||||
react: 'React',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
typescript({
|
|
||||||
tsconfigOverride: { compilerOptions: { declaration: false } },
|
|
||||||
}),
|
|
||||||
resolve(),
|
|
||||||
commonjs(),
|
|
||||||
babel({
|
|
||||||
babelHelpers: 'runtime',
|
|
||||||
extensions: ['.ts', '.tsx'],
|
|
||||||
plugins: ['@babel/plugin-transform-runtime'],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
external: ['react'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: 'src/index.tsx',
|
|
||||||
output: {
|
|
||||||
name: 'ReactJsonTree',
|
|
||||||
file: 'lib/umd/react-json-tree.min.js',
|
|
||||||
format: 'umd',
|
|
||||||
globals: {
|
|
||||||
react: 'React',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
typescript({
|
|
||||||
tsconfigOverride: { compilerOptions: { declaration: false } },
|
|
||||||
}),
|
|
||||||
resolve(),
|
|
||||||
commonjs(),
|
|
||||||
babel({
|
|
||||||
babelHelpers: 'runtime',
|
|
||||||
extensions: ['.ts', '.tsx'],
|
|
||||||
plugins: ['@babel/plugin-transform-runtime'],
|
|
||||||
}),
|
|
||||||
terser(),
|
|
||||||
],
|
|
||||||
external: ['react'],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export default config;
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import JSONArrow from './JSONArrow';
|
import JSONArrow from './JSONArrow.js';
|
||||||
import type { CircularCache, CommonInternalProps } from './types';
|
import type { CircularCache, CommonInternalProps } from './types.js';
|
||||||
|
|
||||||
interface Props extends CommonInternalProps {
|
interface Props extends CommonInternalProps {
|
||||||
data: unknown;
|
data: unknown;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import JSONNestedNode from './JSONNestedNode';
|
import JSONNestedNode from './JSONNestedNode.js';
|
||||||
import type { CommonInternalProps } from './types';
|
import type { CommonInternalProps } from './types.js';
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import JSONNestedNode from './JSONNestedNode';
|
import JSONNestedNode from './JSONNestedNode.js';
|
||||||
import type { CommonInternalProps } from './types';
|
import type { CommonInternalProps } from './types.js';
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import JSONArrow from './JSONArrow';
|
import JSONArrow from './JSONArrow.js';
|
||||||
import getCollectionEntries from './getCollectionEntries';
|
import getCollectionEntries from './getCollectionEntries.js';
|
||||||
import JSONNode from './JSONNode';
|
import JSONNode from './JSONNode.js';
|
||||||
import ItemRange from './ItemRange';
|
import ItemRange from './ItemRange.js';
|
||||||
import type { CircularCache, CommonInternalProps } from './types';
|
import type { CircularCache, CommonInternalProps } from './types.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders nested values (eg. objects, arrays, lists, etc.)
|
* Renders nested values (eg. objects, arrays, lists, etc.)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import objType from './objType';
|
import objType from './objType.js';
|
||||||
import JSONObjectNode from './JSONObjectNode';
|
import JSONObjectNode from './JSONObjectNode.js';
|
||||||
import JSONArrayNode from './JSONArrayNode';
|
import JSONArrayNode from './JSONArrayNode.js';
|
||||||
import JSONIterableNode from './JSONIterableNode';
|
import JSONIterableNode from './JSONIterableNode.js';
|
||||||
import JSONValueNode from './JSONValueNode';
|
import JSONValueNode from './JSONValueNode.js';
|
||||||
import type { CommonInternalProps } from './types';
|
import type { CommonInternalProps } from './types.js';
|
||||||
|
|
||||||
interface Props extends CommonInternalProps {
|
interface Props extends CommonInternalProps {
|
||||||
value: unknown;
|
value: unknown;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import JSONNestedNode from './JSONNestedNode';
|
import JSONNestedNode from './JSONNestedNode.js';
|
||||||
import type { CommonInternalProps } from './types';
|
import type { CommonInternalProps } from './types.js';
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
@ -6,7 +6,7 @@ import type {
|
||||||
LabelRenderer,
|
LabelRenderer,
|
||||||
Styling,
|
Styling,
|
||||||
ValueRenderer,
|
ValueRenderer,
|
||||||
} from './types';
|
} from './types.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders simple values (eg. strings, numbers, booleans, etc)
|
* Renders simple values (eg. strings, numbers, booleans, etc)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import type {
|
||||||
StylingFunction,
|
StylingFunction,
|
||||||
Theme,
|
Theme,
|
||||||
} from 'react-base16-styling';
|
} from 'react-base16-styling';
|
||||||
import solarized from './themes/solarized';
|
import solarized from './themes/solarized.js';
|
||||||
|
|
||||||
const colorMap = (theme: Base16Theme) => ({
|
const colorMap = (theme: Base16Theme) => ({
|
||||||
BACKGROUND_COLOR: theme.base00,
|
BACKGROUND_COLOR: theme.base00,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { SortObjectKeys } from './types';
|
import type { SortObjectKeys } from './types.js';
|
||||||
|
|
||||||
function getLength(type: string, collection: unknown) {
|
function getLength(type: string, collection: unknown) {
|
||||||
if (type === 'Object') {
|
if (type === 'Object') {
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
// port by Daniele Zannotti http://www.github.com/dzannotti <dzannotti@me.com>
|
// port by Daniele Zannotti http://www.github.com/dzannotti <dzannotti@me.com>
|
||||||
|
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import JSONNode from './JSONNode';
|
|
||||||
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 JSONNode from './JSONNode.js';
|
||||||
|
import createStylingFromTheme from './createStylingFromTheme.js';
|
||||||
import type {
|
import type {
|
||||||
CommonExternalProps,
|
CommonExternalProps,
|
||||||
GetItemString,
|
GetItemString,
|
||||||
IsCustomNode,
|
IsCustomNode,
|
||||||
LabelRenderer,
|
LabelRenderer,
|
||||||
ShouldExpandNodeInitially,
|
ShouldExpandNodeInitially,
|
||||||
} from './types';
|
} from './types.js';
|
||||||
|
|
||||||
interface Props extends Partial<CommonExternalProps> {
|
interface Props extends Partial<CommonExternalProps> {
|
||||||
data: unknown;
|
data: unknown;
|
||||||
|
@ -86,5 +86,5 @@ export type {
|
||||||
SortObjectKeys,
|
SortObjectKeys,
|
||||||
Styling,
|
Styling,
|
||||||
CommonExternalProps,
|
CommonExternalProps,
|
||||||
} from './types';
|
} from './types.js';
|
||||||
export type { StylingValue };
|
export type { StylingValue };
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { createRenderer } from 'react-test-renderer/shallow';
|
import TestRenderer from 'react-test-renderer/shallow';
|
||||||
|
|
||||||
import { JSONTree } from '../src/index';
|
import { JSONTree } from '../src/index.js';
|
||||||
import JSONNode from '../src/JSONNode';
|
import JSONNode from '../src/JSONNode.js';
|
||||||
|
|
||||||
const BASIC_DATA = { a: 1, b: 'c' };
|
const BASIC_DATA = { a: 1, b: 'c' };
|
||||||
|
|
||||||
function render(component: React.ReactElement) {
|
function render(component: React.ReactElement) {
|
||||||
const renderer = createRenderer();
|
const renderer = TestRenderer.createRenderer();
|
||||||
renderer.render(component);
|
renderer.render(component);
|
||||||
return renderer.getRenderOutput();
|
return renderer.getRenderOutput();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import objType from '../src/objType';
|
import objType from '../src/objType.js';
|
||||||
|
|
||||||
describe('objType', () => {
|
describe('objType', () => {
|
||||||
it('should determine the correct type', () => {
|
it('should determine the correct type', () => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.react.base.json",
|
"extends": "../../tsconfig.esm.react.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "lib/types"
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": ["src"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"extends": "../../tsconfig.react.base.json",
|
"extends": "../../tsconfig.esm.react.base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"types": ["jest"]
|
"types": ["jest"]
|
||||||
},
|
},
|
||||||
|
|
6
tsconfig.esm.react.base.json
Normal file
6
tsconfig.esm.react.base.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.esm.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"jsx": "react"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user