@momentum-design/components 0.91.1 → 0.91.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +408 -404
- package/dist/browser/index.js.map +4 -4
- package/dist/components/listitem/listitem.component.js +16 -19
- package/dist/components/listitem/listitem.constants.d.ts +1 -3
- package/dist/components/listitem/listitem.constants.js +1 -4
- package/dist/components/listitem/listitem.utils.d.ts +3 -0
- package/dist/components/listitem/listitem.utils.js +4 -0
- package/dist/components/menubar/menubar.component.d.ts +6 -2
- package/dist/components/menubar/menubar.component.js +52 -23
- package/dist/components/menupopover/menupopover.utils.d.ts +1 -2
- package/dist/components/menupopover/menupopover.utils.js +9 -6
- package/dist/components/menusection/menusection.component.d.ts +15 -0
- package/dist/components/menusection/menusection.component.js +38 -2
- package/dist/components/menusection/menusection.styles.js +9 -1
- package/dist/components/{navitem → navmenuitem}/index.d.ts +3 -3
- package/dist/components/navmenuitem/index.js +8 -0
- package/dist/components/{navitem/navitem.component.d.ts → navmenuitem/navmenuitem.component.d.ts} +35 -35
- package/dist/components/{navitem/navitem.component.js → navmenuitem/navmenuitem.component.js} +43 -45
- package/dist/components/{navitem/navitem.constants.d.ts → navmenuitem/navmenuitem.constants.d.ts} +1 -1
- package/dist/components/{navitem/navitem.constants.js → navmenuitem/navmenuitem.constants.js} +1 -1
- package/dist/components/{navitem/navitem.styles.js → navmenuitem/navmenuitem.styles.js} +33 -29
- package/dist/components/{navitem/navitem.types.d.ts → navmenuitem/navmenuitem.types.d.ts} +1 -1
- package/dist/components/popover/popover.component.js +1 -1
- package/dist/components/sidenavigation/index.d.ts +1 -0
- package/dist/components/sidenavigation/index.js +1 -0
- package/dist/components/sidenavigation/sidenavigation.component.d.ts +30 -11
- package/dist/components/sidenavigation/sidenavigation.component.js +60 -17
- package/dist/components/sidenavigation/sidenavigation.context.d.ts +5 -5
- package/dist/components/sidenavigation/sidenavigation.context.js +26 -25
- package/dist/custom-elements.json +838 -1195
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/react/index.d.ts +5 -6
- package/dist/react/index.js +5 -6
- package/dist/react/navmenuitem/index.d.ts +43 -0
- package/dist/react/navmenuitem/index.js +51 -0
- package/dist/react/sidenavigation/index.d.ts +10 -9
- package/dist/react/sidenavigation/index.js +10 -9
- package/package.json +1 -1
- package/dist/components/navitem/index.js +0 -8
- package/dist/components/navitemlist/index.d.ts +0 -7
- package/dist/components/navitemlist/index.js +0 -4
- package/dist/components/navitemlist/navitemlist.component.d.ts +0 -50
- package/dist/components/navitemlist/navitemlist.component.js +0 -89
- package/dist/components/navitemlist/navitemlist.constants.d.ts +0 -2
- package/dist/components/navitemlist/navitemlist.constants.js +0 -3
- package/dist/components/navitemlist/navitemlist.styles.d.ts +0 -2
- package/dist/components/navitemlist/navitemlist.styles.js +0 -23
- package/dist/react/navitem/index.d.ts +0 -43
- package/dist/react/navitem/index.js +0 -51
- package/dist/react/navitemlist/index.d.ts +0 -13
- package/dist/react/navitemlist/index.js +0 -22
- /package/dist/components/{navitem/navitem.styles.d.ts → navmenuitem/navmenuitem.styles.d.ts} +0 -0
- /package/dist/components/{navitem/navitem.types.js → navmenuitem/navmenuitem.types.js} +0 -0
package/dist/components/{navitem/navitem.component.js → navmenuitem/navmenuitem.component.js}
RENAMED
@@ -17,44 +17,44 @@ import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
|
|
17
17
|
import MenuItem from '../menuitem/menuitem.component';
|
18
18
|
import { getIconNameWithoutStyle } from '../button/button.utils';
|
19
19
|
import SideNavigation from '../sidenavigation/sidenavigation.component';
|
20
|
-
import { DEFAULTS, ALLOWED_BADGE_TYPES, ICON_NAME } from './
|
21
|
-
import styles from './
|
20
|
+
import { DEFAULTS, ALLOWED_BADGE_TYPES, ICON_NAME } from './navmenuitem.constants';
|
21
|
+
import styles from './navmenuitem.styles';
|
22
22
|
/**
|
23
|
-
* `mdc-
|
23
|
+
* `mdc-navmenuitem` is a menuitem styled to work as a navigation tab.
|
24
24
|
* It supports a leading icon, optional badge and dynamic text rendering.
|
25
25
|
*
|
26
|
-
* Note: `mdc-
|
26
|
+
* Note: `mdc-navmenuitem` is intended to be used inside `mdc-menubar` as part of the sideNavigation
|
27
27
|
* component. Its structure, spacing, and interactions are designed to align with
|
28
28
|
* the visual and functional requirements of side navigation layouts.
|
29
29
|
*
|
30
|
-
* @tagname mdc-
|
30
|
+
* @tagname mdc-navmenuitem
|
31
31
|
*
|
32
32
|
* @dependency mdc-icon
|
33
33
|
* @dependency mdc-text
|
34
34
|
* @dependency mdc-badge
|
35
35
|
* @dependency mdc-tooltip
|
36
36
|
*
|
37
|
-
* @event click - (React: onClick) This event is dispatched when the
|
38
|
-
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the
|
39
|
-
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the
|
40
|
-
* @event focus - (React: onFocus) This event is dispatched when the
|
41
|
-
* @event activechange - (React: onActiveChange) Dispatched when the active state of the
|
37
|
+
* @event click - (React: onClick) This event is dispatched when the navmenuitem is clicked.
|
38
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the navmenuitem.
|
39
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the navmenuitem.
|
40
|
+
* @event focus - (React: onFocus) This event is dispatched when the navmenuitem receives focus.
|
41
|
+
* @event activechange - (React: onActiveChange) Dispatched when the active state of the navmenuitem changes.
|
42
42
|
*
|
43
|
-
* @cssproperty --mdc-
|
44
|
-
* @cssproperty --mdc-
|
45
|
-
* @cssproperty --mdc-
|
46
|
-
* @cssproperty --mdc-
|
47
|
-
* @cssproperty --mdc-
|
48
|
-
* @cssproperty --mdc-
|
49
|
-
* @cssproperty --mdc-
|
50
|
-
* @cssproperty --mdc-
|
51
|
-
* @cssproperty --mdc-
|
52
|
-
* @cssproperty --mdc-
|
53
|
-
* @cssproperty --mdc-
|
43
|
+
* @cssproperty --mdc-navmenuitem-color - Text color of the navmenuitem in its normal state.
|
44
|
+
* @cssproperty --mdc-navmenuitem-border-color - Border color of the navmenuitem in its normal state.
|
45
|
+
* @cssproperty --mdc-navmenuitem-disabled-color - Text color of the navmenuitem when disabled.
|
46
|
+
* @cssproperty --mdc-navmenuitem-expanded-width - Width of the navmenuitem when expanded.
|
47
|
+
* @cssproperty --mdc-navmenuitem-hover-background-color - Background color of the navmenuitem when hovered.
|
48
|
+
* @cssproperty --mdc-navmenuitem-hover-active-background-color - Background color of the active navmenuitem when hovered.
|
49
|
+
* @cssproperty --mdc-navmenuitem-pressed-background-color - Background color of the navmenuitem when pressed.
|
50
|
+
* @cssproperty --mdc-navmenuitem-pressed-active-background-color - Background color of the active navmenuitem when pressed.
|
51
|
+
* @cssproperty --mdc-navmenuitem-disabled-background-color - Background color of the navmenuitem when disabled.
|
52
|
+
* @cssproperty --mdc-navmenuitem-disabled-active-background-color - Background color of the active navmenuitem when disabled.
|
53
|
+
* @cssproperty --mdc-navmenuitem-rest-active-background-color - Background color of the active nav item in its rest state.
|
54
54
|
*/
|
55
|
-
class
|
55
|
+
class NavMenuItem extends IconNameMixin(MenuItem) {
|
56
56
|
constructor() {
|
57
|
-
super(
|
57
|
+
super();
|
58
58
|
/**
|
59
59
|
* The maximum number can be set up to 999, anything above that will be rendered as _999+_.
|
60
60
|
* The max counter can be `9`, `99` or `999`.
|
@@ -72,28 +72,26 @@ class NavItem extends IconNameMixin(MenuItem) {
|
|
72
72
|
/**
|
73
73
|
* Dispatch the activechange event.
|
74
74
|
* @internal
|
75
|
-
* @param active - The active state of the
|
75
|
+
* @param active - The active state of the navMenuItem.
|
76
76
|
*/
|
77
|
-
this.
|
77
|
+
this.emitNavMenuItemActiveChange = (active) => {
|
78
78
|
const event = new CustomEvent('activechange', {
|
79
79
|
detail: { navId: this.navId, active },
|
80
80
|
bubbles: true,
|
81
81
|
});
|
82
82
|
this.dispatchEvent(event);
|
83
83
|
};
|
84
|
+
this.addEventListener('click', this.handleClickEvent);
|
84
85
|
}
|
85
86
|
connectedCallback() {
|
86
87
|
super.connectedCallback();
|
87
88
|
this.variant = undefined;
|
88
89
|
this.tooltipPlacement = undefined;
|
89
|
-
this.addEventListener('click', this.handleClickEvent);
|
90
90
|
if (!this.navId && this.onerror) {
|
91
|
-
this.onerror('[mdc-
|
91
|
+
this.onerror('[mdc-navmenuitem] navId is required and was not provided.');
|
92
92
|
}
|
93
|
-
|
94
|
-
|
95
|
-
super.disconnectedCallback();
|
96
|
-
this.removeEventListener('click', this.handleClickEvent);
|
93
|
+
// Set in-menupopover attribute if nested
|
94
|
+
this.toggleAttribute('in-menupopover', this.isNested());
|
97
95
|
}
|
98
96
|
updated() {
|
99
97
|
var _a, _b;
|
@@ -113,7 +111,7 @@ class NavItem extends IconNameMixin(MenuItem) {
|
|
113
111
|
}
|
114
112
|
}
|
115
113
|
/**
|
116
|
-
* Check whether the
|
114
|
+
* Check whether the navmenuitem is inside a nested nav structure.
|
117
115
|
* Returns `true` if there is a parent `mdc-menupopover`
|
118
116
|
* This method assumes nesting implies deeper levels of nav hierarchy.
|
119
117
|
*/
|
@@ -129,8 +127,8 @@ class NavItem extends IconNameMixin(MenuItem) {
|
|
129
127
|
}
|
130
128
|
/**
|
131
129
|
* Modifies the icon name based on the active state.
|
132
|
-
* If the
|
133
|
-
* If the
|
130
|
+
* If the navMenuItem is active, the icon name is suffixed with '-filled'.
|
131
|
+
* If the navMenuItem is inactive, the icon name is restored to its original value.
|
134
132
|
* If '-filled' icon is not available, the icon name remains unchanged.
|
135
133
|
* @internal
|
136
134
|
* @param active - The active state.
|
@@ -153,7 +151,7 @@ class NavItem extends IconNameMixin(MenuItem) {
|
|
153
151
|
handleClickEvent() {
|
154
152
|
if (this.disabled)
|
155
153
|
return;
|
156
|
-
this.
|
154
|
+
this.emitNavMenuItemActiveChange(this.active);
|
157
155
|
}
|
158
156
|
update(changedProperties) {
|
159
157
|
super.update(changedProperties);
|
@@ -207,37 +205,37 @@ class NavItem extends IconNameMixin(MenuItem) {
|
|
207
205
|
`;
|
208
206
|
}
|
209
207
|
}
|
210
|
-
|
208
|
+
NavMenuItem.styles = [...MenuItem.styles, ...styles];
|
211
209
|
__decorate([
|
212
210
|
property({ type: Boolean, reflect: true }),
|
213
211
|
__metadata("design:type", Boolean)
|
214
|
-
],
|
212
|
+
], NavMenuItem.prototype, "active", void 0);
|
215
213
|
__decorate([
|
216
214
|
property({ type: String, reflect: true, attribute: 'badge-type' }),
|
217
215
|
__metadata("design:type", String)
|
218
|
-
],
|
216
|
+
], NavMenuItem.prototype, "badgeType", void 0);
|
219
217
|
__decorate([
|
220
218
|
property({ type: Number, reflect: true }),
|
221
219
|
__metadata("design:type", Number)
|
222
|
-
],
|
220
|
+
], NavMenuItem.prototype, "counter", void 0);
|
223
221
|
__decorate([
|
224
222
|
property({ type: Number, attribute: 'max-counter', reflect: true }),
|
225
223
|
__metadata("design:type", Number)
|
226
|
-
],
|
224
|
+
], NavMenuItem.prototype, "maxCounter", void 0);
|
227
225
|
__decorate([
|
228
226
|
property({ type: String, reflect: true, attribute: 'nav-id' }),
|
229
227
|
__metadata("design:type", String)
|
230
|
-
],
|
228
|
+
], NavMenuItem.prototype, "navId", void 0);
|
231
229
|
__decorate([
|
232
230
|
property({ type: Boolean, reflect: true, attribute: 'show-label' }),
|
233
231
|
__metadata("design:type", Boolean)
|
234
|
-
],
|
232
|
+
], NavMenuItem.prototype, "showLabel", void 0);
|
235
233
|
__decorate([
|
236
234
|
property({ type: String, attribute: 'aria-label' }),
|
237
235
|
__metadata("design:type", Object)
|
238
|
-
],
|
236
|
+
], NavMenuItem.prototype, "ariaLabel", void 0);
|
239
237
|
__decorate([
|
240
238
|
property({ type: Boolean, reflect: true, attribute: 'disable-aria-current' }),
|
241
239
|
__metadata("design:type", Boolean)
|
242
|
-
],
|
243
|
-
export default
|
240
|
+
], NavMenuItem.prototype, "disableAriaCurrent", void 0);
|
241
|
+
export default NavMenuItem;
|
package/dist/components/{navitem/navitem.constants.js → navmenuitem/navmenuitem.constants.js}
RENAMED
@@ -3,7 +3,7 @@ import { BUTTON_SIZES } from '../buttonsimple/buttonsimple.constants';
|
|
3
3
|
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
4
4
|
import { TYPE as BADGE_TYPE } from '../badge/badge.constants';
|
5
5
|
import { VARIANTS } from '../sidenavigation/sidenavigation.constants';
|
6
|
-
const TAG_NAME = utils.constructTagName('
|
6
|
+
const TAG_NAME = utils.constructTagName('navmenuitem');
|
7
7
|
const ALLOWED_BADGE_TYPES = {
|
8
8
|
DOT: BADGE_TYPE.DOT,
|
9
9
|
COUNTER: BADGE_TYPE.COUNTER,
|
@@ -4,79 +4,83 @@ const styles = [
|
|
4
4
|
hostFitContentStyles,
|
5
5
|
css `
|
6
6
|
:host {
|
7
|
-
--mdc-
|
8
|
-
--mdc-
|
9
|
-
--mdc-
|
10
|
-
--mdc-
|
7
|
+
--mdc-navmenuitem-color: var(--mds-color-theme-text-primary-normal);
|
8
|
+
--mdc-navmenuitem-disabled-color: var(--mds-color-theme-text-primary-disabled);
|
9
|
+
--mdc-navmenuitem-border-color: var(--mds-color-theme-outline-button-normal);
|
10
|
+
--mdc-navmenuitem-expanded-width: 12.75rem;
|
11
11
|
|
12
12
|
/* Background color when in default (normal) or active state */
|
13
|
-
--mdc-
|
14
|
-
--mdc-
|
15
|
-
--mdc-
|
16
|
-
--mdc-
|
17
|
-
--mdc-
|
18
|
-
--mdc-
|
19
|
-
--mdc-
|
13
|
+
--mdc-navmenuitem-rest-active-background-color: var(--mds-color-theme-button-secondary-active-normal);
|
14
|
+
--mdc-navmenuitem-hover-background-color: var(--mds-color-theme-button-secondary-hover);
|
15
|
+
--mdc-navmenuitem-hover-active-background-color: var(--mds-color-theme-button-secondary-active-hover);
|
16
|
+
--mdc-navmenuitem-pressed-background-color: var(--mds-color-theme-button-secondary-pressed);
|
17
|
+
--mdc-navmenuitem-pressed-active-background-color: var(--mds-color-theme-button-secondary-active-pressed);
|
18
|
+
--mdc-navmenuitem-disabled-background-color: var(--mds-color-theme-button-secondary-disabled);
|
19
|
+
--mdc-navmenuitem-disabled-active-background-color: var(--mds-color-theme-button-secondary-active-disabled);
|
20
20
|
|
21
21
|
position: relative;
|
22
22
|
display: flex;
|
23
23
|
align-items: center;
|
24
24
|
gap: 0.5rem;
|
25
25
|
padding: 0.5rem;
|
26
|
-
color: var(--mdc-
|
27
|
-
border-color: var(--mdc-
|
28
|
-
border-radius:
|
26
|
+
color: var(--mdc-navmenuitem-color);
|
27
|
+
border-color: var(--mdc-navmenuitem-border-color);
|
28
|
+
border-radius: 0.5rem;
|
29
29
|
cursor: pointer;
|
30
30
|
}
|
31
31
|
|
32
|
-
:host(:
|
32
|
+
:host(:not([in-menupopover])) {
|
33
|
+
border-radius: 1.25rem;
|
34
|
+
}
|
35
|
+
|
36
|
+
:host(:not([in-menupopover]):dir(ltr)) {
|
33
37
|
margin-left: 1rem;
|
34
38
|
}
|
35
39
|
|
36
|
-
:host(:dir(rtl)) {
|
40
|
+
:host(:not([in-menupopover]):dir(rtl)) {
|
37
41
|
margin-right: 1rem;
|
38
42
|
}
|
39
43
|
|
40
44
|
:host([show-label]) {
|
41
|
-
width: var(--mdc-
|
45
|
+
width: var(--mdc-navmenuitem-expanded-width);
|
42
46
|
}
|
43
47
|
|
44
48
|
:host([active]) {
|
45
|
-
background-color: var(--mdc-
|
49
|
+
background-color: var(--mdc-navmenuitem-rest-active-background-color);
|
46
50
|
}
|
47
51
|
|
48
52
|
:host([disabled]) {
|
49
|
-
color: var(--mdc-
|
50
|
-
background-color: var(--mdc-
|
53
|
+
color: var(--mdc-navmenuitem-disabled-color);
|
54
|
+
background-color: var(--mdc-navmenuitem-disabled-background-color);
|
51
55
|
pointer-events: none;
|
52
56
|
}
|
53
57
|
|
54
58
|
:host([active][disabled]) {
|
55
|
-
background-color: var(--mdc-
|
56
|
-
color: var(--mdc-
|
59
|
+
background-color: var(--mdc-navmenuitem-disabled-active-background-color);
|
60
|
+
color: var(--mdc-navmenuitem-disabled-color);
|
57
61
|
}
|
58
62
|
|
59
63
|
:host(:hover) {
|
60
|
-
background-color: var(--mdc-
|
64
|
+
background-color: var(--mdc-navmenuitem-hover-background-color);
|
61
65
|
}
|
62
66
|
|
63
67
|
:host(:hover[active]) {
|
64
|
-
background-color: var(--mdc-
|
68
|
+
background-color: var(--mdc-navmenuitem-hover-active-background-color);
|
65
69
|
}
|
66
70
|
|
67
71
|
:host(:active) {
|
68
|
-
background-color: var(--mdc-
|
72
|
+
background-color: var(--mdc-navmenuitem-pressed-background-color);
|
69
73
|
}
|
70
74
|
|
71
75
|
:host(:active[active]) {
|
72
|
-
background-color: var(--mdc-
|
76
|
+
background-color: var(--mdc-navmenuitem-pressed-active-background-color);
|
73
77
|
}
|
74
78
|
|
75
|
-
:host::before {
|
79
|
+
:host(:not([in-menupopover]))::before {
|
76
80
|
content: '';
|
77
81
|
display: block;
|
78
82
|
position: absolute;
|
79
|
-
background-color: var(--mdc-
|
83
|
+
background-color: var(--mdc-navmenuitem-color);
|
80
84
|
width: 0.25rem;
|
81
85
|
height: 1rem;
|
82
86
|
pointer-events: none;
|
@@ -98,7 +102,7 @@ const styles = [
|
|
98
102
|
}
|
99
103
|
|
100
104
|
:host([disabled])::before {
|
101
|
-
background-color: var(--mdc-
|
105
|
+
background-color: var(--mdc-navmenuitem-disabled-color);
|
102
106
|
}
|
103
107
|
|
104
108
|
:host::part(text-container) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ValueOf } from '../../utils/types';
|
2
|
-
import { ALLOWED_BADGE_TYPES } from './
|
2
|
+
import { ALLOWED_BADGE_TYPES } from './navmenuitem.constants';
|
3
3
|
type BadgeType = ValueOf<typeof ALLOWED_BADGE_TYPES>;
|
4
4
|
interface Events {
|
5
5
|
onClickEvent: MouseEvent;
|
@@ -594,7 +594,7 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
594
594
|
this.removeEventListener('keydown', this.onEscapeKeydown);
|
595
595
|
(_e = this.triggerElement) === null || _e === void 0 ? void 0 : _e.removeEventListener('keydown', this.onEscapeKeydown);
|
596
596
|
}
|
597
|
-
if (
|
597
|
+
if (this.disableAriaExpanded) {
|
598
598
|
this.triggerElement.removeAttribute('aria-expanded');
|
599
599
|
}
|
600
600
|
// Remove aria-haspopup if the popover is not interactive
|
@@ -10,20 +10,20 @@ import SideNavigationContext from './sidenavigation.context';
|
|
10
10
|
* - Supports four layout variants: `fixed-collapsed`, `fixed-expanded`, `flexible`, and `hidden`
|
11
11
|
* - Toggleable expand/collapse behavior
|
12
12
|
* - Displays brand logo and customer name
|
13
|
-
* - Serves as a context provider for descendant components - `mdc-
|
13
|
+
* - Serves as a context provider for descendant components - `mdc-menubar` and `mdc-navmenuitem`
|
14
14
|
*
|
15
15
|
* ### Usage:
|
16
|
-
* In a sidenavigation,
|
16
|
+
* In a sidenavigation, navmenuitems can be used in the following ways:
|
17
17
|
*
|
18
|
-
* 1. **Simple
|
18
|
+
* 1. **Simple navmenuitem** – No submenu or interaction beyond selection.
|
19
19
|
*
|
20
|
-
* 2. **
|
21
|
-
* - Provide an `id` on the `mdc-
|
22
|
-
* - Set the `triggerId` on the corresponding `mdc-menupopover` to match the
|
20
|
+
* 2. **NavMenuItem with submenu**:
|
21
|
+
* - Provide an `id` on the `mdc-navmenuitem`
|
22
|
+
* - Set the `triggerId` on the corresponding `mdc-menupopover` to match the navmenuitem's `id`
|
23
23
|
* - Set `parent-nav-tooltip-text` with appropriate text that will display when a child menu item
|
24
24
|
* inside the nested menupopover is active, conveying which submenu item is currently selected
|
25
25
|
*
|
26
|
-
* 3. **Actionable
|
26
|
+
* 3. **Actionable navmenuitem (no submenu)**:
|
27
27
|
* - Performs an action such as navigation or alert trigger
|
28
28
|
* - Set `disable-aria-current="true"` to maintain visual active state without navigation behavior
|
29
29
|
*
|
@@ -33,15 +33,16 @@ import SideNavigationContext from './sidenavigation.context';
|
|
33
33
|
* - For the brand logo, use an informative icon. Refer to `Momentum Informative Icons`
|
34
34
|
*
|
35
35
|
* #### Accessibility Notes:
|
36
|
-
* - Always provide meaningful `aria-label` attributes for both `mdc-
|
36
|
+
* - Always provide meaningful `aria-label` attributes for both `mdc-navmenuitem` and `mdc-menubar`
|
37
37
|
* to ensure screen reader support
|
38
38
|
* - Set `grabber-btn-aria-label` to provide accessible labels for the expand/collapse grabber button
|
39
39
|
*
|
40
40
|
* @dependency mdc-text
|
41
41
|
* @dependency mdc-button
|
42
42
|
* @dependency mdc-divider
|
43
|
+
* @dependency mdc-menubar
|
43
44
|
*
|
44
|
-
* @event activechange - (React: onActiveChange) Dispatched when the active state of the
|
45
|
+
* @event activechange - (React: onActiveChange) Dispatched when the active state of the navmenuitem changes.
|
45
46
|
*
|
46
47
|
* @tagname mdc-sidenavigation
|
47
48
|
*
|
@@ -68,10 +69,10 @@ declare class SideNavigation extends Provider<SideNavigationContext> {
|
|
68
69
|
*/
|
69
70
|
variant: SideNavigationVariant;
|
70
71
|
/**
|
71
|
-
*
|
72
|
+
* Displays footer text in the bottom section of the sidenavigation.
|
72
73
|
* @default ''
|
73
74
|
*/
|
74
|
-
|
75
|
+
footerText: string;
|
75
76
|
/**
|
76
77
|
* Determines whether the sideNavigation is expanded or not.
|
77
78
|
*
|
@@ -115,6 +116,23 @@ declare class SideNavigation extends Provider<SideNavigationContext> {
|
|
115
116
|
* Is called on every re-render, see Provider class
|
116
117
|
*/
|
117
118
|
protected updateContext(): void;
|
119
|
+
/**
|
120
|
+
* Handle the navMenuItem active change event fired from the nested navMenuItem.
|
121
|
+
* @internal
|
122
|
+
* @param event - Custom Event fired from the nested navMenuItem.
|
123
|
+
*/
|
124
|
+
private handleNestedNavMenuItemActiveChange;
|
125
|
+
/**
|
126
|
+
* Matches new navMenuItem with navId.
|
127
|
+
* @param NavMenuItem - The new active navMenuItem.
|
128
|
+
*
|
129
|
+
* @internal
|
130
|
+
*/
|
131
|
+
private findNav;
|
132
|
+
/**
|
133
|
+
* Returns all nested, non-disabled mdc-navmenuitem elements inside this component.
|
134
|
+
*/
|
135
|
+
private get navMenuItems();
|
118
136
|
/**
|
119
137
|
* Syncs `expanded` and `aria-expanded` based on `variant` and `flexibleExpanded`.
|
120
138
|
*
|
@@ -138,6 +156,7 @@ declare class SideNavigation extends Provider<SideNavigationContext> {
|
|
138
156
|
* @internal
|
139
157
|
*/
|
140
158
|
private toggleSideNavigation;
|
159
|
+
private preventScrollOnSpace;
|
141
160
|
render(): import("lit-html").TemplateResult<1>;
|
142
161
|
static styles: Array<CSSResult>;
|
143
162
|
}
|
@@ -11,8 +11,10 @@ import { html, nothing } from 'lit';
|
|
11
11
|
import { property, state } from 'lit/decorators.js';
|
12
12
|
import { Component, Provider } from '../../models';
|
13
13
|
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
14
|
+
import { TAG_NAME as NAVMENUITEM_TAGNAME } from '../navmenuitem/navmenuitem.constants';
|
14
15
|
import { DIRECTIONS, DIVIDER_VARIANT, DIVIDER_ORIENTATION } from '../divider/divider.constants';
|
15
16
|
import { ROLE } from '../../utils/roles';
|
17
|
+
import { KEYS } from '../../utils/keys';
|
16
18
|
import { DEFAULTS, VARIANTS } from './sidenavigation.constants';
|
17
19
|
import SideNavigationContext from './sidenavigation.context';
|
18
20
|
import styles from './sidenavigation.styles';
|
@@ -24,20 +26,20 @@ import styles from './sidenavigation.styles';
|
|
24
26
|
* - Supports four layout variants: `fixed-collapsed`, `fixed-expanded`, `flexible`, and `hidden`
|
25
27
|
* - Toggleable expand/collapse behavior
|
26
28
|
* - Displays brand logo and customer name
|
27
|
-
* - Serves as a context provider for descendant components - `mdc-
|
29
|
+
* - Serves as a context provider for descendant components - `mdc-menubar` and `mdc-navmenuitem`
|
28
30
|
*
|
29
31
|
* ### Usage:
|
30
|
-
* In a sidenavigation,
|
32
|
+
* In a sidenavigation, navmenuitems can be used in the following ways:
|
31
33
|
*
|
32
|
-
* 1. **Simple
|
34
|
+
* 1. **Simple navmenuitem** – No submenu or interaction beyond selection.
|
33
35
|
*
|
34
|
-
* 2. **
|
35
|
-
* - Provide an `id` on the `mdc-
|
36
|
-
* - Set the `triggerId` on the corresponding `mdc-menupopover` to match the
|
36
|
+
* 2. **NavMenuItem with submenu**:
|
37
|
+
* - Provide an `id` on the `mdc-navmenuitem`
|
38
|
+
* - Set the `triggerId` on the corresponding `mdc-menupopover` to match the navmenuitem's `id`
|
37
39
|
* - Set `parent-nav-tooltip-text` with appropriate text that will display when a child menu item
|
38
40
|
* inside the nested menupopover is active, conveying which submenu item is currently selected
|
39
41
|
*
|
40
|
-
* 3. **Actionable
|
42
|
+
* 3. **Actionable navmenuitem (no submenu)**:
|
41
43
|
* - Performs an action such as navigation or alert trigger
|
42
44
|
* - Set `disable-aria-current="true"` to maintain visual active state without navigation behavior
|
43
45
|
*
|
@@ -47,15 +49,16 @@ import styles from './sidenavigation.styles';
|
|
47
49
|
* - For the brand logo, use an informative icon. Refer to `Momentum Informative Icons`
|
48
50
|
*
|
49
51
|
* #### Accessibility Notes:
|
50
|
-
* - Always provide meaningful `aria-label` attributes for both `mdc-
|
52
|
+
* - Always provide meaningful `aria-label` attributes for both `mdc-navmenuitem` and `mdc-menubar`
|
51
53
|
* to ensure screen reader support
|
52
54
|
* - Set `grabber-btn-aria-label` to provide accessible labels for the expand/collapse grabber button
|
53
55
|
*
|
54
56
|
* @dependency mdc-text
|
55
57
|
* @dependency mdc-button
|
56
58
|
* @dependency mdc-divider
|
59
|
+
* @dependency mdc-menubar
|
57
60
|
*
|
58
|
-
* @event activechange - (React: onActiveChange) Dispatched when the active state of the
|
61
|
+
* @event activechange - (React: onActiveChange) Dispatched when the active state of the navmenuitem changes.
|
59
62
|
*
|
60
63
|
* @tagname mdc-sidenavigation
|
61
64
|
*
|
@@ -82,10 +85,10 @@ class SideNavigation extends Provider {
|
|
82
85
|
*/
|
83
86
|
this.variant = DEFAULTS.VARIANT;
|
84
87
|
/**
|
85
|
-
*
|
88
|
+
* Displays footer text in the bottom section of the sidenavigation.
|
86
89
|
* @default ''
|
87
90
|
*/
|
88
|
-
this.
|
91
|
+
this.footerText = '';
|
89
92
|
/**
|
90
93
|
* Toggles between true and false when it's variant is flexible.
|
91
94
|
* @default true
|
@@ -104,6 +107,25 @@ class SideNavigation extends Provider {
|
|
104
107
|
* @internal
|
105
108
|
*/
|
106
109
|
this.arrowDirection = this.flexibleExpanded ? DIRECTIONS.NEGATIVE : DIRECTIONS.POSITIVE;
|
110
|
+
/**
|
111
|
+
* Handle the navMenuItem active change event fired from the nested navMenuItem.
|
112
|
+
* @internal
|
113
|
+
* @param event - Custom Event fired from the nested navMenuItem.
|
114
|
+
*/
|
115
|
+
this.handleNestedNavMenuItemActiveChange = (event) => {
|
116
|
+
var _a;
|
117
|
+
if ((_a = this.context) === null || _a === void 0 ? void 0 : _a.value) {
|
118
|
+
const newNavMenuItem = this.findNav(this.navMenuItems, event.detail.navId);
|
119
|
+
this.context.value.setCurrentActiveNavMenuItem(newNavMenuItem);
|
120
|
+
}
|
121
|
+
};
|
122
|
+
/**
|
123
|
+
* Matches new navMenuItem with navId.
|
124
|
+
* @param NavMenuItem - The new active navMenuItem.
|
125
|
+
*
|
126
|
+
* @internal
|
127
|
+
*/
|
128
|
+
this.findNav = (navs, navId) => navs.find(nav => nav.navId === navId);
|
107
129
|
/**
|
108
130
|
* Syncs `expanded` and `aria-expanded` based on `variant` and `flexibleExpanded`.
|
109
131
|
*
|
@@ -123,6 +145,7 @@ class SideNavigation extends Provider {
|
|
123
145
|
default:
|
124
146
|
}
|
125
147
|
};
|
148
|
+
this.addEventListener('activechange', this.handleNestedNavMenuItemActiveChange);
|
126
149
|
}
|
127
150
|
connectedCallback() {
|
128
151
|
super.connectedCallback();
|
@@ -157,6 +180,12 @@ class SideNavigation extends Provider {
|
|
157
180
|
this.context.updateObservers();
|
158
181
|
}
|
159
182
|
}
|
183
|
+
/**
|
184
|
+
* Returns all nested, non-disabled mdc-navmenuitem elements inside this component.
|
185
|
+
*/
|
186
|
+
get navMenuItems() {
|
187
|
+
return Array.from(this.querySelectorAll(`${NAVMENUITEM_TAGNAME}:not([disabled])`));
|
188
|
+
}
|
160
189
|
/**
|
161
190
|
* Sets the variant attribute for the sideNavigation component.
|
162
191
|
* If the provided variant is not included in the variant,
|
@@ -180,6 +209,12 @@ class SideNavigation extends Provider {
|
|
180
209
|
this.arrowDirection = this.arrowDirection === DIRECTIONS.NEGATIVE ? DIRECTIONS.POSITIVE : DIRECTIONS.NEGATIVE;
|
181
210
|
this.updateExpansionState();
|
182
211
|
}
|
212
|
+
preventScrollOnSpace(event) {
|
213
|
+
// Prevent default space key behavior to avoid scrolling the page
|
214
|
+
if (event.key === KEYS.SPACE) {
|
215
|
+
event.preventDefault();
|
216
|
+
}
|
217
|
+
}
|
183
218
|
render() {
|
184
219
|
var _a;
|
185
220
|
if (this.variant === VARIANTS.HIDDEN) {
|
@@ -187,17 +222,25 @@ class SideNavigation extends Provider {
|
|
187
222
|
}
|
188
223
|
return html `
|
189
224
|
<div part="side-navigation-container" id="side-nav-container">
|
190
|
-
<div part="scrollable-section">
|
191
|
-
<slot name="scrollable-section"
|
225
|
+
<div part="scrollable-section" tabindex="-1" @keydown=${this.preventScrollOnSpace}>
|
226
|
+
<slot name="scrollable-section">
|
227
|
+
<mdc-menubar>
|
228
|
+
<slot name="scrollable-menubar"></slot>
|
229
|
+
</mdc-menubar>
|
230
|
+
</slot>
|
192
231
|
</div>
|
193
232
|
<mdc-divider variant="gradient" part="separator"></mdc-divider>
|
194
233
|
<div part="fixed-section">
|
195
|
-
<slot name="fixed-section"
|
234
|
+
<slot name="fixed-section">
|
235
|
+
<mdc-menubar>
|
236
|
+
<slot name="fixed-menubar"></slot>
|
237
|
+
</mdc-menubar>
|
238
|
+
</slot>
|
196
239
|
<div part="brand-logo-container">
|
197
240
|
<slot name="brand-logo"></slot>
|
198
241
|
${this.expanded
|
199
242
|
? html `<mdc-text type=${TYPE.BODY_MIDSIZE_MEDIUM} tagname=${VALID_TEXT_TAGS.SPAN} part="label"
|
200
|
-
>${this.
|
243
|
+
>${this.footerText}</mdc-text
|
201
244
|
>`
|
202
245
|
: nothing}
|
203
246
|
</div>
|
@@ -228,9 +271,9 @@ __decorate([
|
|
228
271
|
__metadata("design:type", String)
|
229
272
|
], SideNavigation.prototype, "variant", void 0);
|
230
273
|
__decorate([
|
231
|
-
property({ type: String, reflect: true, attribute: '
|
274
|
+
property({ type: String, reflect: true, attribute: 'footer-text' }),
|
232
275
|
__metadata("design:type", String)
|
233
|
-
], SideNavigation.prototype, "
|
276
|
+
], SideNavigation.prototype, "footerText", void 0);
|
234
277
|
__decorate([
|
235
278
|
property({ type: Boolean, reflect: true }),
|
236
279
|
__metadata("design:type", Boolean)
|
@@ -1,15 +1,15 @@
|
|
1
|
-
import type
|
1
|
+
import type NavMenuItem from '../navmenuitem/navmenuitem.component';
|
2
2
|
declare class SideNavigationContext {
|
3
3
|
variant?: string;
|
4
4
|
expanded?: boolean;
|
5
|
-
private
|
5
|
+
private currentActiveNavMenuItem?;
|
6
6
|
parentNavTooltipText?: string;
|
7
7
|
static context: {
|
8
8
|
__context__: SideNavigationContext;
|
9
9
|
};
|
10
10
|
constructor(defaultVariant?: string, defaultExpanded?: boolean, defaultParentNavTooltipText?: string);
|
11
|
-
hasSiblingWithTriggerId(
|
12
|
-
private
|
13
|
-
|
11
|
+
hasSiblingWithTriggerId(navMenuItem: NavMenuItem | undefined): boolean;
|
12
|
+
private getParentNavMenuItems;
|
13
|
+
setCurrentActiveNavMenuItem(navMenuItem: NavMenuItem | undefined): void;
|
14
14
|
}
|
15
15
|
export default SideNavigationContext;
|