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,75 +115,34 @@ class Dialog extends Popup {
78
115
}
79
116
80
117
static get styles ( ) {
81
- return [ Popup . styles , dialogCSS ] ;
118
+ return [ PopupsCommonCss , dialogCSS ] ;
82
119
}
83
120
84
- constructor ( ) {
85
- super ( ) ;
86
-
121
+ onBeforeRendering ( ) {
87
122
this . onPhone = isPhone ( ) ;
88
123
}
89
124
90
- /**
91
- * Opens the <code>ui5-dialog</code>.
92
- * @public
93
- */
94
- open ( ) {
95
- super . open ( ) ;
96
-
97
- this . _focusedElementBeforeOpen = getFocusedElement ( ) ;
98
- this . fireEvent ( "before-open" , { } ) ;
99
- this . show ( ) ;
100
- this . applyInitialFocus ( ) ;
101
-
102
- Dialog . blockBodyScrolling ( ) ;
103
-
104
- addOpenedPopup ( this ) ;
105
- this . opened = true ;
106
- this . fireEvent ( "after-open" , { } ) ;
107
- }
108
-
109
- /**
110
- * Closes the <code>ui5-dialog</code>.
111
- * @public
112
- */
113
- close ( escPressed ) {
114
- const prevented = ! this . fireEvent ( "before-close" , { escPressed } , true ) ;
115
-
116
- if ( prevented || ! this . opened ) {
117
- return ;
118
- }
119
-
120
- super . close ( ) ;
121
- this . hide ( ) ;
122
- this . opened = false ;
123
-
124
- this . fireEvent ( "after-close" , { } ) ;
125
-
126
- removeOpenedPopup ( this ) ;
127
- Dialog . unblockBodyScrolling ( ) ;
128
-
129
- if ( this . _focusedElementBeforeOpen && ! this . _disableInitialFocus ) {
130
- this . _focusedElementBeforeOpen . focus ( ) ;
131
- }
125
+ get isModal ( ) { // Required by Popup.js
126
+ return true ;
132
127
}
133
128
134
- onExitDOM ( ) {
135
- if ( this . isOpen ( ) ) {
136
- Dialog . unblockBodyScrolling ( ) ;
137
- }
129
+ get _ariaLabelledBy ( ) { // Required by Popup.js
130
+ return "ui5-popup-header" ;
138
131
}
139
132
140
- get isModal ( ) {
133
+ get _ariaModal ( ) { // Required by Popup.js
141
134
return true ;
142
135
}
143
136
144
- get _displayFooter ( ) {
145
- return true ;
146
- }
147
-
148
- get _displayHeader ( ) {
149
- return true ;
137
+ get classes ( ) {
138
+ return {
139
+ root : {
140
+ "ui5-popup-root" : true ,
141
+ } ,
142
+ content : {
143
+ "ui5-popup-content" : true ,
144
+ } ,
145
+ } ;
150
146
}
151
147
}
152
148
0 commit comments