@momentum-design/components 0.104.14 → 0.104.15
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 +164 -158
- package/dist/browser/index.js.map +3 -3
- package/dist/components/sidenavigation/sidenavigation.component.d.ts +22 -32
- package/dist/components/sidenavigation/sidenavigation.component.js +40 -55
- package/dist/components/sidenavigation/sidenavigation.styles.js +5 -0
- package/dist/components/sidenavigation/sidenavigation.types.d.ts +9 -4
- package/dist/custom-elements.json +773 -737
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/sidenavigation/index.d.ts +23 -3
- package/dist/react/sidenavigation/index.js +15 -1
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CSSResult } from 'lit';
|
1
|
+
import { CSSResult, PropertyValues } from 'lit';
|
2
2
|
import { Provider } from '../../models';
|
3
3
|
import type { SideNavigationVariant } from './sidenavigation.types';
|
4
4
|
import SideNavigationContext from './sidenavigation.context';
|
@@ -50,15 +50,23 @@ import SideNavigationContext from './sidenavigation.context';
|
|
50
50
|
* @slot fixed-section - Slot for the fixed content area of the side navigation.
|
51
51
|
* @slot brand-logo - Slot for the brand logo (e.g., icon or img).
|
52
52
|
*
|
53
|
+
* @csspart side-navigation-container - The main container wrapping the entire side navigation.
|
54
|
+
* @csspart scrollable-section - The scrollable section of the side navigation.
|
55
|
+
* @csspart fixed-section - The fixed section of the side navigation.
|
56
|
+
* @csspart separator - The divider between the scrollable and fixed sections.
|
57
|
+
* @csspart brand-logo-container - The container wrapping the brand logo and footer text.
|
58
|
+
* @csspart footer-text - The footer text label in the fixed section.
|
59
|
+
* @csspart vertical-divider - The vertical divider between the scrollable and fixed sections.
|
60
|
+
* @csspart vertical-divider-button - The button inside the vertical divider used to toggle expand/collapse.
|
61
|
+
*
|
62
|
+
* @event toggle - (React: onToggle) Dispatched when the grabber button is clicked to expand/collapse the sidenavigation.
|
63
|
+
* @event activechange - (React: onActiveChange) Dispatched when the active state of a nested navmenuitem changes.
|
64
|
+
*
|
53
65
|
* @cssproperty --mdc-sidenavigation-expanded-width - width of the sideNavigation when expanded
|
54
|
-
* @cssproperty --mdc-sidenavigation-collapsed-width - width of the sideNavigation when
|
66
|
+
* @cssproperty --mdc-sidenavigation-collapsed-width - width of the sideNavigation when collapsed
|
67
|
+
* @cssproperty --mdc-sidenavigation-vertical-divider-button-z-index - z-index of the vertical divider button
|
55
68
|
*/
|
56
69
|
declare class SideNavigation extends Provider<SideNavigationContext> {
|
57
|
-
constructor();
|
58
|
-
connectedCallback(): void;
|
59
|
-
static get Context(): {
|
60
|
-
__context__: SideNavigationContext;
|
61
|
-
};
|
62
70
|
/**
|
63
71
|
* Four variants of the sideNavigation
|
64
72
|
* - **fixed-collapsed**: Shows icons without labels and has fixed width, 4.5rem.
|
@@ -90,25 +98,13 @@ declare class SideNavigation extends Provider<SideNavigationContext> {
|
|
90
98
|
* Tooltip text shown on parent nav items when a child is active.
|
91
99
|
*/
|
92
100
|
parentNavTooltipText?: string;
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
*/
|
99
|
-
private flexibleExpanded;
|
100
|
-
/**
|
101
|
-
* Direction of the arrow icon, if applicable.
|
102
|
-
* - **positive**
|
103
|
-
* - **negative**
|
104
|
-
*
|
105
|
-
* Note: Positive and Negative directions are defined based on Cartesian plane.
|
106
|
-
* @default 'negative'
|
107
|
-
*
|
108
|
-
* @internal
|
109
|
-
*/
|
110
|
-
private arrowDirection;
|
101
|
+
constructor();
|
102
|
+
connectedCallback(): void;
|
103
|
+
static get Context(): {
|
104
|
+
__context__: SideNavigationContext;
|
105
|
+
};
|
111
106
|
protected updated(changedProperties: Map<string, any>): void;
|
107
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
112
108
|
/**
|
113
109
|
* Update all observing components of this
|
114
110
|
* provider to update the values
|
@@ -131,14 +127,9 @@ declare class SideNavigation extends Provider<SideNavigationContext> {
|
|
131
127
|
private findNav;
|
132
128
|
/**
|
133
129
|
* Returns all nested, non-disabled mdc-navmenuitem elements inside this component.
|
134
|
-
*/
|
135
|
-
private get navMenuItems();
|
136
|
-
/**
|
137
|
-
* Syncs `expanded` and `aria-expanded` based on `variant` and `flexibleExpanded`.
|
138
|
-
*
|
139
130
|
* @internal
|
140
131
|
*/
|
141
|
-
private
|
132
|
+
private get navMenuItems();
|
142
133
|
/**
|
143
134
|
* Sets the variant attribute for the sideNavigation component.
|
144
135
|
* If the provided variant is not included in the variant,
|
@@ -151,7 +142,6 @@ declare class SideNavigation extends Provider<SideNavigationContext> {
|
|
151
142
|
private setVariant;
|
152
143
|
/**
|
153
144
|
* Toggles navigation state for the flexible variant.
|
154
|
-
* Updates `flexibleExpanded`, `ariaExpanded`, and `arrowDirection`.
|
155
145
|
*
|
156
146
|
* @internal
|
157
147
|
*/
|
@@ -8,7 +8,7 @@ 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
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
12
|
import { Component, Provider } from '../../models';
|
13
13
|
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
14
14
|
import { TAG_NAME as NAVMENUITEM_TAGNAME } from '../navmenuitem/navmenuitem.constants';
|
@@ -66,8 +66,21 @@ import styles from './sidenavigation.styles';
|
|
66
66
|
* @slot fixed-section - Slot for the fixed content area of the side navigation.
|
67
67
|
* @slot brand-logo - Slot for the brand logo (e.g., icon or img).
|
68
68
|
*
|
69
|
+
* @csspart side-navigation-container - The main container wrapping the entire side navigation.
|
70
|
+
* @csspart scrollable-section - The scrollable section of the side navigation.
|
71
|
+
* @csspart fixed-section - The fixed section of the side navigation.
|
72
|
+
* @csspart separator - The divider between the scrollable and fixed sections.
|
73
|
+
* @csspart brand-logo-container - The container wrapping the brand logo and footer text.
|
74
|
+
* @csspart footer-text - The footer text label in the fixed section.
|
75
|
+
* @csspart vertical-divider - The vertical divider between the scrollable and fixed sections.
|
76
|
+
* @csspart vertical-divider-button - The button inside the vertical divider used to toggle expand/collapse.
|
77
|
+
*
|
78
|
+
* @event toggle - (React: onToggle) Dispatched when the grabber button is clicked to expand/collapse the sidenavigation.
|
79
|
+
* @event activechange - (React: onActiveChange) Dispatched when the active state of a nested navmenuitem changes.
|
80
|
+
*
|
69
81
|
* @cssproperty --mdc-sidenavigation-expanded-width - width of the sideNavigation when expanded
|
70
|
-
* @cssproperty --mdc-sidenavigation-collapsed-width - width of the sideNavigation when
|
82
|
+
* @cssproperty --mdc-sidenavigation-collapsed-width - width of the sideNavigation when collapsed
|
83
|
+
* @cssproperty --mdc-sidenavigation-vertical-divider-button-z-index - z-index of the vertical divider button
|
71
84
|
*/
|
72
85
|
class SideNavigation extends Provider {
|
73
86
|
constructor() {
|
@@ -89,24 +102,6 @@ class SideNavigation extends Provider {
|
|
89
102
|
* @default ''
|
90
103
|
*/
|
91
104
|
this.footerText = '';
|
92
|
-
/**
|
93
|
-
* Toggles between true and false when it's variant is flexible.
|
94
|
-
* @default true
|
95
|
-
*
|
96
|
-
* @internal
|
97
|
-
*/
|
98
|
-
this.flexibleExpanded = this.variant === DEFAULTS.VARIANT;
|
99
|
-
/**
|
100
|
-
* Direction of the arrow icon, if applicable.
|
101
|
-
* - **positive**
|
102
|
-
* - **negative**
|
103
|
-
*
|
104
|
-
* Note: Positive and Negative directions are defined based on Cartesian plane.
|
105
|
-
* @default 'negative'
|
106
|
-
*
|
107
|
-
* @internal
|
108
|
-
*/
|
109
|
-
this.arrowDirection = this.flexibleExpanded ? DIRECTIONS.NEGATIVE : DIRECTIONS.POSITIVE;
|
110
105
|
/**
|
111
106
|
* Handle the navMenuItem active change event fired from the nested navMenuItem.
|
112
107
|
* @internal
|
@@ -126,25 +121,6 @@ class SideNavigation extends Provider {
|
|
126
121
|
* @internal
|
127
122
|
*/
|
128
123
|
this.findNav = (navs, navId) => navs.find(nav => nav.navId === navId);
|
129
|
-
/**
|
130
|
-
* Syncs `expanded` and `aria-expanded` based on `variant` and `flexibleExpanded`.
|
131
|
-
*
|
132
|
-
* @internal
|
133
|
-
*/
|
134
|
-
this.updateExpansionState = () => {
|
135
|
-
switch (this.variant) {
|
136
|
-
case VARIANTS.FLEXIBLE:
|
137
|
-
this.expanded = this.flexibleExpanded;
|
138
|
-
break;
|
139
|
-
case VARIANTS.FIXED_EXPANDED:
|
140
|
-
this.expanded = true;
|
141
|
-
break;
|
142
|
-
case VARIANTS.FIXED_COLLAPSED:
|
143
|
-
this.expanded = false;
|
144
|
-
break;
|
145
|
-
default:
|
146
|
-
}
|
147
|
-
};
|
148
124
|
this.addEventListener('activechange', this.handleNestedNavMenuItemActiveChange.bind(this));
|
149
125
|
}
|
150
126
|
connectedCallback() {
|
@@ -158,12 +134,29 @@ class SideNavigation extends Provider {
|
|
158
134
|
super.updated(changedProperties);
|
159
135
|
if (changedProperties.has('variant')) {
|
160
136
|
this.setVariant(this.variant);
|
161
|
-
|
137
|
+
// hard set expanded state for fixed variants:
|
138
|
+
switch (this.variant) {
|
139
|
+
case VARIANTS.FIXED_EXPANDED:
|
140
|
+
this.expanded = true;
|
141
|
+
break;
|
142
|
+
case VARIANTS.FIXED_COLLAPSED:
|
143
|
+
this.expanded = false;
|
144
|
+
break;
|
145
|
+
default:
|
146
|
+
}
|
162
147
|
}
|
163
148
|
if (changedProperties.has('variant') || changedProperties.has('expanded')) {
|
164
149
|
this.updateContext();
|
165
150
|
}
|
166
151
|
}
|
152
|
+
firstUpdated(changedProperties) {
|
153
|
+
super.firstUpdated(changedProperties);
|
154
|
+
if (this.variant === VARIANTS.FLEXIBLE && this.expanded === undefined) {
|
155
|
+
// if on first update the variant is flexible and expanded is not set, default to expanded true
|
156
|
+
this.expanded = true;
|
157
|
+
this.updateContext();
|
158
|
+
}
|
159
|
+
}
|
167
160
|
/**
|
168
161
|
* Update all observing components of this
|
169
162
|
* provider to update the values
|
@@ -182,6 +175,7 @@ class SideNavigation extends Provider {
|
|
182
175
|
}
|
183
176
|
/**
|
184
177
|
* Returns all nested, non-disabled mdc-navmenuitem elements inside this component.
|
178
|
+
* @internal
|
185
179
|
*/
|
186
180
|
get navMenuItems() {
|
187
181
|
return Array.from(this.querySelectorAll(`${NAVMENUITEM_TAGNAME}:not([disabled])`));
|
@@ -200,14 +194,12 @@ class SideNavigation extends Provider {
|
|
200
194
|
}
|
201
195
|
/**
|
202
196
|
* Toggles navigation state for the flexible variant.
|
203
|
-
* Updates `flexibleExpanded`, `ariaExpanded`, and `arrowDirection`.
|
204
197
|
*
|
205
198
|
* @internal
|
206
199
|
*/
|
207
200
|
toggleSideNavigation() {
|
208
|
-
this.
|
209
|
-
this.
|
210
|
-
this.updateExpansionState();
|
201
|
+
this.expanded = !this.expanded;
|
202
|
+
this.dispatchEvent(new CustomEvent('toggle', { detail: { expanded: this.expanded } }));
|
211
203
|
}
|
212
204
|
preventScrollOnSpace(event) {
|
213
205
|
// Prevent default space key behavior to avoid scrolling the page
|
@@ -239,7 +231,7 @@ class SideNavigation extends Provider {
|
|
239
231
|
<div part="brand-logo-container">
|
240
232
|
<slot name="brand-logo"></slot>
|
241
233
|
${this.expanded
|
242
|
-
? html `<mdc-text type=${TYPE.BODY_MIDSIZE_MEDIUM} tagname=${VALID_TEXT_TAGS.SPAN} part="
|
234
|
+
? html `<mdc-text type=${TYPE.BODY_MIDSIZE_MEDIUM} tagname=${VALID_TEXT_TAGS.SPAN} part="footer-text"
|
243
235
|
>${this.footerText}</mdc-text
|
244
236
|
>`
|
245
237
|
: nothing}
|
@@ -248,17 +240,18 @@ class SideNavigation extends Provider {
|
|
248
240
|
</div>
|
249
241
|
${this.variant === VARIANTS.FLEXIBLE
|
250
242
|
? html `<mdc-divider
|
243
|
+
part="vertical-divider"
|
251
244
|
orientation=${DIVIDER_ORIENTATION.VERTICAL}
|
252
245
|
variant=${DIVIDER_VARIANT.GRADIENT}
|
253
|
-
arrow-direction=${this.
|
246
|
+
arrow-direction=${this.expanded ? DIRECTIONS.NEGATIVE : DIRECTIONS.POSITIVE}
|
254
247
|
button-position=${DIRECTIONS.POSITIVE}
|
255
248
|
>
|
256
249
|
<mdc-button
|
250
|
+
part="vertical-divider-button"
|
257
251
|
aria-label=${(_a = this.grabberBtnAriaLabel) !== null && _a !== void 0 ? _a : ''}
|
258
252
|
@click=${this.toggleSideNavigation}
|
259
253
|
aria-expanded="${!!this.expanded}"
|
260
254
|
aria-controls="side-nav-container"
|
261
|
-
part="grabber-btn"
|
262
255
|
></mdc-button>
|
263
256
|
</mdc-divider>`
|
264
257
|
: nothing}
|
@@ -286,12 +279,4 @@ __decorate([
|
|
286
279
|
property({ type: String, reflect: true, attribute: 'parent-nav-tooltip-text' }),
|
287
280
|
__metadata("design:type", String)
|
288
281
|
], SideNavigation.prototype, "parentNavTooltipText", void 0);
|
289
|
-
__decorate([
|
290
|
-
state(),
|
291
|
-
__metadata("design:type", Object)
|
292
|
-
], SideNavigation.prototype, "flexibleExpanded", void 0);
|
293
|
-
__decorate([
|
294
|
-
state(),
|
295
|
-
__metadata("design:type", String)
|
296
|
-
], SideNavigation.prototype, "arrowDirection", void 0);
|
297
282
|
export default SideNavigation;
|
@@ -3,6 +3,7 @@ const styles = css `
|
|
3
3
|
:host {
|
4
4
|
--mdc-sidenavigation-expanded-width: 15rem;
|
5
5
|
--mdc-sidenavigation-collapsed-width: 4.5rem;
|
6
|
+
--mdc-sidenavigation-vertical-divider-button-z-index: auto;
|
6
7
|
|
7
8
|
display: flex;
|
8
9
|
height: 100%;
|
@@ -64,5 +65,9 @@ const styles = css `
|
|
64
65
|
:host::part(separator) {
|
65
66
|
margin-bottom: 0.75rem;
|
66
67
|
}
|
68
|
+
|
69
|
+
:host::part(vertical-divider-button) {
|
70
|
+
z-index: var(--mdc-sidenavigation-vertical-divider-button-z-index);
|
71
|
+
}
|
67
72
|
`;
|
68
73
|
export default [styles];
|
@@ -2,10 +2,15 @@ import type { TypedCustomEvent, ValueOf } from '../../utils/types';
|
|
2
2
|
import type SideNavigation from './sidenavigation.component';
|
3
3
|
import { VARIANTS } from './sidenavigation.constants';
|
4
4
|
type SideNavigationVariant = ValueOf<typeof VARIANTS>;
|
5
|
+
type SideNavigationActiveChangeEvent = TypedCustomEvent<SideNavigation, {
|
6
|
+
navId: string;
|
7
|
+
active: boolean;
|
8
|
+
}>;
|
9
|
+
type SideNavigationToggleEvent = TypedCustomEvent<SideNavigation, {
|
10
|
+
expanded: boolean;
|
11
|
+
}>;
|
5
12
|
interface Events {
|
6
|
-
onActiveChangeEvent:
|
7
|
-
|
8
|
-
active: boolean;
|
9
|
-
}>;
|
13
|
+
onActiveChangeEvent: SideNavigationActiveChangeEvent;
|
14
|
+
onToggleEvent: SideNavigationToggleEvent;
|
10
15
|
}
|
11
16
|
export type { SideNavigationVariant, Events };
|