Skip to content

Commit c999da6

Browse files
authored
Merge pull request #118 from storybookjs/next
Next release
2 parents 9ae745d + 1ad3565 commit c999da6

File tree

14 files changed

+4668
-3250
lines changed

14 files changed

+4668
-3250
lines changed

.babelrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
{
66
"targets": {
77
"browsers": ["ie >= 11"]
8-
}
8+
},
9+
"loose": false
910
}
1011
],
1112
"@babel/preset-react"
1213
],
1314
"plugins": [
1415
"@babel/plugin-syntax-bigint",
15-
"@babel/plugin-proposal-class-properties",
16+
["@babel/plugin-proposal-class-properties", { "loose": false }],
1617
"@babel/plugin-proposal-do-expressions",
1718
"@babel/plugin-proposal-export-default-from",
1819
"@babel/plugin-proposal-logical-assignment-operators",

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ gh-pages/
88
dist
99
build
1010
*.log
11+
storybook-static

.storybook/addons.js

Whitespace-only changes.

.storybook/config.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

.storybook/main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
stories: ['../stories/*.*'],
5+
webpackFinal: (config, {configType}) => {
6+
if (configType !== 'PRODUCTION') {
7+
config.module.rules.push({
8+
test: /\.(js|jsx)$/,
9+
loaders: ['react-hot-loader'],
10+
include: [path.join(__dirname, 'src')],
11+
});
12+
}
13+
14+
return config;
15+
},
16+
};

.storybook/webpack.config.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

README.md

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,79 @@
11
# react-inspector
22

3-
[![build status](https://img.shields.io/travis/xyc/react-inspector/master.svg?style=flat-square)](https://travis-ci.org/xyc/react-inspector)
3+
[![build status](https://img.shields.io/travis/storybookjs/react-inspector/master.svg?style=flat-square)](https://travis-ci.org/storybookjs/react-inspector)
44
[![npm version](https://img.shields.io/npm/v/react-inspector.svg?style=flat-square)](https://www.npmjs.com/package/react-inspector)
55
[![npm downloads](https://img.shields.io/npm/dm/react-inspector.svg?style=flat-square)](https://www.npmjs.com/package/react-inspector)
66

7-
Power of [Browser DevTools](https://developers.google.com/web/tools/chrome-devtools/) inspectors right inside your React app. Check out the [interactive playground](http://xyc.github.io/react-inspector/) or [storybook](http://react-inspector.netlify.com).
7+
Power of [Browser DevTools](https://developers.google.com/web/tools/chrome-devtools/) inspectors right inside your React app. Check out the [interactive playground](https://storybookjs.github.io/react-inspector/) or [storybook](https://react-inspector.netlify.com).
88

9-
![](http://xyc.github.io/react-inspector/objectinspector.png)
9+
![''](https://storybookjs.github.io/react-inspector/objectinspector.png)
1010

11-
![](https://cldup.com/XhNGcBq9h2.png)
11+
![''](https://cldup.com/XhNGcBq9h2.png)
1212

13-
![](http://xyc.github.io/react-inspector/tableinspector.png)
13+
![''](https://storybookjs.github.io/react-inspector/tableinspector.png)
1414

1515
## Install
1616

1717
NPM:
18+
1819
```sh
1920
npm install react-inspector
2021
```
2122

2223
Recommended versions:
24+
2325
- version `3.0.2`: If you are using React 16.8.4 or later.
24-
- version `2.3.1`: If you are using an ealier version of React.
26+
- version `2.3.1`: If you are using an earlier version of React.
27+
28+
## Getting started
2529

2630
### <Inspector />
31+
2732
A shorthand for the inspectors.
2833

2934
- `<Inspector/>` is equivalent to `<ObjectInspector>` or `<DOMInspector>` if inspecting a DOM Node.
3035
- `<Inspector table/>` is equivalent to `<TableInspector>`.
3136

3237
### &lt;ObjectInspector />
38+
3339
Like `console.log`. Consider this as a glorified version of `<pre>JSON.stringify(data, null, 2)</pre>`.
3440

35-
###### How it works
41+
#### How it works
42+
3643
Tree state is saved at root. If you click to expand some elements in the hierarchy, the state will be preserved after the element is unmounted.
3744

3845
#### API
46+
3947
The component accepts the following props:
4048

41-
#### `data: PropTypes.any`: the Javascript object you would like to inspect
49+
**`data: PropTypes.any`:** the Javascript object you would like to inspect
50+
51+
**`name: PropTypes.string`:** specify the optional name of the root node, default to `undefined`
4252

43-
#### `name: PropTypes.string`: specify the optional name of the root node, default to `undefined`
53+
**`expandLevel: PropTypes.number`:** an integer specifying to which level the tree should be initially expanded
4454

45-
#### `expandLevel: PropTypes.number`: an integer specifying to which level the tree should be initially expanded.
55+
**`expandPaths: PropTypes.oneOfType([PropTypes.string, PropTypes.array])`:** an array containing all the paths that should be expanded when the component is initialized, or a string of just one path
4656

47-
#### `expandPaths: PropTypes.oneOfType([PropTypes.string, PropTypes.array])`: an array containing all the paths that should be expanded when the component is initialized, or a string of just one path
48-
- The path string is similar to [JSONPath](http://goessner.net/articles/JsonPath/).
57+
- The path string is similar to [JSONPath](https://goessner.net/articles/JsonPath/).
4958
- It is a dot separated string like `$.foo.bar`. `$.foo.bar` expands the path `$.foo.bar` where `$` refers to the root node. Note that it only expands that single node (but not all its parents and the root node). Instead, you should use `expandPaths={['$', '$.foo', '$.foo.bar']}` to expand all the way to the `$.foo.bar` node.
5059
- You can refer to array index paths using `['$', '$.1']`
5160
- You can use wildcard to expand all paths on a specific level
5261
- For example, to expand all first level and second level nodes, use `['$', '$.*']` (equivalent to `expandLevel={2}`)
5362
- the results are merged with expandLevel
5463

55-
#### `showNonenumerable: PropTypes.bool`: show non-enumerable properties.
64+
**`showNonenumerable: PropTypes.bool`:** show non-enumerable properties
5665

57-
#### `sortObjectKeys: PropTypes.oneOfType([PropTypes.bool, PropTypes.func])`: Sort object keys with optional compare function.
66+
**`sortObjectKeys: PropTypes.oneOfType([PropTypes.bool, PropTypes.func])`:** Sort object keys with optional compare function
5867

5968
When `sortObjectKeys={true}` is provided, keys of objects are sorted in alphabetical order except for arrays.
6069

61-
#### `nodeRenderer: PropTypes.func`: Use a custom `nodeRenderer` to render the object properties (optional
70+
**`nodeRenderer: PropTypes.func`:** Use a custom `nodeRenderer` to render the object properties (optional)
71+
6272
- Instead of using the default `nodeRenderer`, you can provide a
6373
custom function for rendering object properties. The _default_
6474
nodeRender looks like this:
65-
```
75+
76+
```js
6677
import { ObjectRootLabel } from 'react-inspector'
6778
import { ObjectLabel } from 'react-inspector'
6879

@@ -73,20 +84,27 @@ When `sortObjectKeys={true}` is provided, keys of objects are sorted in alphabet
7384
```
7485

7586
### &lt;TableInspector />
87+
7688
Like `console.table`.
7789

7890
#### API
91+
7992
The component accepts the following props:
80-
#### `data: PropTypes.oneOfType([PropTypes.array, PropTypes.object])`: the Javascript object you would like to inspect, either an array or an object
8193

82-
#### `columns: PropTypes.array`: An array of the names of the columns you'd like to display in the table
94+
**`data: PropTypes.oneOfType([PropTypes.array, PropTypes.object])`:** the Javascript object you would like to inspect, either an array or an object
95+
96+
**`columns: PropTypes.array`:** An array of the names of the columns you'd like to display in the table
8397

8498
### &lt;DOMInspector />
99+
85100
#### API
101+
86102
The component accepts the following props:
87-
#### `data: PropTypes.object`: the DOM Node you would like to inspect
88103

89-
### Usage
104+
**`data: PropTypes.object`:** the DOM Node you would like to inspect
105+
106+
#### Usage
107+
90108
```js
91109
import {ObjectInspector, TableInspector} from 'react-inspector';
92110

@@ -109,35 +127,44 @@ ReactDOM.render(
109127
document.getElementById('root')
110128
);
111129
```
130+
112131
Try embedding the inspectors inside a component's render() method to provide a live view for its props/state (Works even better with hot reloading).
113132

114133
### More Examples
134+
115135
Check out the storybook for more examples.
136+
116137
```sh
117138
npm install && npm run storybook
118139
```
119-
Open http://localhost:9001/
140+
141+
Open [http://localhost:9001/](http://localhost:9001/)
120142

121143
## Theme
144+
122145
By specifying the `theme` prop you can customize the inspectors. `theme` prop can be
123146

124147
1. a string referring to a preset theme (`"chromeLight"` or `"chromeDark"`, default to `"chromeLight"`)
125-
2. or a custom object that provides the necessary variables. Checkout `src/styles/themes` for possible theming variables.
148+
2. or a custom object that provides the necessary variables. Checkout [`src/styles/themes`](https://github.com/storybookjs/react-inspector/tree/master/src/styles/themes) for possible theme variables.
149+
150+
**Example 1:** Using a preset theme:
126151

127-
Example 1: Using a preset theme:
128152
```js
129153
<Inspector theme="chromeDark" data={{a: 'a', b: 'b'}}/>
130154
```
131155

132-
Example 2: changing the tree node indentation by inheriting the chrome light theme:
156+
**Example 2:** changing the tree node indentation by inheriting the chrome light theme:
157+
133158
```js
134159
import { chromeLight } from 'react-inspector'
135160

136161
<Inspector theme={{...chromeLight, ...({ TREENODE_PADDING_LEFT: 20 })}} data={{a: 'a', b: 'b'}}/>
137162
```
138163

139164
## Roadmap
165+
140166
Type of inspectors:
167+
141168
- [x] Tree style
142169
- [x] common objects
143170
- [x] DOM nodes
@@ -146,9 +173,11 @@ Type of inspectors:
146173
- [ ] Group style
147174

148175
## Contribution
149-
Contribution is welcome. [Past contributors](https://github.com/xyc/react-inspector/graphs/contributors)
176+
177+
Contribution is welcome. [Past contributors](https://github.com/storybookjs/react-inspector/graphs/contributors)
150178

151179
## Additional
180+
152181
- If you intend to capture `console.log`s, you may want to look at [`console-feed`](https://www.npmjs.com/package/console-feed).
153182
- `react-object-inspector` package will be deprecated. `<ObjectInspector/>` is now part of the new package `react-inspector`.
154183
- Why inline style? [This document](https://github.com/erikras/react-redux-universal-hot-example/blob/master/docs/InlineStyles.md) summarizes it well.

package.json

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"module": "dist/es/react-inspector.js",
3535
"scripts": {
3636
"build": "rollup -c",
37-
"build-storybook": "build-storybook -o storybook-static",
38-
"chromatic": "CHROMATIC_APP_CODE=17yeg4lpa7q chromatic",
37+
"build-storybook": "build-storybook",
38+
"chromatic": "chromatic --project-token=17yeg4lpa7q",
3939
"clean": "rimraf dist",
4040
"lint": "eslint src --fix",
4141
"prerelease": "npm run lint && npm run test && npm run clean && npm run build",
@@ -46,51 +46,52 @@
4646
"test-watch": "npm run test -- --watch"
4747
},
4848
"dependencies": {
49-
"@babel/runtime": "^7.8.7",
50-
"is-dom": "^1.1.0",
51-
"prop-types": "^15.6.1"
49+
"@babel/runtime": "^7.0.0",
50+
"is-dom": "^1.0.0",
51+
"prop-types": "^15.0.0"
5252
},
5353
"devDependencies": {
54-
"@babel/cli": "^7.8.4",
55-
"@babel/core": "^7.8.7",
56-
"@babel/plugin-proposal-class-properties": "^7.8.3",
57-
"@babel/plugin-proposal-do-expressions": "^7.8.3",
58-
"@babel/plugin-proposal-export-default-from": "^7.8.3",
59-
"@babel/plugin-proposal-logical-assignment-operators": "^7.8.3",
60-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
61-
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
62-
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
54+
"@babel/cli": "^7.11.6",
55+
"@babel/core": "^7.11.6",
56+
"@babel/plugin-proposal-class-properties": "^7.10.4",
57+
"@babel/plugin-proposal-do-expressions": "^7.10.4",
58+
"@babel/plugin-proposal-export-default-from": "^7.10.4",
59+
"@babel/plugin-proposal-logical-assignment-operators": "^7.11.0",
60+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
61+
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
62+
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
6363
"@babel/plugin-syntax-bigint": "^7.8.3",
64-
"@babel/plugin-transform-object-assign": "^7.8.3",
65-
"@babel/plugin-transform-runtime": "^7.8.3",
66-
"@babel/preset-env": "^7.8.7",
67-
"@babel/preset-react": "^7.8.3",
68-
"@babel/register": "^7.8.6",
69-
"@storybook/react": "^5.3.14",
64+
"@babel/plugin-transform-object-assign": "^7.10.4",
65+
"@babel/plugin-transform-runtime": "^7.11.5",
66+
"@babel/preset-env": "^7.11.5",
67+
"@babel/preset-react": "^7.10.4",
68+
"@babel/register": "^7.11.5",
69+
"@storybook/react": "^6.0.21",
7070
"babel-eslint": "^10.1.0",
71-
"babel-loader": "^8.0.6",
72-
"core-js": "^3.6.4",
73-
"css-loader": "^3.4.2",
74-
"eslint": "^6.8.0",
75-
"eslint-plugin-jasmine": "^4.1.0",
76-
"eslint-plugin-react": "^7.19.0",
77-
"expect": "^25.1.0",
78-
"jest": "^25.1.0",
79-
"prettier": "^1.19.1",
80-
"react": "^16.13.0",
81-
"react-dom": "^16.13.0",
82-
"react-hot-loader": "^4.12.19",
83-
"react-test-renderer": "^16.13.0",
71+
"babel-loader": "^8.1.0",
72+
"chromatic": "^5.1.0",
73+
"core-js": "^3.6.5",
74+
"css-loader": "^4.3.0",
75+
"eslint": "^7.8.1",
76+
"eslint-plugin-jasmine": "^4.1.1",
77+
"eslint-plugin-react": "^7.20.6",
78+
"expect": "^26.4.2",
79+
"jest": "^26.4.2",
80+
"prettier": "^2.1.1",
81+
"react": "^16.13.1",
82+
"react-dom": "^16.13.1",
83+
"react-hot-loader": "^4.12.21",
84+
"react-test-renderer": "^16.13.1",
8485
"rimraf": "^3.0.2",
85-
"rollup": "^2.0.3",
86+
"rollup": "^2.26.11",
8687
"rollup-plugin-babel": "^4.4.0",
88+
"rollup-plugin-cleanup": "^3.1.1",
8789
"rollup-plugin-commonjs": "^10.1.0",
8890
"rollup-plugin-node-resolve": "^5.2.0",
89-
"storybook-chromatic": "^3.5.2",
90-
"style-loader": "^1.1.3",
91-
"webpack": "^4.42.0",
92-
"webpack-cli": "^3.3.11",
93-
"webpack-dev-server": "^3.10.3"
91+
"style-loader": "^1.2.1",
92+
"webpack": "^4.44.1",
93+
"webpack-cli": "^3.3.12",
94+
"webpack-dev-server": "^3.11.0"
9495
},
9596
"peerDependencies": {
9697
"react": "^16.8.4"

rollup.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import nodeResolve from 'rollup-plugin-node-resolve';
77
import babel from 'rollup-plugin-babel';
88
import commonjs from 'rollup-plugin-commonjs';
9+
import cleanup from 'rollup-plugin-cleanup';
910

1011
export default [
1112
{
@@ -26,6 +27,7 @@ export default [
2627
include: 'node_modules/**',
2728
}),
2829
babel({ runtimeHelpers: true }),
30+
cleanup()
2931
],
3032
},
3133
{
@@ -46,6 +48,7 @@ export default [
4648
include: 'node_modules/**',
4749
}),
4850
babel({ runtimeHelpers: true }),
51+
cleanup()
4952
],
5053
},
5154
{
@@ -80,6 +83,7 @@ export default [
8083
],
8184
},
8285
}),
86+
cleanup()
8387
],
8488
},
8589
];

0 commit comments

Comments
 (0)