@momentum-design/components 0.80.4 → 0.80.5
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 +601 -317
- package/dist/browser/index.js.map +4 -4
- package/dist/components/list/list.component.d.ts +1 -1
- package/dist/components/listitem/listitem.component.js +10 -3
- package/dist/components/menupopover/menupopover.component.js +2 -1
- package/dist/components/navitem/index.d.ts +11 -0
- package/dist/components/navitem/index.js +8 -0
- package/dist/components/navitem/navitem.component.d.ts +125 -0
- package/dist/components/navitem/navitem.component.js +251 -0
- package/dist/components/navitem/navitem.constants.d.ts +16 -0
- package/dist/components/navitem/navitem.constants.js +21 -0
- package/dist/components/navitem/navitem.styles.d.ts +2 -0
- package/dist/components/navitem/navitem.styles.js +146 -0
- package/dist/components/navitem/navitem.types.d.ts +11 -0
- package/dist/components/navitem/navitem.types.js +1 -0
- package/dist/components/navitemlist/index.d.ts +7 -0
- package/dist/components/navitemlist/index.js +4 -0
- package/dist/components/navitemlist/navitemlist.component.d.ts +51 -0
- package/dist/components/navitemlist/navitemlist.component.js +92 -0
- package/dist/components/navitemlist/navitemlist.constants.d.ts +2 -0
- package/dist/components/navitemlist/navitemlist.constants.js +3 -0
- package/dist/components/navitemlist/navitemlist.styles.d.ts +2 -0
- package/dist/components/navitemlist/navitemlist.styles.js +23 -0
- package/dist/components/sidenavigation/index.d.ts +10 -0
- package/dist/components/sidenavigation/index.js +7 -0
- package/dist/components/sidenavigation/sidenavigation.component.d.ts +144 -0
- package/dist/components/sidenavigation/sidenavigation.component.js +244 -0
- package/dist/components/sidenavigation/sidenavigation.constants.d.ts +11 -0
- package/dist/components/sidenavigation/sidenavigation.constants.js +12 -0
- package/dist/components/sidenavigation/sidenavigation.context.d.ts +15 -0
- package/dist/components/sidenavigation/sidenavigation.context.js +78 -0
- package/dist/components/sidenavigation/sidenavigation.styles.d.ts +2 -0
- package/dist/components/sidenavigation/sidenavigation.styles.js +68 -0
- package/dist/components/sidenavigation/sidenavigation.types.d.ts +7 -0
- package/dist/components/sidenavigation/sidenavigation.types.js +1 -0
- package/dist/custom-elements.json +2512 -524
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/react/index.d.ts +5 -2
- package/dist/react/index.js +5 -2
- package/dist/react/navitem/index.d.ts +43 -0
- package/dist/react/navitem/index.js +51 -0
- package/dist/react/navitemlist/index.d.ts +13 -0
- package/dist/react/navitemlist/index.js +22 -0
- package/dist/react/sidenavigation/index.d.ts +56 -0
- package/dist/react/sidenavigation/index.js +64 -0
- package/dist/utils/mixins/MenuMixin.js +39 -14
- package/dist/utils/roles.d.ts +1 -0
- package/dist/utils/roles.js +1 -0
- package/package.json +1 -1
@@ -55,7 +55,7 @@ declare class List extends List_base {
|
|
55
55
|
* `resetTabIndexAndSetActiveTabIndex` with that index.
|
56
56
|
* @param event - The mouse event.
|
57
57
|
*/
|
58
|
-
|
58
|
+
protected handleMouseClick(event: MouseEvent): void;
|
59
59
|
/**
|
60
60
|
* Resets all list items tabindex to -1 and sets the tabindex of the
|
61
61
|
* element at the given index to 0, effectively setting the active
|
@@ -14,6 +14,7 @@ import { KEYS } from '../../utils/keys';
|
|
14
14
|
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
15
15
|
import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
|
16
16
|
import { ROLE } from '../../utils/roles';
|
17
|
+
import { TAG_NAME as NAVITEMLIST_TAG_NAME } from '../navitemlist/navitemlist.constants';
|
17
18
|
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
18
19
|
import { TAG_NAME as TOOLTIP_TAG_NAME } from '../tooltip/tooltip.constants';
|
19
20
|
import { DEFAULTS, LISTITEM_ID, TOOLTIP_ID } from './listitem.constants';
|
@@ -122,7 +123,7 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
122
123
|
* Create the tooltip programmatically after the nearest parent element.
|
123
124
|
*/
|
124
125
|
displayTooltipForLongText() {
|
125
|
-
var _a;
|
126
|
+
var _a, _b, _c;
|
126
127
|
if (!this.tooltipText) {
|
127
128
|
return;
|
128
129
|
}
|
@@ -140,8 +141,14 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
140
141
|
tooltip.setAttribute('placement', this.tooltipPlacement);
|
141
142
|
tooltip.setAttribute('visible', '');
|
142
143
|
tooltip.setAttribute('show-arrow', '');
|
143
|
-
//
|
144
|
-
(_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.
|
144
|
+
// The navitem follows a different pattern to attach the tooltip.
|
145
|
+
if (((_b = (_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === NAVITEMLIST_TAG_NAME) {
|
146
|
+
this.before(tooltip);
|
147
|
+
}
|
148
|
+
else {
|
149
|
+
// Add tooltip programmatically after the parent element.
|
150
|
+
(_c = this.parentElement) === null || _c === void 0 ? void 0 : _c.after(tooltip);
|
151
|
+
}
|
145
152
|
}
|
146
153
|
/**
|
147
154
|
* Removes the dynamically created tooltip for long text label on focus or mouse leave.
|
@@ -34,13 +34,14 @@ class MenuPopover extends MenuMixin(Popover) {
|
|
34
34
|
connectedCallback() {
|
35
35
|
super.connectedCallback();
|
36
36
|
this.role = ROLE.MENU;
|
37
|
+
this.focusBackToTrigger = true;
|
37
38
|
this.focusTrap = true;
|
38
39
|
this.focusBackToTrigger = true;
|
39
40
|
this.hideOnEscape = true;
|
40
41
|
this.hideOnOutsideClick = true;
|
42
|
+
this.interactive = true;
|
41
43
|
this.placement = POPOVER_PLACEMENT.BOTTOM_START;
|
42
44
|
this.showArrow = false;
|
43
|
-
this.interactive = true;
|
44
45
|
this.ariaOrientation = ORIENTATION.VERTICAL;
|
45
46
|
}
|
46
47
|
async firstUpdated(changedProperties) {
|
@@ -0,0 +1,125 @@
|
|
1
|
+
import type { CSSResult, PropertyValues } from 'lit';
|
2
|
+
import MenuItem from '../menuitem/menuitem.component';
|
3
|
+
import type { BadgeType } from './navitem.types';
|
4
|
+
declare const NavItem_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof MenuItem;
|
5
|
+
/**
|
6
|
+
* `mdc-navitem` is a menuitem styled to work as a navigation tab.
|
7
|
+
* It supports a leading icon, optional badge and dynamic text rendering.
|
8
|
+
*
|
9
|
+
* Note: `mdc-navitem` is intended to be used inside `mdc-navitemlist` as part of the sideNavigation
|
10
|
+
* component. Its structure, spacing, and interactions are designed to align with
|
11
|
+
* the visual and functional requirements of side navigation layouts.
|
12
|
+
*
|
13
|
+
* @tagname mdc-navitem
|
14
|
+
*
|
15
|
+
* @dependency mdc-icon
|
16
|
+
* @dependency mdc-text
|
17
|
+
* @dependency mdc-badge
|
18
|
+
* @dependency mdc-tooltip
|
19
|
+
*
|
20
|
+
* @event click - (React: onClick) This event is dispatched when the navitem is clicked.
|
21
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the navitem.
|
22
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the navitem.
|
23
|
+
* @event focus - (React: onFocus) This event is dispatched when the navitem receives focus.
|
24
|
+
* @event activechange - (React: onActiveChange) Dispatched when the active state of the navitem changes.
|
25
|
+
*
|
26
|
+
* @cssproperty --mdc-navitem-color - Text color of the navitem in its normal state.
|
27
|
+
* @cssproperty --mdc-navitem-border-color - Border color of the navitem in its normal state.
|
28
|
+
* @cssproperty --mdc-navitem-disabled-color - Text color of the navitem when disabled.
|
29
|
+
* @cssproperty --mdc-navitem-expanded-width - Width of the navItem when expanded.
|
30
|
+
* @cssproperty --mdc-navitem-hover-background-color - Background color of the navitem when hovered.
|
31
|
+
* @cssproperty --mdc-navitem-hover-active-background-color - Background color of the active navitem when hovered.
|
32
|
+
* @cssproperty --mdc-navitem-pressed-background-color - Background color of the navitem when pressed.
|
33
|
+
* @cssproperty --mdc-navitem-pressed-active-background-color - Background color of the active navitem when pressed.
|
34
|
+
* @cssproperty --mdc-navitem-disabled-background-color - Background color of the navitem when disabled.
|
35
|
+
* @cssproperty --mdc-navitem-disabled-active-background-color - Background color of the active navitem when disabled.
|
36
|
+
* @cssproperty --mdc-navitem-rest-active-background-color - Background color of the active nav item in its rest state.
|
37
|
+
*/
|
38
|
+
declare class NavItem extends NavItem_base {
|
39
|
+
/**
|
40
|
+
* The navitem's active state indicates whether it is currently toggled on (active) or off (inactive).
|
41
|
+
* When the active state is true, the navitem is considered to be in an active state, meaning it is toggled on.
|
42
|
+
* Conversely, when the active state is false, the navitem is in an inactive state, indicating it is toggled off.
|
43
|
+
* @default undefined
|
44
|
+
*/
|
45
|
+
active?: boolean;
|
46
|
+
/**
|
47
|
+
* Type of the badge
|
48
|
+
* Can be `dot` (notification) or `counter`.
|
49
|
+
*/
|
50
|
+
badgeType?: BadgeType;
|
51
|
+
/**
|
52
|
+
* Counter is the number which can be provided in the badge.
|
53
|
+
*/
|
54
|
+
counter?: number;
|
55
|
+
/**
|
56
|
+
* The maximum number can be set up to 999, anything above that will be rendered as _999+_.
|
57
|
+
* The max counter can be `9`, `99` or `999`.
|
58
|
+
* @default 99
|
59
|
+
*/
|
60
|
+
maxCounter: number;
|
61
|
+
/**
|
62
|
+
* Id of the navItem (used as a identificator when used in the navItemList)
|
63
|
+
* Note: It has to be unique.
|
64
|
+
*
|
65
|
+
* @default undefined
|
66
|
+
*/
|
67
|
+
navId?: string;
|
68
|
+
/**
|
69
|
+
* Determines whether the navItem is expanded or not.
|
70
|
+
*
|
71
|
+
* @internal
|
72
|
+
*/
|
73
|
+
showLabel?: boolean;
|
74
|
+
/**
|
75
|
+
* Aria-label attribute to be set for accessibility
|
76
|
+
*/
|
77
|
+
ariaLabel: string | null;
|
78
|
+
/**
|
79
|
+
* When set to true, prevents the automatic setting of the `aria-current` attribute on the navitem
|
80
|
+
* when it becomes active. This is useful for cases where you want to maintain the visual active styling
|
81
|
+
* but need to handle aria-current attribute differently or not at all.
|
82
|
+
* The active button styling will still be applied regardless of this setting.
|
83
|
+
*/
|
84
|
+
disableAriaCurrent?: boolean;
|
85
|
+
/**
|
86
|
+
* @internal
|
87
|
+
*/
|
88
|
+
private prevIconName?;
|
89
|
+
/**
|
90
|
+
* @internal
|
91
|
+
*/
|
92
|
+
private readonly sideNavigationContext;
|
93
|
+
connectedCallback(): void;
|
94
|
+
disconnectedCallback(): void;
|
95
|
+
protected updated(): void;
|
96
|
+
/**
|
97
|
+
* Check whether the navitem is inside a nested nav structure.
|
98
|
+
* Returns `true` if there is a parent `mdc-menupopover`
|
99
|
+
* This method assumes nesting implies deeper levels of nav hierarchy.
|
100
|
+
*/
|
101
|
+
private isNested;
|
102
|
+
/**
|
103
|
+
* Modifies the icon name based on the active state.
|
104
|
+
* If the navItem is active, the icon name is suffixed with '-filled'.
|
105
|
+
* If the navItem is inactive, the icon name is restored to its original value.
|
106
|
+
* If '-filled' icon is not available, the icon name remains unchanged.
|
107
|
+
* @internal
|
108
|
+
* @param active - The active state.
|
109
|
+
*/
|
110
|
+
private modifyIconName;
|
111
|
+
/**
|
112
|
+
* Dispatch the activechange event.
|
113
|
+
* @internal
|
114
|
+
* @param active - The active state of the navItem.
|
115
|
+
*/
|
116
|
+
private emitNavItemActiveChange;
|
117
|
+
private handleClickEvent;
|
118
|
+
update(changedProperties: PropertyValues): void;
|
119
|
+
private renderTextLabel;
|
120
|
+
private renderArrowIcon;
|
121
|
+
private renderBadge;
|
122
|
+
render(): import("lit-html").TemplateResult<1>;
|
123
|
+
static styles: Array<CSSResult>;
|
124
|
+
}
|
125
|
+
export default NavItem;
|
@@ -0,0 +1,251 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html, nothing } from 'lit';
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
|
+
import styles from './navitem.styles';
|
14
|
+
import { DEFAULTS, ALLOWED_BADGE_TYPES, ICON_NAME } from './navitem.constants';
|
15
|
+
import providerUtils from '../../utils/provider';
|
16
|
+
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
17
|
+
import { TAG_NAME as MENUPOPOVER_TAGNAME } from '../menupopover/menupopover.constants';
|
18
|
+
import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
|
19
|
+
import MenuItem from '../menuitem/menuitem.component';
|
20
|
+
import { getIconNameWithoutStyle } from '../button/button.utils';
|
21
|
+
import SideNavigation from '../sidenavigation/sidenavigation.component';
|
22
|
+
/**
|
23
|
+
* `mdc-navitem` is a menuitem styled to work as a navigation tab.
|
24
|
+
* It supports a leading icon, optional badge and dynamic text rendering.
|
25
|
+
*
|
26
|
+
* Note: `mdc-navitem` is intended to be used inside `mdc-navitemlist` as part of the sideNavigation
|
27
|
+
* component. Its structure, spacing, and interactions are designed to align with
|
28
|
+
* the visual and functional requirements of side navigation layouts.
|
29
|
+
*
|
30
|
+
* @tagname mdc-navitem
|
31
|
+
*
|
32
|
+
* @dependency mdc-icon
|
33
|
+
* @dependency mdc-text
|
34
|
+
* @dependency mdc-badge
|
35
|
+
* @dependency mdc-tooltip
|
36
|
+
*
|
37
|
+
* @event click - (React: onClick) This event is dispatched when the navitem is clicked.
|
38
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the navitem.
|
39
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the navitem.
|
40
|
+
* @event focus - (React: onFocus) This event is dispatched when the navitem receives focus.
|
41
|
+
* @event activechange - (React: onActiveChange) Dispatched when the active state of the navitem changes.
|
42
|
+
*
|
43
|
+
* @cssproperty --mdc-navitem-color - Text color of the navitem in its normal state.
|
44
|
+
* @cssproperty --mdc-navitem-border-color - Border color of the navitem in its normal state.
|
45
|
+
* @cssproperty --mdc-navitem-disabled-color - Text color of the navitem when disabled.
|
46
|
+
* @cssproperty --mdc-navitem-expanded-width - Width of the navItem when expanded.
|
47
|
+
* @cssproperty --mdc-navitem-hover-background-color - Background color of the navitem when hovered.
|
48
|
+
* @cssproperty --mdc-navitem-hover-active-background-color - Background color of the active navitem when hovered.
|
49
|
+
* @cssproperty --mdc-navitem-pressed-background-color - Background color of the navitem when pressed.
|
50
|
+
* @cssproperty --mdc-navitem-pressed-active-background-color - Background color of the active navitem when pressed.
|
51
|
+
* @cssproperty --mdc-navitem-disabled-background-color - Background color of the navitem when disabled.
|
52
|
+
* @cssproperty --mdc-navitem-disabled-active-background-color - Background color of the active navitem when disabled.
|
53
|
+
* @cssproperty --mdc-navitem-rest-active-background-color - Background color of the active nav item in its rest state.
|
54
|
+
*/
|
55
|
+
class NavItem extends IconNameMixin(MenuItem) {
|
56
|
+
constructor() {
|
57
|
+
super(...arguments);
|
58
|
+
/**
|
59
|
+
* The maximum number can be set up to 999, anything above that will be rendered as _999+_.
|
60
|
+
* The max counter can be `9`, `99` or `999`.
|
61
|
+
* @default 99
|
62
|
+
*/
|
63
|
+
this.maxCounter = DEFAULTS.MAX_COUNTER;
|
64
|
+
/**
|
65
|
+
* Aria-label attribute to be set for accessibility
|
66
|
+
*/
|
67
|
+
this.ariaLabel = null;
|
68
|
+
/**
|
69
|
+
* @internal
|
70
|
+
*/
|
71
|
+
this.sideNavigationContext = providerUtils.consume({ host: this, context: SideNavigation.Context });
|
72
|
+
/**
|
73
|
+
* Dispatch the activechange event.
|
74
|
+
* @internal
|
75
|
+
* @param active - The active state of the navItem.
|
76
|
+
*/
|
77
|
+
this.emitNavItemActiveChange = (active) => {
|
78
|
+
const event = new CustomEvent('activechange', {
|
79
|
+
detail: { navId: this.navId, active },
|
80
|
+
bubbles: true,
|
81
|
+
});
|
82
|
+
this.dispatchEvent(event);
|
83
|
+
};
|
84
|
+
}
|
85
|
+
connectedCallback() {
|
86
|
+
super.connectedCallback();
|
87
|
+
this.variant = undefined;
|
88
|
+
this.tooltipPlacement = undefined;
|
89
|
+
this.addEventListener('click', this.handleClickEvent);
|
90
|
+
if (!this.navId && this.onerror) {
|
91
|
+
this.onerror('[mdc-navitem] navId is required and was not provided.');
|
92
|
+
}
|
93
|
+
}
|
94
|
+
disconnectedCallback() {
|
95
|
+
super.disconnectedCallback();
|
96
|
+
this.removeEventListener('click', this.handleClickEvent);
|
97
|
+
}
|
98
|
+
updated() {
|
99
|
+
var _a, _b;
|
100
|
+
const context = (_a = this.sideNavigationContext) === null || _a === void 0 ? void 0 : _a.value;
|
101
|
+
if (!context)
|
102
|
+
return;
|
103
|
+
// Determine expansion state
|
104
|
+
this.showLabel = this.isNested() ? true : context.expanded;
|
105
|
+
// Manage aria-label for accessibility
|
106
|
+
if (this.showLabel) {
|
107
|
+
this.removeAttribute('aria-label');
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
const label = (_b = this.label) !== null && _b !== void 0 ? _b : '';
|
111
|
+
this.ariaLabel = this.ariaLabel || label;
|
112
|
+
this.setAttribute('aria-label', label);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Check whether the navitem is inside a nested nav structure.
|
117
|
+
* Returns `true` if there is a parent `mdc-menupopover`
|
118
|
+
* This method assumes nesting implies deeper levels of nav hierarchy.
|
119
|
+
*/
|
120
|
+
isNested() {
|
121
|
+
let parent = this.parentElement;
|
122
|
+
while (parent) {
|
123
|
+
if (parent.tagName.toLowerCase() === MENUPOPOVER_TAGNAME) {
|
124
|
+
return true;
|
125
|
+
}
|
126
|
+
parent = parent.parentElement;
|
127
|
+
}
|
128
|
+
return false;
|
129
|
+
}
|
130
|
+
/**
|
131
|
+
* Modifies the icon name based on the active state.
|
132
|
+
* If the navItem is active, the icon name is suffixed with '-filled'.
|
133
|
+
* If the navItem is inactive, the icon name is restored to its original value.
|
134
|
+
* If '-filled' icon is not available, the icon name remains unchanged.
|
135
|
+
* @internal
|
136
|
+
* @param active - The active state.
|
137
|
+
*/
|
138
|
+
modifyIconName(active) {
|
139
|
+
if (!this.iconName)
|
140
|
+
return;
|
141
|
+
const isFilled = this.iconName.endsWith('-filled');
|
142
|
+
const baseIcon = getIconNameWithoutStyle(this.iconName);
|
143
|
+
if (active) {
|
144
|
+
if (!isFilled) {
|
145
|
+
this.prevIconName = this.iconName;
|
146
|
+
this.iconName = `${baseIcon}-filled`;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
else if (this.prevIconName) {
|
150
|
+
this.iconName = this.prevIconName;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
handleClickEvent() {
|
154
|
+
if (this.disabled)
|
155
|
+
return;
|
156
|
+
this.emitNavItemActiveChange(this.active);
|
157
|
+
}
|
158
|
+
update(changedProperties) {
|
159
|
+
super.update(changedProperties);
|
160
|
+
if (changedProperties.has('active')) {
|
161
|
+
this.modifyIconName(this.active);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
renderTextLabel(label) {
|
165
|
+
return html `
|
166
|
+
<mdc-text
|
167
|
+
type=${this.active ? TYPE.BODY_MIDSIZE_BOLD : TYPE.BODY_MIDSIZE_MEDIUM}
|
168
|
+
tagname=${VALID_TEXT_TAGS.SPAN}
|
169
|
+
part="text-container">
|
170
|
+
${label}
|
171
|
+
</mdc-text>
|
172
|
+
`;
|
173
|
+
}
|
174
|
+
renderArrowIcon(showLabel) {
|
175
|
+
const arrowClass = showLabel ? '' : 'arrow';
|
176
|
+
return html `
|
177
|
+
<mdc-icon
|
178
|
+
name=${ICON_NAME.RIGHT_ARROW}
|
179
|
+
length-unit="rem"
|
180
|
+
part="trailing-arrow"
|
181
|
+
class="${arrowClass}">
|
182
|
+
</mdc-icon>
|
183
|
+
`;
|
184
|
+
}
|
185
|
+
renderBadge(showLabel) {
|
186
|
+
const badgeClass = showLabel ? '' : 'badge';
|
187
|
+
const isValidBadgeType = Object.values(ALLOWED_BADGE_TYPES).includes(this.badgeType);
|
188
|
+
if (!isValidBadgeType) {
|
189
|
+
return nothing;
|
190
|
+
}
|
191
|
+
return html `
|
192
|
+
<mdc-badge
|
193
|
+
class="${badgeClass}"
|
194
|
+
type="${ifDefined(this.badgeType)}"
|
195
|
+
counter="${ifDefined(this.counter)}"
|
196
|
+
max-counter="${this.maxCounter}">
|
197
|
+
</mdc-badge>
|
198
|
+
`;
|
199
|
+
}
|
200
|
+
render() {
|
201
|
+
var _a;
|
202
|
+
const context = (_a = this.sideNavigationContext) === null || _a === void 0 ? void 0 : _a.value;
|
203
|
+
return html `
|
204
|
+
<div part="icon-container">
|
205
|
+
<mdc-icon
|
206
|
+
name="${this.iconName}"
|
207
|
+
size="1.5"
|
208
|
+
length-unit="rem"
|
209
|
+
part="icon"
|
210
|
+
></mdc-icon>
|
211
|
+
${!this.showLabel ? this.renderBadge(this.showLabel) : nothing}
|
212
|
+
</div>
|
213
|
+
${this.showLabel ? html `${this.renderTextLabel(this.label)}${this.renderBadge(this.showLabel)}` : nothing}
|
214
|
+
${(context === null || context === void 0 ? void 0 : context.hasSiblingWithTriggerId(this)) ? this.renderArrowIcon(this.showLabel) : nothing}
|
215
|
+
`;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
NavItem.styles = [...MenuItem.styles, ...styles];
|
219
|
+
__decorate([
|
220
|
+
property({ type: Boolean, reflect: true }),
|
221
|
+
__metadata("design:type", Boolean)
|
222
|
+
], NavItem.prototype, "active", void 0);
|
223
|
+
__decorate([
|
224
|
+
property({ type: String, reflect: true, attribute: 'badge-type' }),
|
225
|
+
__metadata("design:type", String)
|
226
|
+
], NavItem.prototype, "badgeType", void 0);
|
227
|
+
__decorate([
|
228
|
+
property({ type: Number, reflect: true }),
|
229
|
+
__metadata("design:type", Number)
|
230
|
+
], NavItem.prototype, "counter", void 0);
|
231
|
+
__decorate([
|
232
|
+
property({ type: Number, attribute: 'max-counter', reflect: true }),
|
233
|
+
__metadata("design:type", Number)
|
234
|
+
], NavItem.prototype, "maxCounter", void 0);
|
235
|
+
__decorate([
|
236
|
+
property({ type: String, reflect: true, attribute: 'nav-id' }),
|
237
|
+
__metadata("design:type", String)
|
238
|
+
], NavItem.prototype, "navId", void 0);
|
239
|
+
__decorate([
|
240
|
+
property({ type: Boolean, reflect: true, attribute: 'show-label' }),
|
241
|
+
__metadata("design:type", Boolean)
|
242
|
+
], NavItem.prototype, "showLabel", void 0);
|
243
|
+
__decorate([
|
244
|
+
property({ type: String, attribute: 'aria-label' }),
|
245
|
+
__metadata("design:type", Object)
|
246
|
+
], NavItem.prototype, "ariaLabel", void 0);
|
247
|
+
__decorate([
|
248
|
+
property({ type: Boolean, reflect: true, attribute: 'disable-aria-current' }),
|
249
|
+
__metadata("design:type", Boolean)
|
250
|
+
], NavItem.prototype, "disableAriaCurrent", void 0);
|
251
|
+
export default NavItem;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-navitem";
|
2
|
+
declare const ALLOWED_BADGE_TYPES: {
|
3
|
+
readonly DOT: "dot";
|
4
|
+
readonly COUNTER: "counter";
|
5
|
+
};
|
6
|
+
declare const ICON_NAME: {
|
7
|
+
readonly RIGHT_ARROW: "arrow-right-bold";
|
8
|
+
};
|
9
|
+
declare const DEFAULTS: {
|
10
|
+
readonly MAX_COUNTER: 99;
|
11
|
+
readonly TEXT_TYPE: "body-midsize-regular";
|
12
|
+
readonly TAG_NAME: "span";
|
13
|
+
readonly SIZE: 24;
|
14
|
+
readonly VARIANT: string;
|
15
|
+
};
|
16
|
+
export { DEFAULTS, TAG_NAME, ALLOWED_BADGE_TYPES, ICON_NAME };
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
import { BUTTON_SIZES } from '../buttonsimple/buttonsimple.constants';
|
3
|
+
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
4
|
+
import { TYPE as BADGE_TYPE } from '../badge/badge.constants';
|
5
|
+
import { VARIANTS } from '../sidenavigation/sidenavigation.constants';
|
6
|
+
const TAG_NAME = utils.constructTagName('navitem');
|
7
|
+
const ALLOWED_BADGE_TYPES = {
|
8
|
+
DOT: BADGE_TYPE.DOT,
|
9
|
+
COUNTER: BADGE_TYPE.COUNTER,
|
10
|
+
};
|
11
|
+
const ICON_NAME = {
|
12
|
+
RIGHT_ARROW: 'arrow-right-bold',
|
13
|
+
};
|
14
|
+
const DEFAULTS = {
|
15
|
+
MAX_COUNTER: 99,
|
16
|
+
TEXT_TYPE: TYPE.BODY_MIDSIZE_REGULAR,
|
17
|
+
TAG_NAME: VALID_TEXT_TAGS.SPAN,
|
18
|
+
SIZE: BUTTON_SIZES[24],
|
19
|
+
VARIANT: VARIANTS.FLEXIBLE,
|
20
|
+
};
|
21
|
+
export { DEFAULTS, TAG_NAME, ALLOWED_BADGE_TYPES, ICON_NAME };
|
@@ -0,0 +1,146 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
|
3
|
+
const styles = [hostFitContentStyles, css `
|
4
|
+
:host {
|
5
|
+
--mdc-navitem-color: var(--mds-color-theme-text-primary-normal);
|
6
|
+
--mdc-navitem-disabled-color: var(--mds-color-theme-text-primary-disabled);
|
7
|
+
--mdc-navitem-border-color: var(--mds-color-theme-outline-button-normal);
|
8
|
+
--mdc-navitem-expanded-width: 12.75rem;
|
9
|
+
|
10
|
+
/* Background color when in default (normal) or active state */
|
11
|
+
--mdc-navitem-rest-active-background-color: var(--mds-color-theme-button-secondary-active-normal);
|
12
|
+
--mdc-navitem-hover-background-color: var(--mds-color-theme-button-secondary-hover);
|
13
|
+
--mdc-navitem-hover-active-background-color: var(--mds-color-theme-button-secondary-active-hover);
|
14
|
+
--mdc-navitem-pressed-background-color: var(--mds-color-theme-button-secondary-pressed);
|
15
|
+
--mdc-navitem-pressed-active-background-color: var(--mds-color-theme-button-secondary-active-pressed);
|
16
|
+
--mdc-navitem-disabled-background-color: var(--mds-color-theme-button-secondary-disabled);
|
17
|
+
--mdc-navitem-disabled-active-background-color: var(--mds-color-theme-button-secondary-active-disabled);
|
18
|
+
|
19
|
+
position: relative;
|
20
|
+
display: flex;
|
21
|
+
align-items: center;
|
22
|
+
gap: 0.5rem;
|
23
|
+
padding: 0.5rem;
|
24
|
+
color: var(--mdc-navitem-color);
|
25
|
+
border-color: var(--mdc-navitem-border-color);
|
26
|
+
border-radius: 1.25rem;
|
27
|
+
cursor: pointer;
|
28
|
+
}
|
29
|
+
|
30
|
+
:host(:dir(ltr)) {
|
31
|
+
margin-left: 1rem;
|
32
|
+
}
|
33
|
+
|
34
|
+
:host(:dir(rtl)) {
|
35
|
+
margin-right: 1rem;
|
36
|
+
}
|
37
|
+
|
38
|
+
:host([show-label]) {
|
39
|
+
width: var(--mdc-navitem-expanded-width);
|
40
|
+
}
|
41
|
+
|
42
|
+
:host([active]) {
|
43
|
+
background-color: var(--mdc-navitem-rest-active-background-color);
|
44
|
+
}
|
45
|
+
|
46
|
+
:host([disabled]) {
|
47
|
+
color: var(--mdc-navitem-disabled-color);
|
48
|
+
background-color: var(--mdc-navitem-disabled-background-color);
|
49
|
+
pointer-events: none;
|
50
|
+
}
|
51
|
+
|
52
|
+
:host([active][disabled]) {
|
53
|
+
background-color: var(--mdc-navitem-disabled-active-background-color);
|
54
|
+
color: var(--mdc-navitem-disabled-color);
|
55
|
+
}
|
56
|
+
|
57
|
+
:host(:hover) {
|
58
|
+
background-color: var(--mdc-navitem-hover-background-color);
|
59
|
+
}
|
60
|
+
|
61
|
+
:host(:hover[active]) {
|
62
|
+
background-color: var(--mdc-navitem-hover-active-background-color);
|
63
|
+
}
|
64
|
+
|
65
|
+
:host(:active) {
|
66
|
+
background-color: var(--mdc-navitem-pressed-background-color);
|
67
|
+
}
|
68
|
+
|
69
|
+
:host(:active[active]) {
|
70
|
+
background-color: var(--mdc-navitem-pressed-active-background-color);
|
71
|
+
}
|
72
|
+
|
73
|
+
:host::before {
|
74
|
+
content: '';
|
75
|
+
display: block;
|
76
|
+
position: absolute;
|
77
|
+
background-color: var(--mdc-navitem-color);
|
78
|
+
width: 0.25rem;
|
79
|
+
height: 1rem;
|
80
|
+
pointer-events: none;
|
81
|
+
visibility: hidden;
|
82
|
+
}
|
83
|
+
|
84
|
+
:host(:dir(ltr))::before {
|
85
|
+
left: -1rem;
|
86
|
+
border-radius: 0 0.25rem 0.25rem 0;
|
87
|
+
}
|
88
|
+
|
89
|
+
:host(:dir(rtl))::before {
|
90
|
+
right: -1rem;
|
91
|
+
border-radius: 0.25rem 0 0 0.25rem;
|
92
|
+
}
|
93
|
+
|
94
|
+
:host([active])::before {
|
95
|
+
visibility: visible;
|
96
|
+
}
|
97
|
+
|
98
|
+
:host([disabled])::before {
|
99
|
+
background-color: var(--mdc-navitem-disabled-color);
|
100
|
+
}
|
101
|
+
|
102
|
+
:host::part(text-container) {
|
103
|
+
width: 100%;
|
104
|
+
overflow: hidden;
|
105
|
+
text-overflow: ellipsis;
|
106
|
+
white-space: nowrap;
|
107
|
+
}
|
108
|
+
|
109
|
+
:host::part(icon-container) {
|
110
|
+
position: relative;
|
111
|
+
}
|
112
|
+
|
113
|
+
:host(:dir(ltr)) .badge {
|
114
|
+
position: absolute;
|
115
|
+
right: -0.375rem;
|
116
|
+
top: -0.375rem;
|
117
|
+
}
|
118
|
+
|
119
|
+
:host(:dir(rtl)) .badge {
|
120
|
+
position: absolute;
|
121
|
+
left: -0.375rem;
|
122
|
+
top: -0.375rem;
|
123
|
+
}
|
124
|
+
|
125
|
+
:host(:not([show-label]))::part(trailing-arrow) {
|
126
|
+
--mdc-icon-size: 0.75rem;
|
127
|
+
}
|
128
|
+
|
129
|
+
:host([show-label])::part(trailing-arrow) {
|
130
|
+
--mdc-icon-size: 1rem;
|
131
|
+
flex-shrink: 0;
|
132
|
+
}
|
133
|
+
|
134
|
+
:host(:dir(ltr)) .arrow {
|
135
|
+
position: absolute;
|
136
|
+
right: -0.75rem;
|
137
|
+
top: 0.875rem;
|
138
|
+
}
|
139
|
+
|
140
|
+
:host(:dir(rtl)) .arrow {
|
141
|
+
position: absolute;
|
142
|
+
left: -0.75rem;
|
143
|
+
top: 0.875rem;
|
144
|
+
}
|
145
|
+
`, ...hostFocusRingStyles()];
|
146
|
+
export default styles;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { ValueOf } from '../../utils/types';
|
2
|
+
import { ALLOWED_BADGE_TYPES } from './navitem.constants';
|
3
|
+
type BadgeType = ValueOf<typeof ALLOWED_BADGE_TYPES>;
|
4
|
+
interface Events {
|
5
|
+
onClickEvent: MouseEvent;
|
6
|
+
onKeyDownEvent: KeyboardEvent;
|
7
|
+
onKeyUpEvent: KeyboardEvent;
|
8
|
+
onFocusEvent: FocusEvent;
|
9
|
+
onActiveChangeEvent: Event;
|
10
|
+
}
|
11
|
+
export type { Events, BadgeType };
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|