@momentum-design/components 0.123.5 → 0.124.0

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.
Files changed (30) hide show
  1. package/dist/browser/index.js +406 -293
  2. package/dist/browser/index.js.map +3 -3
  3. package/dist/components/menubar/menubar.component.js +1 -1
  4. package/dist/components/menuitem/menuitem.styles.js +1 -1
  5. package/dist/components/menusection/menusection.component.d.ts +5 -0
  6. package/dist/components/menusection/menusection.component.js +5 -0
  7. package/dist/components/menusection/menusection.styles.js +10 -7
  8. package/dist/components/navmenuitem/navmenuitem.component.d.ts +74 -27
  9. package/dist/components/navmenuitem/navmenuitem.component.js +135 -87
  10. package/dist/components/navmenuitem/navmenuitem.constants.d.ts +1 -0
  11. package/dist/components/navmenuitem/navmenuitem.constants.js +1 -0
  12. package/dist/components/navmenuitem/navmenuitem.styles.js +64 -29
  13. package/dist/components/popover/popover.component.js +4 -2
  14. package/dist/components/sidenavigation/sidenavigation.component.d.ts +50 -6
  15. package/dist/components/sidenavigation/sidenavigation.component.js +132 -25
  16. package/dist/components/sidenavigation/sidenavigation.constants.d.ts +1 -0
  17. package/dist/components/sidenavigation/sidenavigation.constants.js +1 -0
  18. package/dist/components/sidenavigation/sidenavigation.context.d.ts +1 -2
  19. package/dist/components/sidenavigation/sidenavigation.context.js +8 -9
  20. package/dist/components/sidenavigation/sidenavigation.styles.js +76 -8
  21. package/dist/custom-elements.json +447 -237
  22. package/dist/react/index.d.ts +1 -1
  23. package/dist/react/index.js +1 -1
  24. package/dist/react/menusection/index.d.ts +5 -0
  25. package/dist/react/menusection/index.js +5 -0
  26. package/dist/react/navmenuitem/index.d.ts +9 -3
  27. package/dist/react/navmenuitem/index.js +9 -3
  28. package/dist/react/sidenavigation/index.d.ts +12 -2
  29. package/dist/react/sidenavigation/index.js +12 -2
  30. package/package.json +1 -1
@@ -327,7 +327,7 @@ class MenuBar extends Component {
327
327
  }
328
328
  }
329
329
  render() {
330
- return html `<slot role="${ROLE.GROUP}"></slot>`;
330
+ return html `<slot></slot>`;
331
331
  }
332
332
  }
333
333
  MenuBar.styles = [...Component.styles, ...styles];
@@ -6,7 +6,7 @@ const styles = css `
6
6
  }
7
7
  :host::part(trailing-arrow),
8
8
  :host::part(leading-arrow) {
9
- --mdc-icon-size: 1.25rem;
9
+ --mdc-icon-size: 1rem;
10
10
  }
11
11
  `;
12
12
  export default [styles];
@@ -21,6 +21,11 @@ import type { IconNames } from '../icon/icon.types';
21
21
  * @csspart align-header - The header of the menusection when it is aligned to the start.
22
22
  * @csspart container - The container of the menusection.
23
23
  * @csspart divider - The divider of the menusection.
24
+ *
25
+ * @cssproperty --mdc-menusection-divider-margin-block - Sets the margin block of the divider.
26
+ * @cssproperty --mdc-menusection-gap - Sets the gap between items in the menusection.
27
+ * @cssproperty --mdc-menusection-divider-width - Sets the width of the divider.
28
+ * @cssproperty --mdc-menusection-header-padding - Sets the padding of the header, if present.
24
29
  */
25
30
  declare class MenuSection extends Component {
26
31
  /**
@@ -36,6 +36,11 @@ import { DEFAULTS } from './menusection.constants';
36
36
  * @csspart align-header - The header of the menusection when it is aligned to the start.
37
37
  * @csspart container - The container of the menusection.
38
38
  * @csspart divider - The divider of the menusection.
39
+ *
40
+ * @cssproperty --mdc-menusection-divider-margin-block - Sets the margin block of the divider.
41
+ * @cssproperty --mdc-menusection-gap - Sets the gap between items in the menusection.
42
+ * @cssproperty --mdc-menusection-divider-width - Sets the width of the divider.
43
+ * @cssproperty --mdc-menusection-header-padding - Sets the padding of the header, if present.
39
44
  */
40
45
  class MenuSection extends Component {
41
46
  constructor() {
@@ -1,21 +1,24 @@
1
1
  import { css } from 'lit';
2
2
  const styles = css `
3
3
  :host {
4
+ --mdc-menusection-divider-margin-block: 0.25rem;
5
+ --mdc-menusection-gap: 0rem;
6
+ --mdc-menusection-divider-width: 100%;
7
+ --mdc-menusection-header-padding: 0.5rem 1.75rem;
8
+
4
9
  display: flex;
5
10
  flex-direction: column;
6
11
  height: 100%;
12
+ gap: var(--mdc-menusection-gap);
7
13
  }
8
14
 
9
15
  :host::part(divider) {
10
- margin-block: 0.25rem;
11
- }
12
-
13
- :host(:dir(ltr))::part(align-header) {
14
- padding-left: 1.75rem;
16
+ width: var(--mdc-menusection-divider-width);
17
+ margin-block: var(--mdc-menusection-divider-margin-block);
15
18
  }
16
19
 
17
- :host(:dir(rtl))::part(align-header) {
18
- padding-right: 1.75rem;
20
+ :host::part(align-header) {
21
+ --mdc-listheader-padding: var(--mdc-menusection-header-padding);
19
22
  }
20
23
  `;
21
24
  export default [styles];
@@ -1,11 +1,14 @@
1
- import type { CSSResult, PropertyValues } from 'lit';
1
+ import type { CSSResult, TemplateResult } from 'lit';
2
2
  import MenuItem from '../menuitem/menuitem.component';
3
+ import type { IconNames } from '../icon/icon.types';
4
+ import type { PopoverPlacement } from '../popover/popover.types';
3
5
  import type { BadgeType } from './navmenuitem.types';
4
- declare const NavMenuItem_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof MenuItem;
5
6
  /**
6
7
  * `mdc-navmenuitem` is a menuitem styled to work as a navigation tab.
7
8
  * It supports a leading icon, optional badge and dynamic text rendering.
8
9
  *
10
+ * The navmenuitem can be in an active or inactive state, indicating whether it is currently selected.
11
+ *
9
12
  * Note: `mdc-navmenuitem` is intended to be used inside `mdc-menubar` as part of the sideNavigation
10
13
  * component. Its structure, spacing, and interactions are designed to align with
11
14
  * the visual and functional requirements of side navigation layouts.
@@ -25,17 +28,21 @@ declare const NavMenuItem_base: import("../../utils/mixins/index.types").Constru
25
28
  * @event focus - (React: onFocus) This event is dispatched when the navmenuitem receives focus.
26
29
  * @event activechange - (React: onActiveChange) Dispatched when the active state of the navmenuitem changes.
27
30
  *
31
+ * @cssproperty --mdc-navmenuitem-in-sidenav-expanded-width - Width of the navmenuitem when expanded.
32
+ * @cssproperty --mdc-navmenuitem-in-sidenav-expanded-margin-left - Left margin of the navmenuitem, when expanded.
33
+ * @cssproperty --mdc-navmenuitem-in-sidenav-expanded-margin-right - Right margin of the navmenuitem, when expanded.
34
+ * @cssproperty --mdc-navmenuitem-in-sidenav-collapsed-width - Width of the navmenuitem when collapsed.
35
+ * @cssproperty --mdc-navmenuitem-in-sidenav-collapsed-margin-left - Left margin of the navmenuitem, when collapsed.
36
+ * @cssproperty --mdc-navmenuitem-in-sidenav-collapsed-margin-right - Right margin of the navmenuitem, when collapsed.
28
37
  * @cssproperty --mdc-navmenuitem-color - Text color of the navmenuitem in its normal state.
29
- * @cssproperty --mdc-navmenuitem-border-color - Border color of the navmenuitem in its normal state.
30
38
  * @cssproperty --mdc-navmenuitem-disabled-color - Text color of the navmenuitem when disabled.
31
- * @cssproperty --mdc-navmenuitem-expanded-width - Width of the navmenuitem when expanded.
39
+ * @cssproperty --mdc-navmenuitem-rest-active-background-color - Background color of the active nav item in its rest state.
32
40
  * @cssproperty --mdc-navmenuitem-hover-background-color - Background color of the navmenuitem when hovered.
33
41
  * @cssproperty --mdc-navmenuitem-hover-active-background-color - Background color of the active navmenuitem when hovered.
34
42
  * @cssproperty --mdc-navmenuitem-pressed-background-color - Background color of the navmenuitem when pressed.
35
43
  * @cssproperty --mdc-navmenuitem-pressed-active-background-color - Background color of the active navmenuitem when pressed.
36
44
  * @cssproperty --mdc-navmenuitem-disabled-background-color - Background color of the navmenuitem when disabled.
37
45
  * @cssproperty --mdc-navmenuitem-disabled-active-background-color - Background color of the active navmenuitem when disabled.
38
- * @cssproperty --mdc-navmenuitem-rest-active-background-color - Background color of the active nav item in its rest state.
39
46
  *
40
47
  * @csspart arrow - The arrow of the navmenuitem.
41
48
  * @csspart badge - The badge of the navmenuitem.
@@ -43,14 +50,30 @@ declare const NavMenuItem_base: import("../../utils/mixins/index.types").Constru
43
50
  * @csspart text-container - The container of the text.
44
51
  * @csspart trailing-arrow - The trailing arrow of the navmenuitem.
45
52
  */
46
- declare class NavMenuItem extends NavMenuItem_base {
53
+ declare class NavMenuItem extends MenuItem {
47
54
  /**
48
55
  * The navmenuitem's active state indicates whether it is currently toggled on (active) or off (inactive).
49
- * When the active state is true, the navmenuitem is considered to be in an active state, meaning it is toggled on.
50
- * Conversely, when the active state is false, the navmenuitem is in an inactive state, indicating it is toggled off.
56
+ * If cannotActivate is set to true, the surrounding SideNavigation will
57
+ * not set this property when the navmenuitem is clicked.
58
+ *
51
59
  * @default undefined
52
60
  */
53
61
  active?: boolean;
62
+ /**
63
+ * When set to true, prevents the navmenuitem from being activated.
64
+ * This is useful for cases where the navmenuitem is used as a button
65
+ * or link, where not the content on the current page is changing.
66
+ * By default this is set to false, making the navmenuitem activatable (= aria-current gets set when active).
67
+ *
68
+ * @default false
69
+ */
70
+ cannotActivate?: boolean;
71
+ /**
72
+ * Name of the leading icon (= filename).
73
+ *
74
+ * If no `icon-name` is provided, no icon will be rendered.
75
+ */
76
+ iconName?: IconNames;
54
77
  /**
55
78
  * Type of the badge
56
79
  * Can be `dot` (notification) or `counter`.
@@ -74,9 +97,10 @@ declare class NavMenuItem extends NavMenuItem_base {
74
97
  */
75
98
  navId?: string;
76
99
  /**
77
- * Determines whether the navMenuItem is expanded or not.
100
+ * Determines whether the nav item is expanded or not.
78
101
  *
79
- * @internal
102
+ * If used in SideNavigation, this property is automatically managed by the SideNavigation component.
103
+ * @default undefined
80
104
  */
81
105
  showLabel?: boolean;
82
106
  /**
@@ -88,16 +112,50 @@ declare class NavMenuItem extends NavMenuItem_base {
88
112
  * when it becomes active. This is useful for cases where you want to maintain the visual active styling
89
113
  * but need to handle aria-current attribute differently or not at all.
90
114
  * The active button styling will still be applied regardless of this setting.
115
+ *
116
+ * If you also want to prevent activation, use the `cannot-activate` property instead.
117
+ *
118
+ * @default undefined
91
119
  */
92
120
  disableAriaCurrent?: boolean;
93
121
  /**
94
- * The tooltip text is displayed on hover of the list item.
122
+ * The tooltip text is displayed on hover of the nav item.
123
+ * Will only be shown when the `show-label` property is false
124
+ * (i.e., when the nav item is collapsed).
95
125
  */
96
126
  tooltipText?: string;
97
127
  /**
128
+ * The placement of the tooltip relative to the nav item.
129
+ * @default 'right'
130
+ */
131
+ tooltipPlacement: PopoverPlacement;
132
+ /**
133
+ * The appearance behavior of the tooltip.
134
+ * Options are 'when-collapsed' (default) or 'always'.
135
+ *
136
+ * @default 'when-collapsed'
137
+ */
138
+ tooltipAppearance: 'when-collapsed' | 'always';
139
+ /**
140
+ * The boundary padding for the tooltip.
141
+ * This defines the minimum distance in pixels between the tooltip and the edges of the viewport.
142
+ * @default 0
143
+ */
144
+ tooltipBoundaryPadding?: number;
145
+ /**
146
+ * Tooltip text shown when this parent NavItem has a active child navitem.
147
+ * This is useful for nested navmenuitems within a sidenavigation.
148
+ *
149
+ * Make sure to include what was normally used as the `tooltip-text` in this property.
150
+ * i.e. `Messaging, contains active navmenuitem`
151
+ */
152
+ isActiveParentTooltipText?: string;
153
+ /**
154
+ * Indicates whether this navmenuitem has an active child navmenuitem.
155
+ * This is used to manage tooltip display for parent navmenuitems in nested navigation structures.
98
156
  * @internal
99
157
  */
100
- private prevIconName?;
158
+ hasActiveChild: boolean;
101
159
  /**
102
160
  * @internal
103
161
  */
@@ -105,24 +163,15 @@ declare class NavMenuItem extends NavMenuItem_base {
105
163
  constructor();
106
164
  connectedCallback(): void;
107
165
  disconnectedCallback(): void;
108
- protected updated(): void;
109
- private removeTooltip;
166
+ protected updated(changedProperties: Map<string, any>): void;
110
167
  private renderDynamicTooltip;
168
+ private removeTooltip;
111
169
  /**
112
170
  * Check whether the navmenuitem is inside a nested nav structure.
113
171
  * Returns `true` if there is a parent `mdc-menupopover`
114
172
  * This method assumes nesting implies deeper levels of nav hierarchy.
115
173
  */
116
174
  private isNested;
117
- /**
118
- * Modifies the icon name based on the active state.
119
- * If the navMenuItem is active, the icon name is suffixed with '-filled'.
120
- * If the navMenuItem is inactive, the icon name is restored to its original value.
121
- * If '-filled' icon is not available, the icon name remains unchanged.
122
- * @internal
123
- * @param active - The active state.
124
- */
125
- private modifyIconName;
126
175
  /**
127
176
  * Dispatch the activechange event.
128
177
  * @internal
@@ -130,11 +179,9 @@ declare class NavMenuItem extends NavMenuItem_base {
130
179
  */
131
180
  private emitNavMenuItemActiveChange;
132
181
  private handleClickEvent;
133
- update(changedProperties: PropertyValues): void;
134
- private renderTextLabel;
135
- private renderArrowIcon;
182
+ private getFilledIconName;
136
183
  private renderBadge;
137
- render(): import("lit-html").TemplateResult<1>;
184
+ render(): TemplateResult<1>;
138
185
  static styles: Array<CSSResult>;
139
186
  }
140
187
  export default NavMenuItem;
@@ -8,23 +8,24 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { html, nothing } from 'lit';
11
- import { property } from 'lit/decorators.js';
11
+ import { property, state } from 'lit/decorators.js';
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
13
  import { v4 } from 'uuid';
14
- import providerUtils from '../../utils/provider';
15
14
  import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
16
15
  import { TAG_NAME as MENUPOPOVER_TAGNAME } from '../menupopover/menupopover.constants';
17
- import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
18
16
  import MenuItem from '../menuitem/menuitem.component';
19
- import { getIconNameWithoutStyle } from '../button/button.utils';
17
+ import providerUtils from '../../utils/provider';
20
18
  import SideNavigation from '../sidenavigation/sidenavigation.component';
21
19
  import { TAG_NAME as TOOLTIP_TAG_NAME } from '../tooltip/tooltip.constants';
22
- import { DEFAULTS, ALLOWED_BADGE_TYPES, ICON_NAME } from './navmenuitem.constants';
20
+ import { getIconNameWithoutStyle } from '../button/button.utils';
21
+ import { ALLOWED_BADGE_TYPES, DEFAULTS, ICON_NAME } from './navmenuitem.constants';
23
22
  import styles from './navmenuitem.styles';
24
23
  /**
25
24
  * `mdc-navmenuitem` is a menuitem styled to work as a navigation tab.
26
25
  * It supports a leading icon, optional badge and dynamic text rendering.
27
26
  *
27
+ * The navmenuitem can be in an active or inactive state, indicating whether it is currently selected.
28
+ *
28
29
  * Note: `mdc-navmenuitem` is intended to be used inside `mdc-menubar` as part of the sideNavigation
29
30
  * component. Its structure, spacing, and interactions are designed to align with
30
31
  * the visual and functional requirements of side navigation layouts.
@@ -44,17 +45,21 @@ import styles from './navmenuitem.styles';
44
45
  * @event focus - (React: onFocus) This event is dispatched when the navmenuitem receives focus.
45
46
  * @event activechange - (React: onActiveChange) Dispatched when the active state of the navmenuitem changes.
46
47
  *
48
+ * @cssproperty --mdc-navmenuitem-in-sidenav-expanded-width - Width of the navmenuitem when expanded.
49
+ * @cssproperty --mdc-navmenuitem-in-sidenav-expanded-margin-left - Left margin of the navmenuitem, when expanded.
50
+ * @cssproperty --mdc-navmenuitem-in-sidenav-expanded-margin-right - Right margin of the navmenuitem, when expanded.
51
+ * @cssproperty --mdc-navmenuitem-in-sidenav-collapsed-width - Width of the navmenuitem when collapsed.
52
+ * @cssproperty --mdc-navmenuitem-in-sidenav-collapsed-margin-left - Left margin of the navmenuitem, when collapsed.
53
+ * @cssproperty --mdc-navmenuitem-in-sidenav-collapsed-margin-right - Right margin of the navmenuitem, when collapsed.
47
54
  * @cssproperty --mdc-navmenuitem-color - Text color of the navmenuitem in its normal state.
48
- * @cssproperty --mdc-navmenuitem-border-color - Border color of the navmenuitem in its normal state.
49
55
  * @cssproperty --mdc-navmenuitem-disabled-color - Text color of the navmenuitem when disabled.
50
- * @cssproperty --mdc-navmenuitem-expanded-width - Width of the navmenuitem when expanded.
56
+ * @cssproperty --mdc-navmenuitem-rest-active-background-color - Background color of the active nav item in its rest state.
51
57
  * @cssproperty --mdc-navmenuitem-hover-background-color - Background color of the navmenuitem when hovered.
52
58
  * @cssproperty --mdc-navmenuitem-hover-active-background-color - Background color of the active navmenuitem when hovered.
53
59
  * @cssproperty --mdc-navmenuitem-pressed-background-color - Background color of the navmenuitem when pressed.
54
60
  * @cssproperty --mdc-navmenuitem-pressed-active-background-color - Background color of the active navmenuitem when pressed.
55
61
  * @cssproperty --mdc-navmenuitem-disabled-background-color - Background color of the navmenuitem when disabled.
56
62
  * @cssproperty --mdc-navmenuitem-disabled-active-background-color - Background color of the active navmenuitem when disabled.
57
- * @cssproperty --mdc-navmenuitem-rest-active-background-color - Background color of the active nav item in its rest state.
58
63
  *
59
64
  * @csspart arrow - The arrow of the navmenuitem.
60
65
  * @csspart badge - The badge of the navmenuitem.
@@ -62,9 +67,18 @@ import styles from './navmenuitem.styles';
62
67
  * @csspart text-container - The container of the text.
63
68
  * @csspart trailing-arrow - The trailing arrow of the navmenuitem.
64
69
  */
65
- class NavMenuItem extends IconNameMixin(MenuItem) {
70
+ class NavMenuItem extends MenuItem {
66
71
  constructor() {
67
72
  super();
73
+ /**
74
+ * When set to true, prevents the navmenuitem from being activated.
75
+ * This is useful for cases where the navmenuitem is used as a button
76
+ * or link, where not the content on the current page is changing.
77
+ * By default this is set to false, making the navmenuitem activatable (= aria-current gets set when active).
78
+ *
79
+ * @default false
80
+ */
81
+ this.cannotActivate = DEFAULTS.CANNOT_ACTIVATE;
68
82
  /**
69
83
  * The maximum number can be set up to 999, anything above that will be rendered as _999+_.
70
84
  * The max counter can be `9`, `99` or `999`.
@@ -75,6 +89,24 @@ class NavMenuItem extends IconNameMixin(MenuItem) {
75
89
  * Aria-label attribute to be set for accessibility
76
90
  */
77
91
  this.ariaLabel = null;
92
+ /**
93
+ * The placement of the tooltip relative to the nav item.
94
+ * @default 'right'
95
+ */
96
+ this.tooltipPlacement = 'right';
97
+ /**
98
+ * The appearance behavior of the tooltip.
99
+ * Options are 'when-collapsed' (default) or 'always'.
100
+ *
101
+ * @default 'when-collapsed'
102
+ */
103
+ this.tooltipAppearance = 'when-collapsed';
104
+ /**
105
+ * Indicates whether this navmenuitem has an active child navmenuitem.
106
+ * This is used to manage tooltip display for parent navmenuitems in nested navigation structures.
107
+ * @internal
108
+ */
109
+ this.hasActiveChild = false;
78
110
  /**
79
111
  * @internal
80
112
  */
@@ -92,10 +124,6 @@ class NavMenuItem extends IconNameMixin(MenuItem) {
92
124
  this.dispatchEvent(event);
93
125
  };
94
126
  this.addEventListener('click', this.handleClickEvent.bind(this));
95
- this.addEventListener('focusin', this.renderDynamicTooltip.bind(this));
96
- this.addEventListener('mouseenter', this.renderDynamicTooltip.bind(this));
97
- this.addEventListener('focusout', this.removeTooltip.bind(this));
98
- this.addEventListener('mouseout', this.removeTooltip.bind(this));
99
127
  }
100
128
  connectedCallback() {
101
129
  super.connectedCallback();
@@ -110,45 +138,46 @@ class NavMenuItem extends IconNameMixin(MenuItem) {
110
138
  super.disconnectedCallback();
111
139
  this.removeTooltip();
112
140
  }
113
- updated() {
114
- var _a, _b;
141
+ updated(changedProperties) {
142
+ var _a;
143
+ super.updated(changedProperties);
144
+ if (changedProperties.has('tooltipText') ||
145
+ changedProperties.has('showLabel') ||
146
+ changedProperties.has('hasActiveChild')) {
147
+ this.renderDynamicTooltip();
148
+ }
149
+ if (changedProperties.has('showLabel')) {
150
+ // If collapsed and aria-label is not set, use visible label
151
+ if (!this.showLabel && !this.getAttribute('aria-label') && this.label) {
152
+ this.setAttribute('aria-label', this.label);
153
+ }
154
+ }
115
155
  const context = (_a = this.sideNavigationContext) === null || _a === void 0 ? void 0 : _a.value;
116
156
  if (!context)
117
157
  return;
118
158
  // Determine expansion state
119
159
  this.showLabel = this.isNested() ? true : context.expanded;
120
- // Manage aria-label for accessibility
121
- if (this.showLabel) {
122
- this.removeAttribute('aria-label');
123
- }
124
- else {
125
- const label = (_b = this.label) !== null && _b !== void 0 ? _b : '';
126
- this.ariaLabel = this.ariaLabel || label;
127
- this.setAttribute('aria-label', label);
128
- }
129
- }
130
- removeTooltip() {
131
- // Remove any existing tooltip.
132
- const existingTooltip = document.querySelector(`${TOOLTIP_TAG_NAME}[triggerid="${this.id}"]`);
133
- if (existingTooltip) {
134
- existingTooltip.remove();
135
- }
136
160
  }
137
161
  renderDynamicTooltip() {
138
- if (!this.tooltipText) {
162
+ var _a;
163
+ this.removeTooltip();
164
+ if (this.hasActiveChild && !this.isActiveParentTooltipText) {
165
+ return;
166
+ }
167
+ if (!this.hasActiveChild &&
168
+ (!this.tooltipText || (this.tooltipAppearance === 'when-collapsed' && this.showLabel))) {
139
169
  return;
140
170
  }
141
171
  if (!this.id) {
142
172
  this.id = `mdc-navmenuitem-${v4()}`;
143
173
  }
144
- this.removeTooltip();
145
- // Create tooltip for the listitem element.
146
174
  const tooltip = document.createElement(TOOLTIP_TAG_NAME);
147
175
  tooltip.id = `mdc-navmenuitem-tooltip-${v4()}`;
148
- tooltip.textContent = this.tooltipText;
176
+ tooltip.textContent = this.hasActiveChild ? this.isActiveParentTooltipText : this.tooltipText;
149
177
  tooltip.setAttribute('triggerid', this.id);
150
- tooltip.setAttribute('visible', '');
151
178
  tooltip.setAttribute('show-arrow', '');
179
+ tooltip.setAttribute('placement', this.tooltipPlacement);
180
+ tooltip.setAttribute('boundary-padding', ((_a = this.tooltipBoundaryPadding) === null || _a === void 0 ? void 0 : _a.toString()) || '0');
152
181
  // Set the slot attribute if the parent element has a slot.
153
182
  if (this.hasAttribute('slot')) {
154
183
  tooltip.setAttribute('slot', this.getAttribute('slot') || '');
@@ -156,6 +185,13 @@ class NavMenuItem extends IconNameMixin(MenuItem) {
156
185
  // Attach the tooltip programmatically after the nearest parent element.
157
186
  this.after(tooltip);
158
187
  }
188
+ removeTooltip() {
189
+ // Remove any existing tooltip.
190
+ const existingTooltip = document.querySelector(`${TOOLTIP_TAG_NAME}[triggerid="${this.id}"]`);
191
+ if (existingTooltip) {
192
+ existingTooltip.remove();
193
+ }
194
+ }
159
195
  /**
160
196
  * Check whether the navmenuitem is inside a nested nav structure.
161
197
  * Returns `true` if there is a parent `mdc-menupopover`
@@ -171,59 +207,21 @@ class NavMenuItem extends IconNameMixin(MenuItem) {
171
207
  }
172
208
  return false;
173
209
  }
174
- /**
175
- * Modifies the icon name based on the active state.
176
- * If the navMenuItem is active, the icon name is suffixed with '-filled'.
177
- * If the navMenuItem is inactive, the icon name is restored to its original value.
178
- * If '-filled' icon is not available, the icon name remains unchanged.
179
- * @internal
180
- * @param active - The active state.
181
- */
182
- modifyIconName(active) {
183
- if (!this.iconName)
184
- return;
185
- const isFilled = this.iconName.endsWith('-filled');
186
- const baseIcon = getIconNameWithoutStyle(this.iconName);
187
- if (active) {
188
- if (!isFilled) {
189
- this.prevIconName = this.iconName;
190
- this.iconName = `${baseIcon}-filled`;
191
- }
192
- }
193
- else if (this.prevIconName) {
194
- this.iconName = this.prevIconName;
195
- }
196
- }
197
210
  handleClickEvent() {
198
- if (this.disabled)
211
+ if (this.disabled || this.cannotActivate)
199
212
  return;
200
213
  this.emitNavMenuItemActiveChange(this.active);
201
214
  }
202
- update(changedProperties) {
203
- super.update(changedProperties);
204
- if (changedProperties.has('active')) {
205
- this.modifyIconName(this.active);
215
+ getFilledIconName() {
216
+ if (!this.iconName) {
217
+ return undefined;
206
218
  }
207
- }
208
- renderTextLabel(label) {
209
- return html `
210
- <mdc-text
211
- type=${this.active ? TYPE.BODY_MIDSIZE_BOLD : TYPE.BODY_MIDSIZE_MEDIUM}
212
- tagname=${VALID_TEXT_TAGS.SPAN}
213
- part="text-container"
214
- >
215
- ${label}
216
- </mdc-text>
217
- `;
218
- }
219
- renderArrowIcon(showLabel) {
220
- return html `
221
- <mdc-icon
222
- name=${ICON_NAME.RIGHT_ARROW}
223
- length-unit="rem"
224
- part="trailing-arrow ${showLabel ? '' : 'arrow'}"
225
- ></mdc-icon>
226
- `;
219
+ const isFilled = this.iconName.endsWith('-filled');
220
+ if (isFilled) {
221
+ return undefined;
222
+ }
223
+ const baseIcon = getIconNameWithoutStyle(this.iconName);
224
+ return `${baseIcon}-filled`;
227
225
  }
228
226
  renderBadge(showLabel) {
229
227
  const isValidBadgeType = Object.values(ALLOWED_BADGE_TYPES).includes(this.badgeType);
@@ -236,6 +234,7 @@ class NavMenuItem extends IconNameMixin(MenuItem) {
236
234
  type="${ifDefined(this.badgeType)}"
237
235
  counter="${ifDefined(this.counter)}"
238
236
  max-counter="${this.maxCounter}"
237
+ aria-hidden="true"
239
238
  >
240
239
  </mdc-badge>
241
240
  `;
@@ -245,11 +244,32 @@ class NavMenuItem extends IconNameMixin(MenuItem) {
245
244
  const context = (_a = this.sideNavigationContext) === null || _a === void 0 ? void 0 : _a.value;
246
245
  return html `
247
246
  <div part="icon-container">
248
- <mdc-icon name="${this.iconName}" size="1.5" length-unit="rem" part="icon"></mdc-icon>
247
+ <mdc-icon name="${this.iconName}" size="1.5" length-unit="rem" part="regular-icon"></mdc-icon>
248
+ ${!this.cannotActivate
249
+ ? html `<mdc-icon
250
+ name="${this.getFilledIconName()}"
251
+ size="1.5"
252
+ length-unit="rem"
253
+ part="filled-icon"
254
+ ></mdc-icon>`
255
+ : nothing}
249
256
  ${!this.showLabel ? this.renderBadge(this.showLabel) : nothing}
250
257
  </div>
251
- ${this.showLabel ? html `${this.renderTextLabel(this.label)}${this.renderBadge(this.showLabel)}` : nothing}
252
- ${(context === null || context === void 0 ? void 0 : context.hasSiblingWithTriggerId(this)) ? this.renderArrowIcon(this.showLabel) : nothing}
258
+ ${this.showLabel
259
+ ? html `
260
+ <mdc-text
261
+ type=${this.active ? TYPE.BODY_MIDSIZE_BOLD : TYPE.BODY_MIDSIZE_MEDIUM}
262
+ tagname=${VALID_TEXT_TAGS.SPAN}
263
+ part="text-container"
264
+ >
265
+ ${this.label}
266
+ </mdc-text>
267
+ ${this.renderBadge(this.showLabel)}
268
+ `
269
+ : nothing}
270
+ ${(context === null || context === void 0 ? void 0 : context.hasSiblingWithTriggerId(this))
271
+ ? html ` <mdc-icon name=${ICON_NAME.RIGHT_ARROW} length-unit="rem" part="trailing-arrow"> </mdc-icon>`
272
+ : nothing}
253
273
  `;
254
274
  }
255
275
  }
@@ -258,6 +278,14 @@ __decorate([
258
278
  property({ type: Boolean, reflect: true }),
259
279
  __metadata("design:type", Boolean)
260
280
  ], NavMenuItem.prototype, "active", void 0);
281
+ __decorate([
282
+ property({ type: Boolean, reflect: true, attribute: 'cannot-activate' }),
283
+ __metadata("design:type", Boolean)
284
+ ], NavMenuItem.prototype, "cannotActivate", void 0);
285
+ __decorate([
286
+ property({ type: String, attribute: 'icon-name', reflect: true }),
287
+ __metadata("design:type", String)
288
+ ], NavMenuItem.prototype, "iconName", void 0);
261
289
  __decorate([
262
290
  property({ type: String, reflect: true, attribute: 'badge-type' }),
263
291
  __metadata("design:type", String)
@@ -290,4 +318,24 @@ __decorate([
290
318
  property({ type: String, reflect: true, attribute: 'tooltip-text' }),
291
319
  __metadata("design:type", String)
292
320
  ], NavMenuItem.prototype, "tooltipText", void 0);
321
+ __decorate([
322
+ property({ type: String, reflect: true, attribute: 'tooltip-placement' }),
323
+ __metadata("design:type", String)
324
+ ], NavMenuItem.prototype, "tooltipPlacement", void 0);
325
+ __decorate([
326
+ property({ type: String, reflect: true, attribute: 'tooltip-appearance' }),
327
+ __metadata("design:type", String)
328
+ ], NavMenuItem.prototype, "tooltipAppearance", void 0);
329
+ __decorate([
330
+ property({ type: Number, reflect: true, attribute: 'tooltip-boundary-padding' }),
331
+ __metadata("design:type", Number)
332
+ ], NavMenuItem.prototype, "tooltipBoundaryPadding", void 0);
333
+ __decorate([
334
+ property({ type: String, reflect: true, attribute: 'is-active-parent-tooltip-text' }),
335
+ __metadata("design:type", String)
336
+ ], NavMenuItem.prototype, "isActiveParentTooltipText", void 0);
337
+ __decorate([
338
+ state(),
339
+ __metadata("design:type", Boolean)
340
+ ], NavMenuItem.prototype, "hasActiveChild", void 0);
293
341
  export default NavMenuItem;
@@ -13,5 +13,6 @@ declare const DEFAULTS: {
13
13
  readonly TAG_NAME: "span";
14
14
  readonly SIZE: 24;
15
15
  readonly VARIANT: string;
16
+ readonly CANNOT_ACTIVATE: false;
16
17
  };
17
18
  export { DEFAULTS, TAG_NAME, ALLOWED_BADGE_TYPES, ICON_NAME };
@@ -17,5 +17,6 @@ const DEFAULTS = {
17
17
  TAG_NAME: VALID_TEXT_TAGS.SPAN,
18
18
  SIZE: BUTTON_SIZES[24],
19
19
  VARIANT: VARIANTS.FLEXIBLE,
20
+ CANNOT_ACTIVATE: false,
20
21
  };
21
22
  export { DEFAULTS, TAG_NAME, ALLOWED_BADGE_TYPES, ICON_NAME };