Skip to content

collapsed object with props names #406

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
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
`objectCollapsedMaxPropsCount`|`boolean` or `number`|`false`|When set to `true`, see object props when object is collpased, number set max display props count

### 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=""
objectCollapsedMaxPropsCount={4}
/>

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

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

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

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

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

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

<JsonViewer
Expand All @@ -167,6 +174,7 @@ ReactDom.render(
name="large_array"
groupArraysAfterLength={50}
src={getExampleJson4()}
objectCollapsedMaxPropsCount={true}
/>
</div>,
document.getElementById('app-container')
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
*/
objectCollapsedMaxPropsCount?: number | boolean;
}

export interface OnCopyProps {
Expand Down
Loading