Skip to content

Commit 76fb252

Browse files
committed
merging with master
2 parents 0862e76 + 001cce5 commit 76fb252

39 files changed

+3984
-1251
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Name|Type|Default|Description
4848
`indentWidth`|`integer`|4|Set the indent-width for nested objects
4949
`collapsed`|`boolean` or `integer`|`false`|When set to `true`, all nodes will be collapsed by default. Use an integer value to collapse at a particular depth.
5050
`collapseStringsAfterLength`|`integer`|`false`|When an integer value is assigned, strings will be cut off at that length. Collapsed strings are followed by an ellipsis. String content can be expanded and collapsed by clicking on the string value.
51+
`shouldCollapse`|`(field)=>{}`|`false`|Callback function to provide control over what objects and arrays should be collapsed by default. An object is passed to the callback containing `name`, `src`, `type` ("array" or "object") and `namespace`.
5152
`groupArraysAfterLength`|`integer`|`100`|When an integer value is assigned, arrays will be displayed in groups by count of the value. Groups are displayed with brakcet notation and can be expanded and collapsed by clickong on the brackets.
5253
`enableClipboard`|`boolean` or `(copy)=>{}`|`true`|When prop is not `false`, the user can copy objects and arrays to clipboard by clicking on the clipboard icon. Copy callbacks are supported.
5354
`displayObjectSize`|`boolean`|`true`|When set to `true`, objects and arrays are labeled with size

demo/dist/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="en">
33
<head>
44
<title>RJV Demo</title>
5+
<meta name="keywords" content="array-viewer,base-16,component,interactive,interactive-json,json,json-component,json-display,json-tree,json-view,json-viewer,json-inspector,json-tree,react,react-component,react-json,theme,tree,tree-view,treeview,mac-s-g">
56
<meta charset="UTF-8">
67
<link rel="icon"
78
type="image/ico"

demo/dist/main.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev-server/src/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import React from "react"
55
import ReactDom from "react-dom"
66

7+
import Moment from "moment"
8+
79
//import the react-json-view component (installed with npm)
810
import JsonViewer from "./../../src/js/index"
911

@@ -45,6 +47,14 @@ ReactDom.render(
4547
enableClipboard={copy => {
4648
console.log("you copied to clipboard!", copy)
4749
}}
50+
shouldCollapse={({ src, namespace, type }) => {
51+
if (type === "array" && src.indexOf("test") > -1) {
52+
return true
53+
} else if (namespace.indexOf("moment") > -1) {
54+
return true
55+
}
56+
return false
57+
}}
4858
/>
4959

5060
<br />
@@ -72,6 +82,10 @@ ReactDom.render(
7282
}}
7383
name={false}
7484
iconStyle="triangle"
85+
shouldCollapse={({ src, type }) =>
86+
type === "object" &&
87+
src.constructor &&
88+
src.constructor.name === "Moment"}
7589
/>
7690

7791
<br />
@@ -126,6 +140,8 @@ ReactDom.render(
126140
<JsonViewer
127141
enableClipboard={false}
128142
src={getExampleJson1()}
143+
shouldCollapse={({ src, namespace, type }) =>
144+
namespace.indexOf("moment") > -1}
129145
theme={{
130146
base00: "white",
131147
base01: "#ddd",
@@ -188,7 +204,9 @@ function getExampleJson1() {
188204
}
189205
},
190206
string_number: "1234",
191-
date: new Date()
207+
date: new Date(),
208+
moment: Moment(),
209+
regexp: /[0-9]/gi
192210
}
193211
}
194212

0 commit comments

Comments
 (0)