@momentum-design/components 0.75.4 → 0.76.1
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 +44 -32
- package/dist/browser/index.js.map +2 -2
- package/dist/components/listitem/listitem.component.d.ts +27 -0
- package/dist/components/listitem/listitem.component.js +40 -2
- package/dist/components/menuitem/menuitem.component.js +8 -2
- package/dist/custom-elements.json +1295 -1105
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +4 -4
- package/package.json +1 -1
@@ -97,8 +97,19 @@ declare class ListItem extends ListItem_base {
|
|
97
97
|
tooltipPlacement: PopoverPlacement;
|
98
98
|
constructor();
|
99
99
|
connectedCallback(): void;
|
100
|
+
/**
|
101
|
+
* Fires the click event when the enter or space key is pressed.
|
102
|
+
* @param event - The keyboard event triggered when a key is pressed down.
|
103
|
+
*/
|
100
104
|
private handleKeyDown;
|
105
|
+
/**
|
106
|
+
* Triggers a click event on the list item.
|
107
|
+
*/
|
101
108
|
private triggerClickEvent;
|
109
|
+
/**
|
110
|
+
* Handles the click event on the list item.
|
111
|
+
* If the tooltip is open, it has to be closed first.
|
112
|
+
*/
|
102
113
|
private handleClick;
|
103
114
|
/**
|
104
115
|
* Display a tooltip for the listitem.
|
@@ -126,8 +137,24 @@ declare class ListItem extends ListItem_base {
|
|
126
137
|
*/
|
127
138
|
private disableSlottedChildren;
|
128
139
|
update(changedProperties: PropertyValues): void;
|
140
|
+
/**
|
141
|
+
* Renders the trailing controls slot.
|
142
|
+
* @returns A template for the trailing controls slot.
|
143
|
+
*/
|
129
144
|
protected renderTrailingControls(): TemplateResult<1>;
|
145
|
+
/**
|
146
|
+
* Renders the leading controls slot.
|
147
|
+
* @returns A template for the leading controls slot.
|
148
|
+
*/
|
130
149
|
protected renderLeadingControls(): TemplateResult<1>;
|
150
|
+
/**
|
151
|
+
* Stops the click event from propagating to parent elements. In case of keyboard events,
|
152
|
+
* it stops the propagation for Enter and Space keys.
|
153
|
+
* This is useful when the list item contains controls that
|
154
|
+
* should not trigger the click event on the list item itself.
|
155
|
+
* @param event - The mouse event triggered when a click occurs.
|
156
|
+
*/
|
157
|
+
protected stopEventPropagation(event: Event): void;
|
131
158
|
render(): TemplateResult<1>;
|
132
159
|
static styles: Array<CSSResult>;
|
133
160
|
}
|
@@ -88,12 +88,19 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
88
88
|
super.connectedCallback();
|
89
89
|
this.role = this.role || ROLE.LISTITEM;
|
90
90
|
}
|
91
|
+
/**
|
92
|
+
* Fires the click event when the enter or space key is pressed.
|
93
|
+
* @param event - The keyboard event triggered when a key is pressed down.
|
94
|
+
*/
|
91
95
|
handleKeyDown(event) {
|
92
96
|
if (event.key === KEYS.ENTER || event.key === KEYS.SPACE) {
|
93
97
|
this.triggerClickEvent();
|
94
98
|
event.preventDefault();
|
95
99
|
}
|
96
100
|
}
|
101
|
+
/**
|
102
|
+
* Triggers a click event on the list item.
|
103
|
+
*/
|
97
104
|
triggerClickEvent() {
|
98
105
|
const clickEvent = new MouseEvent('click', {
|
99
106
|
bubbles: true,
|
@@ -102,6 +109,10 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
102
109
|
});
|
103
110
|
this.dispatchEvent(clickEvent);
|
104
111
|
}
|
112
|
+
/**
|
113
|
+
* Handles the click event on the list item.
|
114
|
+
* If the tooltip is open, it has to be closed first.
|
115
|
+
*/
|
105
116
|
handleClick() {
|
106
117
|
// If the tooltip is open, it has to be closed first.
|
107
118
|
this.hideTooltipOnLeave();
|
@@ -178,11 +189,38 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
|
|
178
189
|
this.setAttribute('aria-disabled', `${this.disabled}`);
|
179
190
|
}
|
180
191
|
}
|
192
|
+
/**
|
193
|
+
* Renders the trailing controls slot.
|
194
|
+
* @returns A template for the trailing controls slot.
|
195
|
+
*/
|
181
196
|
renderTrailingControls() {
|
182
|
-
return html `<slot name="trailing-controls"
|
197
|
+
return html `<slot name="trailing-controls"
|
198
|
+
@click=${this.stopEventPropagation}
|
199
|
+
@keyup=${this.stopEventPropagation}
|
200
|
+
@keydown=${this.stopEventPropagation}></slot>`;
|
183
201
|
}
|
202
|
+
/**
|
203
|
+
* Renders the leading controls slot.
|
204
|
+
* @returns A template for the leading controls slot.
|
205
|
+
*/
|
184
206
|
renderLeadingControls() {
|
185
|
-
return html `<slot name="leading-controls"
|
207
|
+
return html `<slot name="leading-controls"
|
208
|
+
@click=${this.stopEventPropagation}
|
209
|
+
@keyup=${this.stopEventPropagation}
|
210
|
+
@keydown=${this.stopEventPropagation}></slot>`;
|
211
|
+
}
|
212
|
+
/**
|
213
|
+
* Stops the click event from propagating to parent elements. In case of keyboard events,
|
214
|
+
* it stops the propagation for Enter and Space keys.
|
215
|
+
* This is useful when the list item contains controls that
|
216
|
+
* should not trigger the click event on the list item itself.
|
217
|
+
* @param event - The mouse event triggered when a click occurs.
|
218
|
+
*/
|
219
|
+
stopEventPropagation(event) {
|
220
|
+
if ((event instanceof KeyboardEvent && (event.key === KEYS.ENTER || event.key === KEYS.SPACE))
|
221
|
+
|| (event instanceof MouseEvent)) {
|
222
|
+
event.stopPropagation();
|
223
|
+
}
|
186
224
|
}
|
187
225
|
render() {
|
188
226
|
return html `
|
@@ -49,7 +49,10 @@ class MenuItem extends ListItem {
|
|
49
49
|
? ARROW_ICONS.LEFT
|
50
50
|
: ARROW_ICONS.RIGHT;
|
51
51
|
return html `
|
52
|
-
<slot name="trailing-controls"
|
52
|
+
<slot name="trailing-controls"
|
53
|
+
@click=${this.stopEventPropagation}
|
54
|
+
@keyup=${this.stopEventPropagation}
|
55
|
+
@keydown=${this.stopEventPropagation}></slot>
|
53
56
|
${this.arrowPosition === ARROW_POSITIONS.TRAILING
|
54
57
|
? html `<mdc-icon name="${arrowIcon}" length-unit="rem" part="trailing-arrow"></mdc-icon>`
|
55
58
|
: nothing}
|
@@ -64,7 +67,10 @@ class MenuItem extends ListItem {
|
|
64
67
|
? ARROW_ICONS.RIGHT
|
65
68
|
: ARROW_ICONS.LEFT;
|
66
69
|
return html `
|
67
|
-
<slot name="leading-controls"
|
70
|
+
<slot name="leading-controls"
|
71
|
+
@click=${this.stopEventPropagation}
|
72
|
+
@keyup=${this.stopEventPropagation}
|
73
|
+
@keydown=${this.stopEventPropagation}></slot>
|
68
74
|
${this.arrowPosition === ARROW_POSITIONS.LEADING
|
69
75
|
? html `<mdc-icon name="${arrowIcon}" length-unit="rem" part="leading-arrow"></mdc-icon>`
|
70
76
|
: nothing}
|