|
1 | | -import { html, LitElement, TemplateResult } from 'lit'; |
| 1 | +import { html, LitElement, nothing, TemplateResult } from 'lit'; |
2 | 2 | import { property, queryAll, state } from 'lit/decorators.js'; |
3 | 3 | import { classMap } from 'lit/directives/class-map.js'; |
4 | 4 | import { map } from 'lit/directives/map.js'; |
@@ -262,32 +262,36 @@ export class JsonViewer extends LitElement { |
262 | 262 | const nodePath = path ? `${path}.${key}` : key; |
263 | 263 | const isPrimitiveNode = isPrimitive(nodeData); |
264 | 264 | const isExpanded = this.state.expanded[nodePath]; |
265 | | -
|
266 | | - return html` |
267 | | - <li |
268 | | - part="property" |
269 | | - role="treeitem" |
270 | | - data-path="${nodePath}" |
271 | | - aria-expanded="${isExpanded ? 'true' : 'false'}" |
272 | | - tabindex="-1" |
273 | | - .hidden="${this.state.filtered[nodePath]}" |
274 | | - aria-hidden="${this.state.filtered[nodePath]}" |
275 | | - > |
276 | | - <span |
277 | | - part="key" |
278 | | - class="${classMap({ |
279 | | - key: key, |
280 | | - collapsable: !isPrimitiveNode, |
281 | | - ['collapsable--collapsed']: !this.state.expanded[nodePath] |
282 | | - })}" |
283 | | - @click="${!isPrimitiveNode ? this.#handlePropertyClick(nodePath) : null}" |
284 | | - > |
285 | | - ${key}: ${when(!isPrimitiveNode && !isExpanded, () => this.renderNodePreview(nodeData))} |
286 | | - </span> |
287 | | -
|
288 | | - ${when(isPrimitiveNode || isExpanded, () => this.renderValue(nodeData, nodePath))} |
289 | | - </li> |
290 | | - `; |
| 265 | + const isFiltered = this.state.filtered[nodePath]; |
| 266 | +
|
| 267 | + return isFiltered |
| 268 | + ? nothing |
| 269 | + : html` |
| 270 | + <li |
| 271 | + part="property" |
| 272 | + role="treeitem" |
| 273 | + data-path="${nodePath}" |
| 274 | + aria-expanded="${isExpanded ? 'true' : 'false'}" |
| 275 | + tabindex="-1" |
| 276 | + .hidden="${this.state.filtered[nodePath]}" |
| 277 | + aria-hidden="${this.state.filtered[nodePath]}" |
| 278 | + > |
| 279 | + <span |
| 280 | + part="key" |
| 281 | + class="${classMap({ |
| 282 | + key: key, |
| 283 | + collapsable: !isPrimitiveNode, |
| 284 | + ['collapsable--collapsed']: !this.state.expanded[nodePath] |
| 285 | + })}" |
| 286 | + @click="${!isPrimitiveNode ? this.#handlePropertyClick(nodePath) : null}" |
| 287 | + > |
| 288 | + ${key}: |
| 289 | + ${when(!isPrimitiveNode && !isExpanded, () => this.renderNodePreview(nodeData))} |
| 290 | + </span> |
| 291 | +
|
| 292 | + ${when(isPrimitiveNode || isExpanded, () => this.renderValue(nodeData, nodePath))} |
| 293 | + </li> |
| 294 | + `; |
291 | 295 | })} |
292 | 296 | </ul> |
293 | 297 | `; |
|
0 commit comments