@@ -4,12 +4,12 @@ import { customElement, property, query, state } from "lit/decorators";
44import { ifDefined } from "lit/directives/if-defined" ;
55import { fireEvent } from "../../common/dom/fire_event" ;
66import "../../components/ha-button" ;
7+ import "../../components/ha-dialog-footer" ;
78import "../../components/ha-dialog-header" ;
8- import "../../components/ha-md-dialog" ;
9- import type { HaMdDialog } from "../../components/ha-md-dialog" ;
109import "../../components/ha-svg-icon" ;
1110import "../../components/ha-textfield" ;
1211import type { HaTextField } from "../../components/ha-textfield" ;
12+ import "../../components/ha-wa-dialog" ;
1313import type { HomeAssistant } from "../../types" ;
1414import type { DialogBoxParams } from "./show-dialog-box" ;
1515
@@ -19,12 +19,12 @@ class DialogBox extends LitElement {
1919
2020 @state ( ) private _params ?: DialogBoxParams ;
2121
22+ @state ( ) private _open = false ;
23+
2224 @state ( ) private _closeState ?: "canceled" | "confirmed" ;
2325
2426 @query ( "ha-textfield" ) private _textField ?: HaTextField ;
2527
26- @query ( "ha-md-dialog" ) private _dialog ?: HaMdDialog ;
27-
2828 private _closePromise ?: Promise < void > ;
2929
3030 private _closeResolve ?: ( ) => void ;
@@ -34,6 +34,7 @@ class DialogBox extends LitElement {
3434 await this . _closePromise ;
3535 }
3636 this . _params = params ;
37+ this . _open = true ;
3738 }
3839
3940 public closeDialog ( ) : boolean {
@@ -60,16 +61,16 @@ class DialogBox extends LitElement {
6061 this . hass . localize ( "ui.dialogs.generic.default_confirmation_title" ) ) ;
6162
6263 return html `
63- <ha- md- dialog
64- open
65- .disableCancelAction = ${ confirmPrompt }
64+ <ha- wa- dialog
65+ .hass = ${ this . hass }
66+ .open = ${ this . _open }
67+ ?prevent- scrim- close= ${ confirmPrompt }
6668 @closed = ${ this . _dialogClosed }
67- type= "alert"
6869 aria- labelledby= "dialog-box-title"
6970 aria-describedby = "dialog-box-description"
7071 >
71- <div slot= "headline " >
72- <span . title = ${ dialogTitle } id= "dialog-box-title" >
72+ <ha - dialog - header slot= "header " >
73+ <span slot = "title" id = "dialog-box-title" >
7374 ${ this . _params . warning
7475 ? html `<ha- svg- icon
7576 .path = ${ mdiAlertOutline }
@@ -78,13 +79,13 @@ class DialogBox extends LitElement {
7879 : nothing }
7980 ${ dialogTitle }
8081 </ span>
81- </ div >
82- <div slot = "content" id = "dialog-box-description" >
82+ </ ha - dialog - header >
83+ <div id= "dialog-box-description" >
8384 ${ this . _params . text ? html ` <p> ${ this . _params . text } </ p> ` : "" }
8485 ${ this . _params . prompt
8586 ? html `
8687 <ha- textfield
87- dialogInitialFocus
88+ au to focus
8889 value= ${ ifDefined ( this . _params . defaultValue ) }
8990 .placeholder = ${ this . _params . placeholder }
9091 .label = ${ this . _params . inputLabel
@@ -99,10 +100,11 @@ class DialogBox extends LitElement {
99100 `
100101 : "" }
101102 </ div>
102- <div slot= "actions " >
103+ <ha - dialog - footer slot= "footer " >
103104 ${ confirmPrompt
104105 ? html `
105106 <ha- butto n
107+ slot= "secondaryAction"
106108 @click = ${ this . _dismiss }
107109 ?auto focus= ${ ! this . _params . prompt && this . _params . destructive }
108110 appearance= "plain"
@@ -114,6 +116,7 @@ class DialogBox extends LitElement {
114116 `
115117 : nothing }
116118 <ha- butto n
119+ slot= "primaryAction"
117120 @click = ${ this . _confirm }
118121 ?auto focus= ${ ! this . _params . prompt && ! this . _params . destructive }
119122 variant= ${ this . _params . destructive ? "danger" : "brand" }
@@ -122,8 +125,8 @@ class DialogBox extends LitElement {
122125 ? this . _params . confirmText
123126 : this . hass . localize ( "ui.common.ok" ) }
124127 </ ha- butto n>
125- </ div >
126- </ ha- md - dialog>
128+ </ ha - dialog - footer >
129+ </ ha- wa - dialog>
127130 ` ;
128131 }
129132
@@ -148,8 +151,7 @@ class DialogBox extends LitElement {
148151 }
149152
150153 private _closeDialog ( ) {
151- fireEvent ( this , "dialog-closed" , { dialog : this . localName } ) ;
152- this . _dialog ?. close ( ) ;
154+ this . _open = false ;
153155 this . _closePromise = new Promise ( ( resolve ) => {
154156 this . _closeResolve = resolve ;
155157 } ) ;
@@ -162,6 +164,7 @@ class DialogBox extends LitElement {
162164 }
163165 this . _closeState = undefined ;
164166 this . _params = undefined ;
167+ this . _open = false ;
165168 this . _closeResolve ?.( ) ;
166169 this . _closeResolve = undefined ;
167170 }
0 commit comments