Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collapsed object with props names #406

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![npm](https://img.shields.io/npm/v/react-json-view.svg)](https://www.npmjs.com/package/react-json-view) [![npm](https://img.shields.io/npm/l/react-json-view.svg)](https://github.com/mac-s-g/react-json-view/blob/master/LISCENSE) [![Build Status](https://travis-ci.org/mac-s-g/react-json-view.svg)](https://travis-ci.org/mac-s-g/react-json-view) [![Coverage Status](https://coveralls.io/repos/github/mac-s-g/react-json-view/badge.svg?branch=master)](https://coveralls.io/github/mac-s-g/react-json-view?branch=master)

# react-json-view
# react-json-view-2
RJV is a React component for displaying and editing javascript **arrays** and **JSON objects**.

This component provides a responsive interface for displaying arrays or JSON in a web browser. NPM offers a distribution of the source that's transpiled to ES5; so you can include this component with *any web-based javascript application*.
Expand All @@ -12,8 +12,8 @@ This component provides a responsive interface for displaying arrays or JSON in

### Implementation Example
```js
// import the react-json-view component
import ReactJson from 'react-json-view'
// import the react-json-view-2 component
import ReactJson from 'react-json-view-2'

// use the component in your app!
<ReactJson src={my_json_object} />
Expand All @@ -28,12 +28,12 @@ import ReactJson from 'react-json-view'
### Installation Instructions
Install this component with [NPM](https://www.npmjs.com/package/react-json-view).
```shell
npm install --save react-json-view
npm install --save react-json-view-2
```
Or add to your package.json config file:
```json
"dependencies": {
"react-json-view": "latest"
"react-json-view-2": "latest"
}
```

Expand Down Expand Up @@ -62,6 +62,7 @@ Name|Type|Default|Description
`quotesOnKeys`|`boolean`|`true`|set to false to remove quotes from keys (eg. `"name":` vs. `name:`)
`validationMessage`|`string`|"Validation Error"|Custom message for validation failures to `onEdit`, `onAdd`, or `onDelete` callbacks
`displayArrayKey`|`boolean`|`true`|When set to `true`, the index of the elements prefix values
`objectCollpasedMaxPropsCount`|`boolean` or `intiger`|`false`|When set to `true`, see object props when object is collpased, intiger set max display props count
zielinskipawel marked this conversation as resolved.
Show resolved Hide resolved

### Features
* `onEdit`, `onAdd` and `onDelete` props allow users to edit the `src` variable
Expand Down
8 changes: 8 additions & 0 deletions dev-server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ReactDom.render(
return false;
}}
defaultValue=""
objectCollpasedMaxPropsCount={4}
/>

<br />
Expand Down Expand Up @@ -84,6 +85,7 @@ ReactDom.render(
src.constructor &&
src.constructor.name === 'Moment'
}
objectCollpasedMaxPropsCount={4}
/>

<br />
Expand All @@ -95,6 +97,7 @@ ReactDom.render(
name={'feature_set'}
displayDataTypes={false}
indentWidth={2}
objectCollpasedMaxPropsCount={4}
/>

<br />
Expand All @@ -106,6 +109,7 @@ ReactDom.render(
name={'feature_set'}
displayDataTypes={false}
indentWidth={5}
objectCollpasedMaxPropsCount={4}
/>

<br />
Expand All @@ -119,6 +123,7 @@ ReactDom.render(
displayObjectSize={false}
displayDataTypes={false}
enableClipboard={false}
objectCollpasedMaxPropsCount={4}
/>

<br />
Expand All @@ -130,6 +135,7 @@ ReactDom.render(
onEdit={edit => {
console.log(edit);
}}
objectCollpasedMaxPropsCount={4}
/>

<br />
Expand Down Expand Up @@ -159,6 +165,7 @@ ReactDom.render(
base0E: 'rgba(70, 70, 230, 1)',
base0F: 'rgba(70, 70, 230, 1)'
}}
objectCollpasedMaxPropsCount={true}
/>

<JsonViewer
Expand All @@ -167,6 +174,7 @@ ReactDom.render(
name="large_array"
groupArraysAfterLength={50}
src={getExampleJson4()}
objectCollpasedMaxPropsCount={true}
/>
</div>,
document.getElementById('app-container')
Expand Down
4 changes: 2 additions & 2 deletions doc/example-usage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import ReactJson from 'react-json-view';
import ReactJson from 'react-json-view-2';

//you have some json to display
let my_important_json = {
Expand Down Expand Up @@ -31,7 +31,7 @@ let my_important_json = {


// ES6 with React
import ReactJson from 'react-json-view';
import ReactJson from 'react-json-view-2';

...
<ReactJson src={my_important_json} />
Expand Down
8 changes: 7 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ export interface ReactJsonViewProps {
*
* Default: null
*/
defaultValue?: TypeDefaultValue | TypeDefaultValue[] | null;
defaultValue?: TypeDefaultValue | TypeDefaultValue[] | null;
/**
* Set to a value to be used as see object props when object is collpased
*
* Default: null
*/
objectCollpasedMaxPropsCount?: number | boolean;
}

export interface OnCopyProps {
Expand Down
Loading