1
1
import { isPhone } from "@ui5/webcomponents-base/dist/Device.js" ;
2
- import { addOpenedPopup , removeOpenedPopup } from "./popup-utils/OpenedPopupsRegistry.js" ;
3
-
4
2
import Popup from "./Popup.js" ;
3
+
5
4
// Template
6
5
import DialogTemplate from "./generated/templates/DialogTemplate.lit.js" ;
7
-
8
6
// Styles
7
+ import PopupsCommonCss from "./generated/themes/PopupsCommon.css.js" ;
9
8
import dialogCSS from "./generated/themes/Dialog.css.js" ;
10
- import { getFocusedElement } from "./popup-utils/PopupUtils.js" ;
11
9
12
10
/**
13
11
* @public
14
12
*/
15
13
const metadata = {
16
14
tag : "ui5-dialog" ,
15
+ slots : /** @lends sap.ui.webcomponents.main.Popup.prototype */ {
16
+ /**
17
+ * Defines the header HTML Element.
18
+ *
19
+ * @type {HTMLElement[] }
20
+ * @slot
21
+ * @public
22
+ */
23
+ header : {
24
+ type : HTMLElement ,
25
+ } ,
26
+
27
+ /**
28
+ * Defines the footer HTML Element.
29
+ *
30
+ * @type {HTMLElement[] }
31
+ * @slot
32
+ * @public
33
+ */
34
+ footer : {
35
+ type : HTMLElement ,
36
+ } ,
37
+ } ,
17
38
properties : /** @lends sap.ui.webcomponents.main.Dialog.prototype */ {
39
+ /**
40
+ * Defines the header text.
41
+ * <br><br>
42
+ * <b>Note:</b> If <code>header</code> slot is provided, the <code>headerText</code> is ignored.
43
+ *
44
+ * @type {string }
45
+ * @defaultvalue ""
46
+ * @public
47
+ */
48
+ headerText : {
49
+ type : String ,
50
+ } ,
51
+
18
52
/**
19
53
* Determines whether the <code>ui5-dialog</code> should be stretched to fullscreen.
20
54
* <br><br>
@@ -29,6 +63,9 @@ const metadata = {
29
63
type : Boolean ,
30
64
} ,
31
65
66
+ /**
67
+ * @private
68
+ */
32
69
onPhone : {
33
70
type : Boolean ,
34
71
} ,
@@ -78,77 +115,34 @@ class Dialog extends Popup {
78
115
}
79
116
80
117
static get styles ( ) {
81
- return [ Popup . styles , dialogCSS ] ;
82
- }
83
-
84
- constructor ( ) {
85
- super ( ) ;
118
+ return [ PopupsCommonCss , dialogCSS ] ;
86
119
}
87
120
88
121
onBeforeRendering ( ) {
89
122
this . onPhone = isPhone ( ) ;
90
123
}
91
124
92
- /**
93
- * Opens the <code>ui5-dialog</code>.
94
- * @public
95
- */
96
- open ( ) {
97
- super . open ( ) ;
98
-
99
- this . _focusedElementBeforeOpen = getFocusedElement ( ) ;
100
- this . fireEvent ( "before-open" , { } ) ;
101
- this . show ( ) ;
102
- this . applyInitialFocus ( ) ;
103
-
104
- Dialog . blockBodyScrolling ( ) ;
105
-
106
- addOpenedPopup ( this ) ;
107
- this . opened = true ;
108
- this . fireEvent ( "after-open" , { } ) ;
109
- }
110
-
111
- /**
112
- * Closes the <code>ui5-dialog</code>.
113
- * @public
114
- */
115
- close ( escPressed ) {
116
- const prevented = ! this . fireEvent ( "before-close" , { escPressed } , true ) ;
117
-
118
- if ( prevented || ! this . opened ) {
119
- return ;
120
- }
121
-
122
- super . close ( ) ;
123
- this . hide ( ) ;
124
- this . opened = false ;
125
-
126
- this . fireEvent ( "after-close" , { } ) ;
127
-
128
- removeOpenedPopup ( this ) ;
129
- Dialog . unblockBodyScrolling ( ) ;
130
-
131
- if ( this . _focusedElementBeforeOpen && ! this . _disableInitialFocus ) {
132
- this . _focusedElementBeforeOpen . focus ( ) ;
133
- }
125
+ get isModal ( ) { // Required by Popup.js
126
+ return true ;
134
127
}
135
128
136
- onExitDOM ( ) {
137
- if ( this . isOpen ( ) ) {
138
- Dialog . unblockBodyScrolling ( ) ;
139
- }
129
+ get _ariaLabelledBy ( ) { // Required by Popup.js
130
+ return "ui5-popup-header" ;
140
131
}
141
132
142
- get isModal ( ) {
133
+ get _ariaModal ( ) { // Required by Popup.js
143
134
return true ;
144
135
}
145
136
146
- get _displayFooter ( ) {
147
- return true ;
148
- }
149
-
150
- get _displayHeader ( ) {
151
- return true ;
137
+ get classes ( ) {
138
+ return {
139
+ root : {
140
+ "ui5-popup-root" : true ,
141
+ } ,
142
+ content : {
143
+ "ui5-popup-content" : true ,
144
+ } ,
145
+ } ;
152
146
}
153
147
}
154
148
0 commit comments