1
1
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
2
2
import { isLeft , isRight } from "@ui5/webcomponents-base/dist/Keys.js" ;
3
+ import { fetchI18nBundle , getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js" ;
3
4
import ListItem from "./ListItem.js" ;
4
5
import Icon from "./Icon.js" ;
5
6
import "@ui5/webcomponents-icons/dist/navigation-right-arrow.js" ;
6
7
import "@ui5/webcomponents-icons/dist/navigation-down-arrow.js" ;
8
+ import {
9
+ TREE_ITEM_ARIA_LABEL ,
10
+ TREE_ITEM_EXPAND_NODE ,
11
+ TREE_ITEM_COLLAPSE_NODE ,
12
+ LIST_ITEM_SELECTED ,
13
+ } from "./generated/i18n/i18n-defaults.js" ;
7
14
8
15
// Template
9
16
import TreeListItemTemplate from "./generated/templates/TreeListItemTemplate.lit.js" ;
@@ -16,6 +23,7 @@ import treeListItemCss from "./generated/themes/TreeListItem.css.js";
16
23
*/
17
24
const metadata = {
18
25
tag : "ui5-li-tree" ,
26
+ languageAware : true ,
19
27
properties : /** @lends sap.ui.webcomponents.main.TreeListItem.prototype */ {
20
28
21
29
/**
@@ -175,6 +183,12 @@ class TreeListItem extends ListItem {
175
183
] ;
176
184
}
177
185
186
+ constructor ( ) {
187
+ super ( ) ;
188
+
189
+ this . i18nBundle = getI18nBundle ( "@ui5/webcomponents" ) ;
190
+ }
191
+
178
192
onBeforeRendering ( ) {
179
193
this . actionable = false ;
180
194
}
@@ -214,6 +228,7 @@ class TreeListItem extends ListItem {
214
228
role : "treeitem" ,
215
229
ariaExpanded : this . showToggleButton ? this . expanded : undefined ,
216
230
ariaLevel : this . level ,
231
+ listItemAriaLabel : this . ariaLabelText ,
217
232
} ;
218
233
}
219
234
@@ -241,6 +256,24 @@ class TreeListItem extends ListItem {
241
256
}
242
257
}
243
258
}
259
+
260
+ get ariaLabelText ( ) {
261
+ let text = this . i18nBundle . getText ( TREE_ITEM_ARIA_LABEL ) ;
262
+
263
+ if ( this . selected ) {
264
+ text += ` ${ this . i18nBundle . getText ( LIST_ITEM_SELECTED ) } ` ;
265
+ }
266
+
267
+ return text ;
268
+ }
269
+
270
+ get iconAccessibleName ( ) {
271
+ return this . expanded ? this . i18nBundle . getText ( TREE_ITEM_COLLAPSE_NODE ) : this . i18nBundle . getText ( TREE_ITEM_EXPAND_NODE ) ;
272
+ }
273
+
274
+ static async onDefine ( ) {
275
+ await fetchI18nBundle ( "@ui5/webcomponents" ) ;
276
+ }
244
277
}
245
278
246
279
TreeListItem . define ( ) ;
0 commit comments