@momentum-design/components 0.84.0 → 0.84.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 +137 -137
- package/dist/browser/index.js.map +3 -3
- package/dist/components/menupopover/menupopover.component.d.ts +18 -1
- package/dist/components/menupopover/menupopover.component.js +32 -7
- package/dist/components/menupopover/menupopover.constants.d.ts +4 -1
- package/dist/components/menupopover/menupopover.constants.js +5 -1
- package/dist/components/popover/popover.component.d.ts +19 -0
- package/dist/components/popover/popover.component.js +39 -12
- package/dist/components/toggletip/toggletip.component.d.ts +18 -0
- package/dist/components/toggletip/toggletip.component.js +21 -1
- package/dist/custom-elements.json +477 -339
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
@@ -1,5 +1,6 @@
|
|
1
1
|
import { CSSResult, PropertyValues } from 'lit';
|
2
2
|
import Popover from '../popover/popover.component';
|
3
|
+
import { PopoverPlacement } from '../popover/popover.types';
|
3
4
|
/**
|
4
5
|
* A popover menu component that displays a list of menu items in a floating container.
|
5
6
|
* It's designed to work in conjunction with `mdc-menubar` and `mdc-menuitem` to create
|
@@ -21,10 +22,26 @@ import Popover from '../popover/popover.component';
|
|
21
22
|
* @slot default - Contains the menu items to be displayed in the popover
|
22
23
|
*/
|
23
24
|
declare class MenuPopover extends Popover {
|
25
|
+
/**
|
26
|
+
* The placement of the popover.
|
27
|
+
* - **top**
|
28
|
+
* - **top-start**
|
29
|
+
* - **top-end**
|
30
|
+
* - **bottom**
|
31
|
+
* - **bottom-start**
|
32
|
+
* - **bottom-end**
|
33
|
+
* - **left**
|
34
|
+
* - **left-start**
|
35
|
+
* - **left-end**
|
36
|
+
* - **right**
|
37
|
+
* - **right-start**
|
38
|
+
* - **right-end**
|
39
|
+
* @default bottom
|
40
|
+
*/
|
41
|
+
placement: PopoverPlacement;
|
24
42
|
constructor();
|
25
43
|
/** @internal */
|
26
44
|
get menuItems(): Array<HTMLElement>;
|
27
|
-
hidePopover: () => void;
|
28
45
|
connectedCallback(): void;
|
29
46
|
firstUpdated(changedProperties: PropertyValues): Promise<void>;
|
30
47
|
/**
|
@@ -1,10 +1,20 @@
|
|
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 { property } from 'lit/decorators.js';
|
1
11
|
import { KEYS } from '../../utils/keys';
|
2
12
|
import { ROLE } from '../../utils/roles';
|
3
13
|
import { TAG_NAME as MENUSECTION_TAGNAME } from '../menusection/menusection.constants';
|
4
14
|
import { ORIENTATION } from '../menubar/menubar.constants';
|
5
15
|
import Popover from '../popover/popover.component';
|
6
16
|
import { COLOR } from '../popover/popover.constants';
|
7
|
-
import { TAG_NAME as MENU_POPOVER } from './menupopover.constants';
|
17
|
+
import { DEFAULTS, TAG_NAME as MENU_POPOVER } from './menupopover.constants';
|
8
18
|
import styles from './menupopover.styles';
|
9
19
|
import { isActiveMenuItem, isValidMenuItem, isValidPopover } from './menupopover.utils';
|
10
20
|
import { popoverStack } from '../popover/popover.stack';
|
@@ -31,12 +41,23 @@ import { popoverStack } from '../popover/popover.stack';
|
|
31
41
|
class MenuPopover extends Popover {
|
32
42
|
constructor() {
|
33
43
|
super();
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
44
|
+
/**
|
45
|
+
* The placement of the popover.
|
46
|
+
* - **top**
|
47
|
+
* - **top-start**
|
48
|
+
* - **top-end**
|
49
|
+
* - **bottom**
|
50
|
+
* - **bottom-start**
|
51
|
+
* - **bottom-end**
|
52
|
+
* - **left**
|
53
|
+
* - **left-start**
|
54
|
+
* - **left-end**
|
55
|
+
* - **right**
|
56
|
+
* - **right-start**
|
57
|
+
* - **right-end**
|
58
|
+
* @default bottom
|
59
|
+
*/
|
60
|
+
this.placement = DEFAULTS.PLACEMENT;
|
40
61
|
/**
|
41
62
|
* Handles outside click events to close the popover.
|
42
63
|
* This method checks if the click occurred outside the popover and its trigger element.
|
@@ -247,4 +268,8 @@ class MenuPopover extends Popover {
|
|
247
268
|
}
|
248
269
|
}
|
249
270
|
MenuPopover.styles = [...Popover.styles, ...styles];
|
271
|
+
__decorate([
|
272
|
+
property({ type: String, reflect: true }),
|
273
|
+
__metadata("design:type", String)
|
274
|
+
], MenuPopover.prototype, "placement", void 0);
|
250
275
|
export default MenuPopover;
|
@@ -1,3 +1,7 @@
|
|
1
1
|
import utils from '../../utils/tag-name';
|
2
|
+
import { POPOVER_PLACEMENT } from '../popover/popover.constants';
|
2
3
|
const TAG_NAME = utils.constructTagName('menupopover');
|
3
|
-
|
4
|
+
const DEFAULTS = {
|
5
|
+
PLACEMENT: POPOVER_PLACEMENT.BOTTOM_START,
|
6
|
+
};
|
7
|
+
export { TAG_NAME, DEFAULTS };
|
@@ -215,6 +215,8 @@ declare class Popover extends Popover_base {
|
|
215
215
|
/** @internal */
|
216
216
|
private hoverTimer;
|
217
217
|
/** @internal */
|
218
|
+
private isHovered;
|
219
|
+
/** @internal */
|
218
220
|
protected isTriggerClicked: boolean;
|
219
221
|
/** @internal */
|
220
222
|
private openDelay;
|
@@ -264,6 +266,23 @@ declare class Popover extends Popover_base {
|
|
264
266
|
* @param newValue - The new value of the visible property.
|
265
267
|
*/
|
266
268
|
private isOpenUpdated;
|
269
|
+
/**
|
270
|
+
* Handles mouse enter event on the trigger element.
|
271
|
+
* This method sets the `isHovered` flag to true and shows the popover
|
272
|
+
*/
|
273
|
+
private handleMouseEnter;
|
274
|
+
/**
|
275
|
+
* Handles mouse leave event on the trigger element.
|
276
|
+
* This method sets the `isHovered` flag to false and starts the close delay
|
277
|
+
* timer to hide the popover.
|
278
|
+
*/
|
279
|
+
private handleMouseLeave;
|
280
|
+
/**
|
281
|
+
* Handles focus out event on the trigger element.
|
282
|
+
* This method checks if the popover is not hovered and hides the popover.
|
283
|
+
* If the popover is hovered, it will not hide the popover.
|
284
|
+
*/
|
285
|
+
private handleFocusOut;
|
267
286
|
/**
|
268
287
|
* Starts the close delay timer.
|
269
288
|
* If the popover is not interactive, it will close the popover after the delay.
|
@@ -229,6 +229,8 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
229
229
|
/** @internal */
|
230
230
|
this.hoverTimer = null;
|
231
231
|
/** @internal */
|
232
|
+
this.isHovered = false;
|
233
|
+
/** @internal */
|
232
234
|
this.isTriggerClicked = false;
|
233
235
|
/** @internal */
|
234
236
|
this.openDelay = 0;
|
@@ -280,6 +282,33 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
280
282
|
this.hidePopover();
|
281
283
|
}
|
282
284
|
};
|
285
|
+
/**
|
286
|
+
* Handles mouse enter event on the trigger element.
|
287
|
+
* This method sets the `isHovered` flag to true and shows the popover
|
288
|
+
*/
|
289
|
+
this.handleMouseEnter = () => {
|
290
|
+
this.isHovered = true;
|
291
|
+
this.showPopover();
|
292
|
+
};
|
293
|
+
/**
|
294
|
+
* Handles mouse leave event on the trigger element.
|
295
|
+
* This method sets the `isHovered` flag to false and starts the close delay
|
296
|
+
* timer to hide the popover.
|
297
|
+
*/
|
298
|
+
this.handleMouseLeave = () => {
|
299
|
+
this.isHovered = false;
|
300
|
+
this.startCloseDelay();
|
301
|
+
};
|
302
|
+
/**
|
303
|
+
* Handles focus out event on the trigger element.
|
304
|
+
* This method checks if the popover is not hovered and hides the popover.
|
305
|
+
* If the popover is hovered, it will not hide the popover.
|
306
|
+
*/
|
307
|
+
this.handleFocusOut = () => {
|
308
|
+
if (!this.isHovered) {
|
309
|
+
this.hidePopover();
|
310
|
+
}
|
311
|
+
};
|
283
312
|
/**
|
284
313
|
* Starts the close delay timer.
|
285
314
|
* If the popover is not interactive, it will close the popover after the delay.
|
@@ -318,12 +347,10 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
318
347
|
* Hides the popover.
|
319
348
|
*/
|
320
349
|
this.hidePopover = () => {
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
}, this.closeDelay);
|
326
|
-
}
|
350
|
+
setTimeout(() => {
|
351
|
+
this.visible = false;
|
352
|
+
this.isTriggerClicked = false;
|
353
|
+
}, this.closeDelay);
|
327
354
|
};
|
328
355
|
/**
|
329
356
|
* Toggles the popover visibility.
|
@@ -396,8 +423,8 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
396
423
|
}
|
397
424
|
if (this.trigger.includes('mouseenter')) {
|
398
425
|
const hoverBridge = this.renderRoot.querySelector('.popover-hover-bridge');
|
399
|
-
this.triggerElement.addEventListener('mouseenter', this.
|
400
|
-
this.triggerElement.addEventListener('mouseleave', this.
|
426
|
+
this.triggerElement.addEventListener('mouseenter', this.handleMouseEnter);
|
427
|
+
this.triggerElement.addEventListener('mouseleave', this.handleMouseLeave);
|
401
428
|
this.addEventListener('mouseenter', this.cancelCloseDelay);
|
402
429
|
this.addEventListener('mouseleave', this.startCloseDelay);
|
403
430
|
hoverBridge === null || hoverBridge === void 0 ? void 0 : hoverBridge.addEventListener('mouseenter', this.showPopover);
|
@@ -405,7 +432,7 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
405
432
|
if (this.trigger.includes('focusin')) {
|
406
433
|
this.triggerElement.addEventListener('focusin', this.showPopover);
|
407
434
|
if (!this.interactive) {
|
408
|
-
this.triggerElement.addEventListener('focusout', this.
|
435
|
+
this.triggerElement.addEventListener('focusout', this.handleFocusOut);
|
409
436
|
}
|
410
437
|
}
|
411
438
|
this.addEventListener('focus-trap-exit', this.hidePopover);
|
@@ -418,12 +445,12 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
418
445
|
return;
|
419
446
|
const hoverBridge = this.renderRoot.querySelector('.popover-hover-bridge');
|
420
447
|
this.triggerElement.removeEventListener('click', this.togglePopoverVisible);
|
421
|
-
this.triggerElement.removeEventListener('mouseenter', this.
|
422
|
-
this.triggerElement.removeEventListener('mouseleave', this.
|
448
|
+
this.triggerElement.removeEventListener('mouseenter', this.handleMouseEnter);
|
449
|
+
this.triggerElement.removeEventListener('mouseleave', this.handleMouseLeave);
|
423
450
|
this.removeEventListener('mouseenter', this.cancelCloseDelay);
|
424
451
|
this.removeEventListener('mouseleave', this.startCloseDelay);
|
425
452
|
this.triggerElement.removeEventListener('focusin', this.showPopover);
|
426
|
-
this.triggerElement.removeEventListener('focusout', this.
|
453
|
+
this.triggerElement.removeEventListener('focusout', this.handleFocusOut);
|
427
454
|
hoverBridge === null || hoverBridge === void 0 ? void 0 : hoverBridge.removeEventListener('mouseenter', this.showPopover);
|
428
455
|
this.removeEventListener('focus-trap-exit', this.hidePopover);
|
429
456
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { CSSResult, PropertyValueMap } from 'lit';
|
2
2
|
import Popover from '../popover/popover.component';
|
3
|
+
import { PopoverPlacement } from '../popover/popover.types';
|
3
4
|
/**
|
4
5
|
* A toggletip is triggered by clicking a trigger element.
|
5
6
|
*
|
@@ -48,6 +49,23 @@ declare class ToggleTip extends Popover {
|
|
48
49
|
* Please refer to the `mdc-screenreaderannouncer` component for more details.
|
49
50
|
*/
|
50
51
|
screenreaderAnnouncerIdentity?: string;
|
52
|
+
/**
|
53
|
+
* The placement of the popover.
|
54
|
+
* - **top**
|
55
|
+
* - **top-start**
|
56
|
+
* - **top-end**
|
57
|
+
* - **bottom**
|
58
|
+
* - **bottom-start**
|
59
|
+
* - **bottom-end**
|
60
|
+
* - **left**
|
61
|
+
* - **left-start**
|
62
|
+
* - **left-end**
|
63
|
+
* - **right**
|
64
|
+
* - **right-start**
|
65
|
+
* - **right-end**
|
66
|
+
* @default bottom
|
67
|
+
*/
|
68
|
+
placement: PopoverPlacement;
|
51
69
|
connectedCallback(): void;
|
52
70
|
/**
|
53
71
|
* @returns The text content of all the nodes in the default slot, joined by a space.
|
@@ -54,13 +54,29 @@ class ToggleTip extends Popover {
|
|
54
54
|
super(...arguments);
|
55
55
|
/** @internal */
|
56
56
|
this.currentAnnouncement = '';
|
57
|
+
/**
|
58
|
+
* The placement of the popover.
|
59
|
+
* - **top**
|
60
|
+
* - **top-start**
|
61
|
+
* - **top-end**
|
62
|
+
* - **bottom**
|
63
|
+
* - **bottom-start**
|
64
|
+
* - **bottom-end**
|
65
|
+
* - **left**
|
66
|
+
* - **left-start**
|
67
|
+
* - **left-end**
|
68
|
+
* - **right**
|
69
|
+
* - **right-start**
|
70
|
+
* - **right-end**
|
71
|
+
* @default bottom
|
72
|
+
*/
|
73
|
+
this.placement = DEFAULTS.PLACEMENT;
|
57
74
|
}
|
58
75
|
connectedCallback() {
|
59
76
|
var _a;
|
60
77
|
super.connectedCallback();
|
61
78
|
this.closeButton = (_a = this.closeButton) !== null && _a !== void 0 ? _a : DEFAULTS.CLOSE_BUTTON;
|
62
79
|
this.closeButtonAriaLabel = DEFAULTS.CLOSE_BUTTON_ARIA_LABEL;
|
63
|
-
this.placement = DEFAULTS.PLACEMENT;
|
64
80
|
this.trigger = DEFAULTS.CLICK;
|
65
81
|
this.showArrow = DEFAULTS.SHOW_ARROW;
|
66
82
|
this.interactive = true;
|
@@ -122,4 +138,8 @@ __decorate([
|
|
122
138
|
property({ type: String, reflect: true, attribute: 'screenreader-announcer-identity' }),
|
123
139
|
__metadata("design:type", String)
|
124
140
|
], ToggleTip.prototype, "screenreaderAnnouncerIdentity", void 0);
|
141
|
+
__decorate([
|
142
|
+
property({ type: String, reflect: true }),
|
143
|
+
__metadata("design:type", String)
|
144
|
+
], ToggleTip.prototype, "placement", void 0);
|
125
145
|
export default ToggleTip;
|