1
- import { LitElement , PropertyValues , html , nothing } from " lit" ;
2
- import { property , query } from " lit/decorators.js" ;
1
+ import { LitElement , PropertyValues , html , nothing } from ' lit' ;
2
+ import { property , query } from ' lit/decorators.js' ;
3
3
4
4
export class Modal extends LitElement implements HTMLDialogElement {
5
5
static readonly shadowRootOptions = {
@@ -10,13 +10,13 @@ export class Modal extends LitElement implements HTMLDialogElement {
10
10
@property ( { type : Boolean , reflect : true } )
11
11
open : boolean = false ;
12
12
13
- @query ( " #dialog" )
13
+ @query ( ' #dialog' )
14
14
private dialog ?: HTMLElement | null ;
15
15
16
- @query ( " #overlay" )
16
+ @query ( ' #overlay' )
17
17
private overlay ?: HTMLElement | null ;
18
18
19
- returnValue : string = "" ;
19
+ returnValue : string = '' ;
20
20
21
21
constructor ( ) {
22
22
super ( ) ;
@@ -27,12 +27,12 @@ export class Modal extends LitElement implements HTMLDialogElement {
27
27
28
28
connectedCallback ( ) {
29
29
super . connectedCallback ( ) ;
30
- this . addEventListener ( " keydown" , this . handleKeydown ) ;
31
- this . addEventListener ( " click" , this . handleClick ) ;
30
+ this . addEventListener ( ' keydown' , this . handleKeydown ) ;
31
+ this . addEventListener ( ' click' , this . handleClick ) ;
32
32
}
33
33
34
34
protected updated ( changed : PropertyValues ) : void {
35
- const oldValue = changed . get ( " open" ) ;
35
+ const oldValue = changed . get ( ' open' ) ;
36
36
const newValue = this . open ;
37
37
const openChanged = oldValue !== undefined && oldValue !== newValue ;
38
38
@@ -41,19 +41,19 @@ export class Modal extends LitElement implements HTMLDialogElement {
41
41
this . dialog ?. focus ( ) ;
42
42
43
43
this . dispatchEvent (
44
- new Event ( " open" , {
44
+ new Event ( ' open' , {
45
45
bubbles : true ,
46
46
composed : true ,
47
47
cancelable : true ,
48
- } )
48
+ } ) ,
49
49
) ;
50
50
} else {
51
51
this . dispatchEvent (
52
- new Event ( " close" , {
52
+ new Event ( ' close' , {
53
53
bubbles : true ,
54
54
composed : true ,
55
55
cancelable : true ,
56
- } )
56
+ } ) ,
57
57
) ;
58
58
}
59
59
}
@@ -72,7 +72,7 @@ export class Modal extends LitElement implements HTMLDialogElement {
72
72
73
73
private handleKeydown ( event : KeyboardEvent ) {
74
74
// TODO: handle `Tab`, `Shift + Tab`.
75
- if ( [ " Escape" , " Esc" ] . includes ( event . key ) ) {
75
+ if ( [ ' Escape' , ' Esc' ] . includes ( event . key ) ) {
76
76
this . close ( ) ;
77
77
}
78
78
}
0 commit comments