1212 @mouseenter =" enter"
1313 @mouseleave =" leave"
1414 :class =" { selected: selected }"
15- :style =" { paddingLeft: depth * 15 + 'px' }" >
15+ :style =" { paddingLeft: depth * 15 + 'px' }"
16+ >
17+ <!-- Component tag -->
1618 <span class =" content" >
1719 <!-- arrow wrapper for better hit box -->
1820 <span class =" arrow-wrapper"
2123 <span class =" arrow right" :class =" { rotated: expanded }" >
2224 </span >
2325 </span >
24- <span class =" angle-bracket" >< ; </span ><span class =" item-name" >{{ displayName }}</span ><span class =" angle-bracket" >> ; </span >
26+
27+ <span class =" angle-bracket" >< ; </span >
28+
29+ <span class =" item-name" >{{ displayName }}</span >
30+
31+ <span v-if =" componentHasKey" class =" attr" >
32+ <span class =" attr-title" > key</span >=<span class =" attr-value" >{{instance.renderKey}}</span >
33+ </span >
34+
35+ <span class =" angle-bracket" >> ; </span >
2536 </span >
2637 <span
2738 v-if =" instance.consoleId"
4859 >
4960 inactive
5061 </span >
62+
5163 <span class =" spacer" ></span >
64+
5265 <VueIcon
5366 class =" icon-button"
5467 icon =" visibility"
5568 v-tooltip =" 'Scroll into view'"
5669 @click =" scrollToInstance"
5770 />
5871 </div >
72+
5973 <div v-if =" expanded" >
6074 <component-instance
6175 v-for =" child in sortedChildren"
6983
7084<script >
7185import { mapState } from ' vuex'
72- import { classify , scrollIntoView } from ' ../../../util'
86+ import { classify , scrollIntoView , UNDEFINED } from ' ../../../util'
7387
7488export default {
7589 name: ' ComponentInstance' ,
90+
7691 props: {
7792 instance: Object ,
7893 depth: Number
7994 },
95+
8096 created () {
8197 // expand root by default
8298 if (this .depth === 0 ) {
8399 this .expand ()
84100 }
85101 },
102+
86103 computed: {
87104 ... mapState (' components' , [
88105 ' classifyComponents'
89106 ]),
107+
90108 scrollToExpanded () {
91109 return this .$store .state .components .scrollToExpanded
92110 },
111+
93112 expanded () {
94113 return !! this .$store .state .components .expansionMap [this .instance .id ]
95114 },
115+
96116 selected () {
97117 return this .instance .id === this .$store .state .components .inspectedInstance .id
98118 },
119+
99120 sortedChildren () {
100121 return this .instance .children .slice ().sort ((a , b ) => {
101122 return a .top === b .top
102123 ? a .id - b .id
103124 : a .top - b .top
104125 })
105126 },
127+
106128 displayName () {
107129 return this .classifyComponents ? classify (this .instance .name ) : this .instance .name
130+ },
131+
132+ componentHasKey () {
133+ return !! this .instance .renderKey && this .instance .renderKey !== UNDEFINED
108134 }
109135 },
136+
110137 watch: {
111138 scrollToExpanded: {
112139 handler (value , oldValue ) {
@@ -117,35 +144,44 @@ export default {
117144 immediate: true
118145 }
119146 },
147+
120148 methods: {
121149 toggle (event ) {
122150 this .toggleWithValue (! this .expanded , event .altKey )
123151 },
152+
124153 expand () {
125154 this .toggleWithValue (true )
126155 },
156+
127157 collapse () {
128158 this .toggleWithValue (false )
129159 },
160+
130161 toggleWithValue (val , recursive = false ) {
131162 this .$store .dispatch (' components/toggleInstance' , {
132163 instance: this .instance ,
133164 expanded: val,
134165 recursive
135166 })
136167 },
168+
137169 select () {
138170 bridge .send (' select-instance' , this .instance .id )
139171 },
172+
140173 enter () {
141174 bridge .send (' enter-instance' , this .instance .id )
142175 },
176+
143177 leave () {
144178 bridge .send (' leave-instance' , this .instance .id )
145179 },
180+
146181 scrollToInstance () {
147182 bridge .send (' scroll-to-instance' , this .instance .id )
148183 },
184+
149185 scrollIntoView (center = true ) {
150186 this .$nextTick (() => {
151187 scrollIntoView (this .$globalRefs .leftScroll , this .$refs .self , center)
@@ -233,16 +269,29 @@ export default {
233269 color $component-color
234270 margin 0 1px
235271
272+ .attr
273+ opacity .5
274+ font-size 12px
275+
276+ .attr-title
277+ color purple
278+
236279.spacer
237- flex 100% 1 1
238- width 0
280+ flex auto 1 1
239281
240282.icon-button
241- font-size 16px
283+ width 16px
284+ height 16px
242285
243286 .self :not (:hover ) &
244287 visibility hidden
245288
246289 .self.selected & >>> svg
247290 fill $white
291+
292+ .self.selected
293+ .attr
294+ opacity 1
295+ .attr-title
296+ color lighten ($purple , 70% )
248297 </style >
0 commit comments