@@ -6,154 +6,72 @@ import type SideNavigationItem from "./SideNavigationItem.js";
6
6
7
7
export default function SideNavigationItemTemplate ( this : SideNavigationItem ) {
8
8
if ( this . sideNavCollapsed ) {
9
- return MenuItemTemplate . call ( this ) ;
9
+ return ItemTemplate . call ( this ) ;
10
10
}
11
- return TreeItemTemplate . call ( this ) ;
11
+
12
+ return (
13
+ < li id = { this . _id } class = "ui5-sn-list-li" role = "none" >
14
+ { ItemTemplate . call ( this ) }
15
+ </ li >
16
+ ) ;
12
17
}
13
18
14
- function MenuItemTemplate ( this : SideNavigationItem ) {
15
- return ( < >
16
- { this . _href ?
17
- < a id = { this . _id }
18
- class = { `ui5-sn-item ui5-sn-item-level1 ${ this . _classes } ` }
19
- role = { this . ariaRole }
20
- data-sap-focus-ref
21
- onKeyDown = { this . _onkeydown }
22
- onKeyUp = { this . _onkeyup }
23
- onClick = { this . _onclick }
24
- onFocusIn = { this . _onfocusin }
25
- onFocusOut = { this . _onfocusout }
26
- onMouseEnter = { this . _onmouseenter }
27
- onMouseLeave = { this . _onmouseleave }
28
- tabIndex = { this . effectiveTabIndex !== undefined ? parseInt ( this . effectiveTabIndex ) : undefined }
29
- aria-haspopup = { this . _ariaHasPopup }
30
- aria-checked = { this . _ariaChecked }
31
- title = { this . _tooltip }
32
- href = { this . _href }
33
- target = { this . _target }
19
+ function ItemTemplate ( this : SideNavigationItem ) {
20
+ const EffectiveTag = this . _effectiveTag ;
21
+
22
+ return (
23
+ < >
24
+ < EffectiveTag id = { this . _id }
25
+ data-sap-focus-ref
26
+ class = { `ui5-sn-item ui5-sn-item-level1 ${ this . _classes } ` }
27
+ role = { this . ariaRole }
28
+ onKeyDown = { this . _onkeydown }
29
+ onKeyUp = { this . _onkeyup }
30
+ onClick = { this . _onclick }
31
+ onFocusIn = { this . _onfocusin }
32
+ tabIndex = { this . effectiveTabIndex }
33
+ aria-current = { this . _ariaCurrent }
34
+ aria-selected = { this . _ariaSelected }
35
+ title = { this . _tooltip }
36
+ aria-disabled = { this . effectiveDisabled }
37
+ href = { this . _href }
38
+ target = { this . _target }
39
+ aria-haspopup = { this . _ariaHasPopup }
40
+ onFocusOut = { this . _onfocusout }
41
+ onMouseEnter = { this . _onmouseenter }
42
+ onMouseLeave = { this . _onmouseleave }
43
+ aria-checked = { this . _ariaChecked }
44
+ aria-owns = { this . _groupId }
45
+ aria-label = { this . _ariaLabel }
46
+ aria-expanded = { this . _expanded }
34
47
>
35
- < Icon class = "ui5-sn-item-icon" name = { this . icon } />
48
+ { this . sideNavCollapsed ?
49
+ < Icon class = "ui5-sn-item-icon" name = { this . icon } />
50
+ :
51
+ this . icon && < Icon class = "ui5-sn-item-icon" name = { this . icon } />
52
+ }
36
53
< div class = "ui5-sn-item-text" > { this . text } </ div >
37
- { ! ! this . items . length &&
54
+ { this . sideNavCollapsed ?
55
+ ! ! this . items . length &&
38
56
< Icon class = "ui5-sn-item-toggle-icon"
39
- name = { navRightArrow }
57
+ name = { navRightArrow }
40
58
/>
41
- }
42
- { this . isExternalLink &&
43
- < Icon class = "ui5-sn-item-external-link-icon"
44
- name = { arrowRight }
45
- />
46
- }
47
- </ a >
48
- :
49
- < div id = { this . _id }
50
- class = { `ui5-sn-item ui5-sn-item-level1 ${ this . _classes } ` }
51
- role = { this . ariaRole }
52
- data-sap-focus-ref
53
- onKeyDown = { this . _onkeydown }
54
- onKeyUp = { this . _onkeyup }
55
- onClick = { this . _onclick }
56
- onFocusIn = { this . _onfocusin }
57
- onFocusOut = { this . _onfocusout }
58
- onMouseEnter = { this . _onmouseenter }
59
- onMouseLeave = { this . _onmouseleave }
60
- tabIndex = { this . effectiveTabIndex !== undefined ? parseInt ( this . effectiveTabIndex ) : undefined }
61
- aria-haspopup = { this . _ariaHasPopup }
62
- aria-checked = { this . _ariaChecked }
63
- title = { this . _tooltip }
64
- aria-label = { this . _ariaLabel }
65
- >
66
- < Icon class = "ui5-sn-item-icon" name = { this . icon } />
67
- < div class = "ui5-sn-item-text" > { this . text } </ div >
68
- { ! ! this . items . length &&
59
+ :
60
+ ! ! this . items . length &&
69
61
< Icon class = "ui5-sn-item-toggle-icon"
70
- name = { navRightArrow }
62
+ name = { this . expanded ? navDownArrow : navRightArrow }
63
+ accessibleName = { this . _arrowTooltip }
64
+ showTooltip = { true }
65
+ onClick = { this . _onToggleClick }
71
66
/>
72
67
}
73
68
{ this . isExternalLink &&
74
69
< Icon class = "ui5-sn-item-external-link-icon"
75
- name = { arrowRight }
70
+ name = { arrowRight }
76
71
/>
77
72
}
78
- </ div >
79
- }
80
- </ > ) ;
81
- }
82
-
83
- function TreeItemTemplate ( this : SideNavigationItem ) {
84
- return (
85
- < li id = { this . _id } class = "ui5-sn-list-li" role = "none" >
86
- { this . _href ?
87
- < a class = { `ui5-sn-item ui5-sn-item-level1 ${ this . _classes } ` }
88
- role = { this . ariaRole }
89
- data-sap-focus-ref
90
- onKeyDown = { this . _onkeydown }
91
- onKeyUp = { this . _onkeyup }
92
- onClick = { this . _onclick }
93
- onFocusIn = { this . _onfocusin }
94
- tabIndex = { this . effectiveTabIndex !== undefined ? parseInt ( this . effectiveTabIndex ) : undefined }
95
- aria-expanded = { this . _expanded }
96
- aria-current = { this . _ariaCurrent }
97
- aria-selected = { this . selected }
98
- title = { this . _tooltip }
99
- aria-owns = { this . _groupId }
100
- href = { this . _href }
101
- target = { this . _target }
102
- >
103
- { this . icon &&
104
- < Icon class = "ui5-sn-item-icon" name = { this . icon } />
105
- }
106
- < div class = "ui5-sn-item-text" > { this . text } </ div >
107
- { this . isExternalLink &&
108
- < Icon class = "ui5-sn-item-external-link-icon"
109
- name = { arrowRight }
110
- />
111
- }
112
- { ! ! this . items . length &&
113
- < Icon class = "ui5-sn-item-toggle-icon"
114
- name = { this . expanded ? navDownArrow : navRightArrow }
115
- accessibleName = { this . _arrowTooltip }
116
- showTooltip = { true }
117
- onClick = { this . _onToggleClick }
118
- />
119
- }
120
- </ a >
121
- :
122
- < div class = { `ui5-sn-item ui5-sn-item-level1 ${ this . _classes } ` }
123
- role = { this . ariaRole }
124
- data-sap-focus-ref
125
- onKeyDown = { this . _onkeydown }
126
- onKeyUp = { this . _onkeyup }
127
- onClick = { this . _onclick }
128
- onFocusIn = { this . _onfocusin }
129
- tabIndex = { this . effectiveTabIndex !== undefined ? parseInt ( this . effectiveTabIndex ) : undefined }
130
- aria-expanded = { this . _expanded }
131
- aria-current = { this . _ariaCurrent }
132
- aria-selected = { this . selected }
133
- aria-haspopup = { this . accessibilityAttributes ?. hasPopup }
134
- title = { this . _tooltip }
135
- aria-owns = { this . _groupId }
136
- >
137
- { this . icon &&
138
- < Icon class = "ui5-sn-item-icon" name = { this . icon } />
139
- }
140
- < div class = "ui5-sn-item-text" > { this . text } </ div >
141
- { this . isExternalLink &&
142
- < Icon class = "ui5-sn-item-external-link-icon"
143
- name = { arrowRight }
144
- />
145
- }
146
- { ! ! this . items . length &&
147
- < Icon class = "ui5-sn-item-toggle-icon"
148
- name = { this . expanded ? navDownArrow : navRightArrow }
149
- accessibleName = { this . _arrowTooltip }
150
- showTooltip = { true }
151
- onClick = { this . _onToggleClick }
152
- />
153
- }
154
- </ div >
155
- }
156
- { ! ! this . items . length &&
73
+ </ EffectiveTag >
74
+ { ! this . sideNavCollapsed && ! ! this . items . length &&
157
75
< ul id = { this . _groupId }
158
76
class = "ui5-sn-item-ul"
159
77
aria-label = { this . text }
@@ -162,6 +80,6 @@ function TreeItemTemplate(this: SideNavigationItem) {
162
80
< slot > </ slot >
163
81
</ ul >
164
82
}
165
- </ li >
83
+ </ >
166
84
) ;
167
85
}
0 commit comments