Skip to content

Commit 2dd97cf

Browse files
authored
feat: ui5-tree (new component) (#1580)
1 parent 37ee069 commit 2dd97cf

22 files changed

+1350
-29
lines changed

docs/Public Module Imports.md

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ For API documentation and samples, please check the [UI5 Web Components Playgrou
6969
| Title | `ui5-title` | `import "@ui5/webcomponents/dist/Title.js";` |
7070
| Toast | `ui5-toast` | `import "@ui5/webcomponents/dist/Toast.js";` |
7171
| Toggle Button | `ui5-togglebutton` | `import "@ui5/webcomponents/dist/ToggleButton.js";` |
72+
| Tree | `ui5-tree` | `import "@ui5/webcomponents/dist/Tree.js";` |
73+
| Tree Item | `ui5-tree-item` | comes with `ui5-tree` |
7274

7375
### 2. Assets
7476

packages/main/bundle.esm.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ import TimePicker from "./dist/TimePicker.js";
6161
import Title from "./dist/Title.js";
6262
import Toast from "./dist/Toast.js";
6363
import ToggleButton from "./dist/ToggleButton.js";
64-
65-
64+
import Tree from "./dist/Tree.js";
6665

6766
import List from "./dist/List.js";
6867
import StandardListItem from "./dist/StandardListItem.js";

packages/main/src/List.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<div id="{{_id}}-before" tabindex="0" class="ui5-list-focusarea"></div>
1818

19-
<ul id="{{_id}}-listUl" class="ui5-list-ul" aria-multiselectable="{{isMultiSelect}}" aria-labelledby="{{ariaLabelledBy}}" role="listbox">
19+
<ul id="{{_id}}-listUl" class="ui5-list-ul" aria-multiselectable="{{isMultiSelect}}" aria-labelledby="{{ariaLabelledBy}}" role="{{_role}}">
2020
<slot></slot>
2121

2222
{{#if showNoDataText}}
@@ -41,4 +41,4 @@
4141
{{/if}}
4242

4343
<div id="{{_id}}-after" tabindex="0" class="ui5-list-focusarea"></div>
44-
</div>
44+
</div>

packages/main/src/List.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const metadata = {
2626
slots: /** @lends sap.ui.webcomponents.main.List.prototype */ {
2727

2828
/**
29-
* Defines the <code>ui5-li</code> header.
29+
* Defines the <code>ui5-list</code> header.
3030
* <br><br>
3131
* <b>Note:</b> When <code>header</code> is set, the
3232
* <code>headerText</code> property is ignored.
@@ -93,8 +93,8 @@ const metadata = {
9393
/**
9494
* Defines the mode of the <code>ui5-list</code>.
9595
* <br><br>
96-
* <b>Note:</b> Avalaible options are <code>None</code>, <code>SingleSelect</code>,
97-
* <code>MultiSelect</code>, and <code>Delete</code>.
96+
* <b>Note:</b> Available options are <code>None</code>, <code>SingleSelect</code>, <code>SingleSelectBegin</code>,
97+
* <code>SingleSelectEnd</code>, <code>MultiSelect</code>, and <code>Delete</code>.
9898
*
9999
* @type {ListMode}
100100
* @defaultvalue "None"
@@ -162,6 +162,17 @@ const metadata = {
162162
busy: {
163163
type: Boolean,
164164
},
165+
166+
/**
167+
* Used to externally manipulate the role of the list
168+
*
169+
* @private
170+
*/
171+
_role: {
172+
type: String,
173+
defaultValue: "listbox",
174+
noAttribute: true,
175+
},
165176
},
166177
events: /** @lends sap.ui.webcomponents.main.List.prototype */ {
167178

@@ -227,7 +238,7 @@ const metadata = {
227238

228239
/**
229240
* Fired when selection is changed by user interaction
230-
* in <code>SingleSelect</code> and <code>MultiSelect</code> modes.
241+
* in <code>SingleSelect</code>, <code>SingleSelectBegin</code>, <code>SingleSelectEnd</code> and <code>MultiSelect</code> modes.
231242
*
232243
* @event
233244
* @param {Array} selectedItems An array of the selected items.
@@ -624,6 +635,10 @@ class List extends UI5Element {
624635
}
625636
}
626637

638+
focusItem(item) {
639+
item.focus();
640+
}
641+
627642
setForwardingFocus(forwardingFocus) {
628643
this._forwardingFocus = forwardingFocus;
629644
}

packages/main/src/ListItem.hbs

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
@touchend="{{_ontouchend}}"
1313
@click="{{_onclick}}"
1414
aria-selected="{{ariaSelected}}"
15-
role="option"
15+
role="{{_accInfo.role}}"
16+
aria-expanded="{{_accInfo.ariaExpanded}}"
17+
aria-level="{{_accInfo.ariaLevel}}"
1618
>
19+
{{> listItemPreContent}}
20+
1721
{{#if placeSelectionElementBefore}}
1822
{{> selectionElement}}
1923
{{/if}}
@@ -40,7 +44,7 @@
4044
{{/if}}
4145
</li>
4246

43-
47+
{{#*inline "listItemPreContent"}}{{/inline}}
4448
{{#*inline "listItemContent"}}{{/inline}}
4549
{{#*inline "imageBegin"}}{{/inline}}
4650
{{#*inline "iconBegin"}}{{/inline}}

packages/main/src/ListItem.js

+8
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ class ListItem extends ListItemBase {
283283
return this.i18nBundle.getText(DELETE);
284284
}
285285

286+
get _accInfo() {
287+
return {
288+
role: "option",
289+
ariaExpanded: undefined,
290+
ariaLevel: undefined,
291+
};
292+
}
293+
286294
static async onDefine() {
287295
await Promise.all([
288296
fetchI18nBundle("@ui5/webcomponents"),

packages/main/src/Tree.hbs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<ui5-list
2+
.mode="{{mode}}"
3+
.headerText="{{headerText}}"
4+
.footerText="{{footerText}}"
5+
.noDataText="{{noDataText}}"
6+
._role="{{_role}}"
7+
@ui5-itemClick="{{_onListItemClick}}"
8+
@ui5-itemDelete="{{_onListItemDelete}}"
9+
@ui5-selectionChange="{{_onListSelectionChange}}"
10+
>
11+
<slot name="header" slot="header"></slot>
12+
{{#each _listItems}}
13+
<ui5-li-tree
14+
._id="{{this.treeItem._id}}"
15+
type="Active"
16+
level="{{this.level}}"
17+
icon="{{this.treeItem.icon}}"
18+
.treeItem="{{this.treeItem}}"
19+
.expanded="{{this.treeItem.expanded}}"
20+
.selected="{{this.treeItem.selected}}"
21+
.showToggleButton="{{this.treeItem.requiresToggleButton}}"
22+
@ui5-toggle="{{../_onListItemToggle}}"
23+
@ui5-stepIn="{{../_onListItemStepIn}}"
24+
@ui5-stepOut="{{../_onListItemStepOut}}"
25+
>
26+
{{this.treeItem.text}}
27+
</ui5-li-tree>
28+
{{/each}}
29+
</ui5-list>

0 commit comments

Comments
 (0)