Skip to content

Commit 1f07d50

Browse files
authored
feat(ui5-tree-item): implement info/infoState attributes (#2711)
Info and infoState attributes are added to ui5-tree-item. Fixes: #2633
1 parent 8c71ca4 commit 1f07d50

File tree

6 files changed

+100
-7
lines changed

6 files changed

+100
-7
lines changed

packages/main/src/Tree.hbs

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
type="Active"
1616
level="{{this.level}}"
1717
icon="{{this.treeItem.icon}}"
18+
info="{{this.treeItem.info}}"
19+
info-state="{{this.treeItem.infoState}}"
1820
?_toggle-button-end="{{ ../_toggleButtonEnd}}"
1921
?_minimal="{{../_minimal}}"
2022
.treeItem="{{this.treeItem}}"

packages/main/src/TreeItem.js

+25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2+
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
23

34
/**
45
* @public
@@ -66,6 +67,30 @@ const metadata = {
6667
icon: {
6768
type: String,
6869
},
70+
71+
/**
72+
* Defines the <code>info</code>, displayed in the end of the tree item.
73+
* @type {string}
74+
* @public
75+
* @since 1.0.0-rc.12
76+
*/
77+
info: {
78+
type: String,
79+
},
80+
81+
/**
82+
* Defines the state of the <code>info</code>.
83+
* <br>
84+
* Available options are: <code>"None"</code> (by default), <code>"Success"</code>, <code>"Warning"</code>, <code>"Information"</code> and <code>"Erorr"</code>.
85+
* @type {ValueState}
86+
* @defaultvalue "None"
87+
* @public
88+
* @since 1.0.0-rc.12
89+
*/
90+
infoState: {
91+
type: ValueState,
92+
defaultValue: ValueState.None,
93+
},
6994
},
7095
managedSlots: true,
7196
slots: /** @lends sap.ui.webcomponents.main.TreeItem.prototype */ {

packages/main/src/TreeListItem.hbs

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818
{{/inline}}
1919

2020
{{#*inline "listItemContent"}}
21-
{{#if _showTitle}}
22-
<div part="title" class="ui5-li-title"><slot></slot></div>
23-
{{/if}}
21+
<div class="ui5-li-tree-text-wrapper">
22+
{{#if _showTitle}}
23+
<div part="title" class="ui5-li-title"><slot></slot></div>
24+
{{/if}}
25+
26+
{{#if info}}
27+
<span part="info" class="ui5-li-tree-info">{{info}}</span>
28+
{{/if}}
29+
</div>
2430
{{/inline}}
2531

2632
{{#*inline "imageBegin"}}{{/inline}}

packages/main/src/TreeListItem.js

+25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
22
import { isLeft, isRight } from "@ui5/webcomponents-base/dist/Keys.js";
33
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
4+
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js";
45
import ListItem from "./ListItem.js";
56
import Icon from "./Icon.js";
67
import "@ui5/webcomponents-icons/dist/navigation-right-arrow.js";
@@ -71,6 +72,30 @@ const metadata = {
7172
type: Boolean,
7273
},
7374

75+
/**
76+
* Defines the <code>info</code>, displayed in the end of the tree item.
77+
* @type {string}
78+
* @public
79+
* @since 1.0.0-rc.12
80+
*/
81+
info: {
82+
type: String,
83+
},
84+
85+
/**
86+
* Defines the state of the <code>info</code>.
87+
* <br>
88+
* Available options are: <code>"None"</code> (by default), <code>"Success"</code>, <code>"Warning"</code>, <code>"Information"</code> and <code>"Erorr"</code>.
89+
* @type {ValueState}
90+
* @defaultvalue "None"
91+
* @public
92+
* @since 1.0.0-rc.12
93+
*/
94+
infoState: {
95+
type: ValueState,
96+
defaultValue: ValueState.None,
97+
},
98+
7499
/**
75100
* Defines whether the toggle button is shown at the end, rather than at the beginning of the item
76101
*

packages/main/src/themes/TreeListItem.css

+35
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,38 @@
8383
:host([active][actionable]) .ui5-li-tree-toggle-icon {
8484
color: var(--sapList_Active_TextColor);
8585
}
86+
87+
/* [ui5-li]: infoState */
88+
:host([info-state="Warning"]) .ui5-li-tree-info {
89+
color: var(--sapCriticalTextColor);
90+
}
91+
92+
:host([info-state="Success"]) .ui5-li-tree-info {
93+
color: var(--sapPositiveTextColor);
94+
}
95+
96+
:host([info-state="Error"]) .ui5-li-tree-info {
97+
color: var(--sapNegativeTextColor);
98+
}
99+
100+
:host([info-state="Information"]) .ui5-li-tree-info {
101+
color: var(--sapInformativeTextColor);
102+
}
103+
104+
/* [ui5-li]: info */
105+
.ui5-li-tree-info {
106+
margin: 0 0.25rem;
107+
color: var(--sapNeutralTextColor);
108+
font-size: 0.875rem;
109+
min-width: 6rem;
110+
max-width: 40%;
111+
white-space: nowrap;
112+
overflow: hidden;
113+
text-overflow: ellipsis;
114+
}
115+
116+
.ui5-li-tree-text-wrapper {
117+
display:flex;
118+
justify-content:space-between;
119+
width: 100%;
120+
}

packages/main/test/pages/Tree.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
<ui5-button id="collapseAll" icon="collapse-all">Collapse All</ui5-button>
7575
</div>
7676

77-
<ui5-tree-item expanded text="Tree 1" icon="paste" selected>
78-
<ui5-tree-item expanded text="Tree 1.1" selected>
79-
<ui5-tree-item text="Tree 1.1.1"></ui5-tree-item>
80-
<ui5-tree-item text="Tree 1.1.2"></ui5-tree-item>
77+
<ui5-tree-item expanded text="Tree 1" icon="paste" info="Available" info-state="Information" selected>
78+
<ui5-tree-item expanded text="Tree 1.1" info="Re-stock" info-state="Error" selected>
79+
<ui5-tree-item text="Tree 1.1.1" info="Required" info-state="Warning"></ui5-tree-item>
80+
<ui5-tree-item text="Tree 1.1.2" info="Available" info-state="Success"></ui5-tree-item>
8181
</ui5-tree-item>
8282
</ui5-tree-item>
8383

0 commit comments

Comments
 (0)