1- import React from ' react' ;
2- import DataTypeLabel from ' ./DataTypeLabel' ;
1+ import React from " react"
2+ import DataTypeLabel from " ./DataTypeLabel"
33
44//theme
5- import Theme from ' ./../../themes/getStyle' ;
5+ import Theme from " ./../../themes/getStyle"
66
77//attribute store for storing collapsed state
8- import AttributeStore from ' ./../../stores/ObjectAttributes' ;
8+ import AttributeStore from " ./../../stores/ObjectAttributes"
99
1010export default class extends React . Component {
11-
1211 constructor ( props ) {
13- super ( props ) ;
12+ super ( props )
1413
1514 this . state . collapsed = AttributeStore . get (
1615 props . rjvId ,
1716 props . namespace ,
18- ' collapsed' ,
17+ " collapsed" ,
1918 true
20- ) ;
19+ )
2120 }
2221
2322 state = {
2423 collapsed : true
2524 }
2625
2726 toggleCollapsed = ( ) => {
28- this . state . collapsed = ! this . state . collapsed ;
27+ this . state . collapsed = ! this . state . collapsed
2928 AttributeStore . set (
3029 this . props . rjvId ,
3130 this . props . namespace ,
32- ' collapsed' ,
31+ " collapsed" ,
3332 this . state . collapsed
34- ) ;
35- this . setState ( this . state ) ;
33+ )
34+ this . setState ( this . state )
3635 }
3736
3837 render ( ) {
39- const type_name = ' function' ;
40- const { props} = this ;
41- const { collapsed} = this . state ;
38+ const type_name = " function"
39+ const { props } = this
40+ const { collapsed } = this . state
4241
4342 return (
44- < div { ...Theme ( props . theme , 'function' ) } >
45- < DataTypeLabel type_name = { type_name } { ...props } />
46- < span class = "rjv-function-container"
47- onClick = { ( ) => { this . toggleCollapsed ( ) } } >
48- { this . getFunctionDisplay ( collapsed ) }
49- </ span >
50- </ div >
51- ) ;
43+ < div { ...Theme ( props . theme , "function" ) } >
44+ < DataTypeLabel type_name = { type_name } { ...props } />
45+ < span
46+ { ...Theme ( props . theme , "function-value" ) }
47+ class = "rjv-function-container"
48+ onClick = { ( ) => {
49+ this . toggleCollapsed ( )
50+ } }
51+ >
52+ { this . getFunctionDisplay ( collapsed ) }
53+ </ span >
54+ </ div >
55+ )
5256 }
5357
54- getFunctionDisplay = ( collapsed ) => {
55- const { props} = this ;
58+ getFunctionDisplay = collapsed => {
59+ const { props } = this
5660
5761 if ( collapsed ) {
58- return ( < span >
59- { this . props . value . toString ( ) . slice ( 9 , - 1 ) . replace ( / \{ [ \s \S ] + / , '' ) }
60- < span class = 'function-collapsed' style = { { fontWeight : 'bold' } } >
61- < span > { "{" } </ span >
62- < span { ...Theme ( props . theme , 'ellipsis' ) } > ...</ span >
63- < span > { "}" } </ span >
62+ return (
63+ < span >
64+ { this . props . value
65+ . toString ( )
66+ . slice ( 9 , - 1 )
67+ . replace ( / \{ [ \s \S ] + / , "" ) }
68+ < span
69+ class = "function-collapsed"
70+ style = { { fontWeight : "bold" } }
71+ >
72+ < span > { "{" } </ span >
73+ < span { ...Theme ( props . theme , "ellipsis" ) } > ...</ span >
74+ < span > { "}" } </ span >
75+ </ span >
6476 </ span >
65- </ span > ) ;
77+ )
6678 } else {
67- return this . props . value . toString ( ) . slice ( 9 , - 1 ) ;
79+ return this . props . value . toString ( ) . slice ( 9 , - 1 )
6880 }
6981 }
70-
71- }
82+ }
0 commit comments