1
1
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js" ;
2
2
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
3
+ import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
3
4
4
5
// Template
5
6
import AvatarTemplate from "./generated/templates/AvatarTemplate.lit.js" ;
6
7
8
+ import { AVATAR_TOOLTIP } from "./generated/i18n/i18n-defaults.js" ;
9
+
7
10
// Styles
8
11
import AvatarCss from "./generated/themes/Avatar.css.js" ;
9
12
@@ -142,6 +145,19 @@ const metadata = {
142
145
type : String ,
143
146
defaultValue : AvatarBackgroundColor . Accent6 ,
144
147
} ,
148
+
149
+ /**
150
+ * Defines the text alternative of the <code>ui5-avatar</code>.
151
+ * If not provided a default text alternative will be set, if present.
152
+ *
153
+ * @type {string }
154
+ * @defaultvalue ""
155
+ * @public
156
+ * @since 1.0.0-rc.7
157
+ */
158
+ accessibleName : {
159
+ type : String ,
160
+ } ,
145
161
} ,
146
162
slots : /** @lends sap.ui.webcomponents.main.Avatar.prototype */ {
147
163
} ,
@@ -173,6 +189,11 @@ const metadata = {
173
189
* @public
174
190
*/
175
191
class Avatar extends UI5Element {
192
+ constructor ( ) {
193
+ super ( ) ;
194
+ this . i18nBundle = getI18nBundle ( "@ui5/webcomponents" ) ;
195
+ }
196
+
176
197
static get metadata ( ) {
177
198
return metadata ;
178
199
}
@@ -190,7 +211,10 @@ class Avatar extends UI5Element {
190
211
}
191
212
192
213
static async onDefine ( ) {
193
- await Icon . define ( ) ;
214
+ await Promise . all ( [
215
+ fetchI18nBundle ( "@ui5/webcomponents" ) ,
216
+ Icon . define ( ) ,
217
+ ] ) ;
194
218
}
195
219
196
220
get validInitials ( ) {
@@ -202,6 +226,14 @@ class Avatar extends UI5Element {
202
226
203
227
return null ;
204
228
}
229
+
230
+ get accessibleNameText ( ) {
231
+ if ( this . accessibleName ) {
232
+ return this . accessibleName ;
233
+ }
234
+
235
+ return this . i18nBundle . getText ( AVATAR_TOOLTIP ) || undefined ;
236
+ }
205
237
}
206
238
207
239
Avatar . define ( ) ;
0 commit comments