@@ -36,9 +36,7 @@ export class JsonViewer extends HTMLElement {
3636
3737 // Boolean attributes
3838 get expanded ( ) : boolean {
39- return (
40- this . hasAttribute ( "expanded" ) && this . getAttribute ( "expanded" ) !== "false"
41- )
39+ return this . hasAttribute ( "expanded" ) && this . getAttribute ( "expanded" ) !== "false"
4240 }
4341 set expanded ( value : boolean ) {
4442 if ( value ) {
@@ -49,59 +47,41 @@ export class JsonViewer extends HTMLElement {
4947 }
5048
5149 get showDataTypes ( ) : boolean {
52- return (
53- this . hasAttribute ( "show-data-types" ) &&
54- this . getAttribute ( "show-data-types" ) !== "false"
55- )
50+ return this . hasAttribute ( "show-data-types" ) && this . getAttribute ( "show-data-types" ) !== "false"
5651 }
5752 set showDataTypes ( value : boolean ) {
5853 this . setAttribute ( "show-data-types" , value . toString ( ) )
5954 }
6055
6156 get showLoadingStatus ( ) : boolean {
62- return (
63- this . hasAttribute ( "show-loading-status" ) &&
64- this . getAttribute ( "show-loading-status" ) !== "false"
65- )
57+ return this . hasAttribute ( "show-loading-status" ) && this . getAttribute ( "show-loading-status" ) !== "false"
6658 }
6759 set showLoadingStatus ( value : boolean ) {
6860 this . setAttribute ( "show-loading-status" , value . toString ( ) )
6961 }
7062 get showErrors ( ) : boolean {
71- return (
72- this . hasAttribute ( "show-errors" ) &&
73- this . getAttribute ( "show-errors" ) !== "false"
74- )
63+ return this . hasAttribute ( "show-errors" ) && this . getAttribute ( "show-errors" ) !== "false"
7564 }
7665 set showErrors ( value : boolean ) {
7766 this . setAttribute ( "show-errors" , value . toString ( ) )
7867 }
7968
8069 get showToolbar ( ) : boolean {
81- return (
82- this . hasAttribute ( "show-toolbar" ) &&
83- this . getAttribute ( "show-toolbar" ) !== "false"
84- )
70+ return this . hasAttribute ( "show-toolbar" ) && this . getAttribute ( "show-toolbar" ) !== "false"
8571 }
8672 set showToolbar ( value : boolean ) {
8773 this . setAttribute ( "show-toolbar" , value . toString ( ) )
8874 }
8975
9076 get showCopy ( ) : boolean {
91- return (
92- this . hasAttribute ( "show-copy" ) &&
93- this . getAttribute ( "show-copy" ) !== "false"
94- )
77+ return this . hasAttribute ( "show-copy" ) && this . getAttribute ( "show-copy" ) !== "false"
9578 }
9679 set showCopy ( value : boolean ) {
9780 this . setAttribute ( "show-copy" , value . toString ( ) )
9881 }
9982
10083 get showSize ( ) : boolean {
101- return (
102- this . hasAttribute ( "show-size" ) &&
103- this . getAttribute ( "show-size" ) !== "false"
104- )
84+ return this . hasAttribute ( "show-size" ) && this . getAttribute ( "show-size" ) !== "false"
10585 }
10686 set showSize ( value : boolean ) {
10787 this . setAttribute ( "show-size" , value . toString ( ) )
@@ -150,11 +130,7 @@ export class JsonViewer extends HTMLElement {
150130 return content || ""
151131 }
152132
153- attributeChangedCallback (
154- _name : string ,
155- oldValue : string | null ,
156- newValue : string | null
157- ) {
133+ attributeChangedCallback ( _name : string , oldValue : string | null , newValue : string | null ) {
158134 if ( oldValue !== newValue ) {
159135 this . render ( )
160136 }
@@ -211,9 +187,7 @@ export class JsonViewer extends HTMLElement {
211187 Invalid JSON data
212188 <details style="margin-top: 8px;">
213189 <summary>Raw data:</summary>
214- <pre style="background: #f5f5f5; padding: 8px; margin-top: 4px;">${
215- this . data
216- } </pre>
190+ <pre style="background: #f5f5f5; padding: 8px; margin-top: 4px;">${ this . data } </pre>
217191 <p>Error: ${ result . error || "Unknown error" } </p>
218192 </details>
219193 </div>
@@ -223,35 +197,6 @@ export class JsonViewer extends HTMLElement {
223197
224198 const parsedData = result . data
225199
226- if ( this . showToolbar ) {
227- if ( ! this . toolbar ) {
228- this . toolbar = new Toolbar ( )
229- this . toolbar . onChange ( ( { key, value } ) => {
230- if ( key === "indent" ) {
231- this . indent = value as number
232- } else if ( key === "expanded" ) {
233- this . expanded = value as boolean
234- } else if ( key === "showDataTypes" ) {
235- this . showDataTypes = value as boolean
236- } else if ( key === "expandIconType" ) {
237- this . expandIconType = value as string
238- } else if ( key === "showCopy" ) {
239- this . showCopy = value as boolean
240- } else if ( key === "showSize" ) {
241- this . showSize = value as boolean
242- }
243- } )
244- }
245- this . toolbar . updateProps ( {
246- indent : this . indent ,
247- expanded : this . expanded ,
248- showDataTypes : this . showDataTypes ,
249- expandIconType : this . expandIconType ,
250- showCopy : this . showCopy ,
251- showSize : this . showSize ,
252- } )
253- }
254-
255200 this . shadowRoot . innerHTML = `
256201 <style>
257202 :host {
@@ -295,7 +240,6 @@ export class JsonViewer extends HTMLElement {
295240 </style>
296241
297242 <div class="json-viewer" data-theme="${ this . theme } ">
298- ${ this . showToolbar ? this . toolbar ?. render ( ) : "" }
299243 ${ this . renderJson ( parsedData ) }
300244 </div>
301245 `
0 commit comments