@@ -16,7 +16,7 @@ import { humanizeKey, humanizeValue } from "./utils/humanize";
16
16
import { choose } from "lit/directives/choose.js" ;
17
17
import { when } from "lit/directives/when.js" ;
18
18
import { isUndefined } from "lodash" ;
19
- import { navigate } from "./utils/path" ;
19
+ import { navigateSchema } from "./utils/path" ;
20
20
21
21
/**
22
22
* The body represents the main content of the JSON UI.
@@ -54,6 +54,7 @@ export class BodyElement extends LitElement {
54
54
[ "string" , ( ) => this . renderPrimitive ( "string" ) ] ,
55
55
[ "number" , ( ) => this . renderPrimitive ( "string" ) ] ,
56
56
[ "enum" , ( ) => this . renderPrimitive ( "string" ) ] ,
57
+ [ "boolean" , ( ) => this . renderPrimitive ( "boolean" ) ] ,
57
58
] ,
58
59
( ) => html `Unknown type < strong > ${ type } </ strong > .`
59
60
) }
@@ -69,12 +70,12 @@ export class BodyElement extends LitElement {
69
70
}
70
71
71
72
private renderPrimitive (
72
- type : "string" | "number" | "enum" ,
73
+ type : "string" | "number" | "enum" | "boolean" ,
73
74
key ?: string | number ,
74
75
skipHeader = false
75
76
) {
76
77
const value = ! isUndefined ( key ) ? this . value ?. [ key ] : this . value ;
77
- const schema = navigate ( this . schema ! , key ) ;
78
+ const schema = navigateSchema ( this . schema ! , key ) ;
78
79
return html `< label class ="flex flex-col gap-2 w-full ">
79
80
${ when ( ! skipHeader && key , ( ) =>
80
81
renderLabel ( String ( key ) , this . required . includes ( String ( key ) ) )
@@ -109,6 +110,14 @@ export class BodyElement extends LitElement {
109
110
> </ single-dropdown-element > ` ;
110
111
} ,
111
112
] ,
113
+ [
114
+ "boolean" ,
115
+ ( ) => html `< checkbox-element
116
+ @change =${ dispatchChange ( this , String ( key ?? "" ) ) }
117
+ .value =${ value }
118
+ .label=${ humanizeKey ( String ( key ) ) }
119
+ > </ checkbox-element > ` ,
120
+ ] ,
112
121
] ) }
113
122
</ label > ` ;
114
123
}
@@ -129,8 +138,9 @@ export class BodyElement extends LitElement {
129
138
[ "string" , ( ) => this . renderPrimitive ( "string" , key ) ] ,
130
139
[ "number" , ( ) => this . renderPrimitive ( "number" , key ) ] ,
131
140
[ "enum" , ( ) => this . renderPrimitive ( "enum" , key ) ] ,
141
+ [ "boolean" , ( ) => this . renderPrimitive ( "boolean" , key , true ) ] ,
132
142
] ,
133
- ( ) => html `< label class ="inline-flex flex-col gap-2 "
143
+ ( ) => html `< label class ="w-full inline-flex flex-col gap-2 "
134
144
> ${ renderLabel ( key , this . required . includes ( key ) ) }
135
145
${ this . renderValuePreview ( key , value ) }
136
146
</ label > `
0 commit comments