@@ -11,11 +11,12 @@ export default class Primitive extends Component {
1111 getConfigs : PropTypes . func . isRequired ,
1212 name : PropTypes . string ,
1313 displayName : PropTypes . string ,
14- depth : PropTypes . number
14+ depth : PropTypes . number ,
15+ expandDepth : PropTypes . number
1516 }
1617
1718 render ( ) {
18- let { schema, getComponent, getConfigs, name, displayName, depth } = this . props
19+ let { schema, getComponent, getConfigs, name, displayName, depth, expandDepth } = this . props
1920
2021 const { showExtensions } = getConfigs ( )
2122
@@ -37,33 +38,40 @@ export default class Primitive extends Component {
3738 const Markdown = getComponent ( "Markdown" , true )
3839 const EnumModel = getComponent ( "EnumModel" )
3940 const Property = getComponent ( "Property" )
41+ const ModelCollapse = getComponent ( "ModelCollapse" )
42+ const titleEl = title &&
43+ < span className = "model-title" >
44+ < span className = "model-title__text" > { title } </ span >
45+ </ span >
4046
4147 return < span className = "model" >
42- < span className = "prop" >
43- { name && < span className = { `${ depth === 1 && "model-title" } prop-name` } > { title } </ span > }
44- < span className = "prop-type" > { type } </ span >
45- { format && < span className = "prop-format" > (${ format } )</ span > }
46- {
47- properties . size ? properties . entrySeq ( ) . map ( ( [ key , v ] ) => < Property key = { `${ key } -${ v } ` } propKey = { key } propVal = { v } propClass = { propClass } /> ) : null
48- }
49- {
50- showExtensions && extensions . size ? extensions . entrySeq ( ) . map ( ( [ key , v ] ) => < Property key = { `${ key } -${ v } ` } propKey = { key } propVal = { v } propClass = { propClass } /> ) : null
51- }
52- {
53- ! description ? null :
54- < Markdown source = { description } />
55- }
56- {
57- xml && xml . size ? ( < span > < br /> < span className = { propClass } > xml:</ span >
58- {
59- xml . entrySeq ( ) . map ( ( [ key , v ] ) => < span key = { `${ key } -${ v } ` } className = { propClass } > < br /> { key } : { String ( v ) } </ span > ) . toArray ( )
60- }
61- </ span > ) : null
62- }
63- {
64- enumArray && < EnumModel value = { enumArray } getComponent = { getComponent } />
65- }
66- </ span >
48+ < ModelCollapse title = { titleEl } expanded = { depth >= expandDepth } collapsedContent = " " hideSelfOnExpand = { expandDepth !== depth } >
49+ < span className = "prop" >
50+ { name && depth > 1 && < span className = { `${ depth === 1 && "model-title" } prop-name` } > { title } </ span > }
51+ < span className = "prop-type" > { type } </ span >
52+ { format && < span className = "prop-format" > (${ format } )</ span > }
53+ {
54+ properties . size ? properties . entrySeq ( ) . map ( ( [ key , v ] ) => < Property key = { `${ key } -${ v } ` } propKey = { key } propVal = { v } propClass = { propClass } /> ) : null
55+ }
56+ {
57+ showExtensions && extensions . size ? extensions . entrySeq ( ) . map ( ( [ key , v ] ) => < Property key = { `${ key } -${ v } ` } propKey = { key } propVal = { v } propClass = { propClass } /> ) : null
58+ }
59+ {
60+ ! description ? null :
61+ < Markdown source = { description } />
62+ }
63+ {
64+ xml && xml . size ? ( < span > < br /> < span className = { propClass } > xml:</ span >
65+ {
66+ xml . entrySeq ( ) . map ( ( [ key , v ] ) => < span key = { `${ key } -${ v } ` } className = { propClass } > < br /> { key } : { String ( v ) } </ span > ) . toArray ( )
67+ }
68+ </ span > ) : null
69+ }
70+ {
71+ enumArray && < EnumModel value = { enumArray } getComponent = { getComponent } />
72+ }
73+ </ span >
74+ </ ModelCollapse >
6775 </ span >
6876 }
6977}
0 commit comments