-
Notifications
You must be signed in to change notification settings - Fork 280
Expand file tree
/
Copy pathSideNavigationSubItem.ts
More file actions
103 lines (87 loc) · 2.52 KB
/
SideNavigationSubItem.ts
File metadata and controls
103 lines (87 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import jsxRender from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot-strict.js";
import type { Slot } from "@ui5/webcomponents-base/dist/UI5Element.js";
import SideNavigationSelectableItemBase from "./SideNavigationSelectableItemBase.js";
import SideNavigationSubItemTemplate from "./SideNavigationSubItemTemplate.js";
import "@ui5/webcomponents/dist/Tag.js";
// Styles
import SideNavigationSubItemCss from "./generated/themes/SideNavigationSubItem.css.js";
/**
* @class
*
* ### Overview
* Represents a single navigation action within `ui5-side-navigation-item`.
* The `ui5-side-navigation-sub-item` is intended to be used inside a `ui5-side-navigation-item` only.
*
* ### ES6 Module Import
*
* `import "@ui5/webcomponents-fiori/dist/SideNavigationSubItem.js";`
*
* @constructor
* @extends SideNavigationSelectableItemBase
* @public
* @abstract
* @since 1.0.0-rc.8
*/
@customElement({
tag: "ui5-side-navigation-sub-item",
renderer: jsxRender,
template: SideNavigationSubItemTemplate,
styles: SideNavigationSubItemCss,
})
class SideNavigationSubItem extends SideNavigationSelectableItemBase {
/**
* Defines the tag to be displayed.
*
* **Note:** Only one `ui5-tag` is allowed. The tag should use `design="Set2"`, `hide-state-icon`,
* and `colorScheme` values 5-10 to avoid confusion with semantic colors (1-4).
*
* **Note:** It is recommended to limit tag width to 64px (4rem). If tag text exceeds this,
* use shortened forms or abbreviations (e.g., "Experimental" → "Exp").
*
* @public
* @since 2.7.0
*/
@slot({ type: HTMLElement })
tag!: Slot<HTMLElement>;
get hasTag() {
return !!this.tag.length;
}
get _textId() {
return `${this._id}-text`;
}
get _textAriaLabelledBy() {
if (this.hasTag) {
return `${this._textId} ${this._tagId}`;
}
return undefined;
}
get _describedBy() {
return this.hasTag ? this._tagId : undefined;
}
_onkeydown(e: KeyboardEvent) {
super._onkeydown(e);
}
_onkeyup(e: KeyboardEvent) {
super._onkeyup(e);
}
_onfocusin(e: FocusEvent) {
super._onfocusin(e);
}
_onclick(e: MouseEvent) {
super._onclick(e);
}
get classesArray() {
const classes = super.classesArray;
if (this.icon) {
classes.push("ui5-sn-item-has-icon");
}
if (this.effectiveDisabled) {
classes.push("ui5-sn-item-disabled");
}
return classes;
}
}
SideNavigationSubItem.define();
export default SideNavigationSubItem;