diff --git a/dev-server/src/index.js b/dev-server/src/index.js
index 229ae0e..2d5b1fa 100644
--- a/dev-server/src/index.js
+++ b/dev-server/src/index.js
@@ -137,7 +137,7 @@ ReactDom.render(
- {/*demo array support*/}
+ {/* demo array support */}
+
+ {/* Custom buttons according to the value type */}
+ { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ integer: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: (element) => element.src === 27
+ ?
+ : ,
+ viewBox: (element) => element.src === 27
+ ? '0 0 15 15'
+ : '0 0 40 40',
+ title: (element) => element.src === 27
+ ? 'Special title'
+ : 'Example title',
+ className: (element) => element.src === 27
+ ? 'special-class'
+ : 'class-example'
+ },
+ float: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ bigNumber: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ date: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ string: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: (element) => element.variableName === 'string-key-test'
+ ?
+ : ,
+ viewBox: (element) => element.variableName === 'string-key-test'
+ ?'0 0 1792 1792'
+ :'0 0 40 40',
+ title: (element) => element.variableName === 'string-key-test'
+ ? 'Special title'
+ : 'Title example',
+ className: (element) => element.variableName === 'string-key-test'
+ ? 'special-class'
+ : 'class-example'
+ },
+ regexp: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ array: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ empty_array: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ object: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ empty_object: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ function: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ undefined: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ null: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ nan: {
+ clickCallback: (element) => { console.log(JSON.stringify(element, null, 4)) },
+ path: ,
+ viewBox: '0 0 40 40',
+ title: 'A title example',
+ className: 'class-example'
+ },
+ }}
+ onEdit={e => {
+ console.log('edit callback', e)
+ if (e.new_value == 'error') {
+ return false
+ }
+ }}
+ onDelete={e => {
+ console.log('delete callback', e)
+ }}
+ onAdd={e => {
+ console.log('add callback', e)
+ if (e.new_value == 'error') {
+ return false
+ }
+ }}
+ onSelect={e => {
+ console.log('select callback', e)
+ console.log(e.namespace)
+ }}
+ displayObjectSize={true}
+ name={'custom-buttons'}
+ enableClipboard={copy => {
+ console.log('you copied to clipboard!', copy)
+ }}
+ shouldCollapse={({ src, namespace, type }) => {
+ if (type === 'array' && src.indexOf('test') > -1) {
+ return true
+ } else if (namespace.indexOf('moment') > -1) {
+ return true
+ }
+ return false
+ }}
+ defaultValue=''
+ />
,
document.getElementById('app-container')
)
@@ -320,3 +486,35 @@ function getExampleArray () {
function getExampleWithStringEscapeSequences () {
return { '\\\n\t\r\f\\n': '\\\n\t\r\f\\n' }
}
+
+function getExampleJson5 () {
+ return {
+ string: 'this is a test string',
+ 'string-key-test': 'this is another test string',
+ integer: 42,
+ 'integer-key-test': 27,
+ empty_array: [],
+ empty_object: {},
+ array: [1, 2, 3, 'test'],
+ float: -2.757,
+ undefined_var: undefined,
+ parent: {
+ sibling1: true,
+ sibling2: false,
+ sibling3: null,
+ sibling4: NaN,
+ isString: value => {
+ if (typeof value === 'string') {
+ return 'string'
+ } else {
+ return 'other'
+ }
+ }
+ },
+ string_number: '1234',
+ date: new Date(),
+ moment: Moment(),
+ regexp: /[0-9]/gi,
+ bigNumber: new BigNumber('0.0060254656709730629123'),
+ }
+}
diff --git a/docs/src/js/components/Demo.js b/docs/src/js/components/Demo.js
index 7ba5dac..8fa9edd 100644
--- a/docs/src/js/components/Demo.js
+++ b/docs/src/js/components/Demo.js
@@ -175,9 +175,9 @@ class Demo extends React.PureComponent {
`}
)}
-
-