@momentum-design/components 0.89.0 → 0.90.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.
- package/dist/browser/index.js +158 -158
- package/dist/browser/index.js.map +3 -3
- package/dist/components/menupopover/menupopover.component.d.ts +1 -0
- package/dist/components/menupopover/menupopover.component.js +14 -1
- package/dist/components/menupopover/menupopover.utils.js +4 -2
- package/dist/components/popover/popover.component.d.ts +11 -1
- package/dist/components/popover/popover.component.js +28 -0
- package/dist/custom-elements.json +686 -567
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +4 -4
- package/package.json +1 -1
@@ -49,6 +49,7 @@ declare class MenuPopover extends Popover {
|
|
49
49
|
/** @internal */
|
50
50
|
get menuItems(): Array<HTMLElement>;
|
51
51
|
connectedCallback(): void;
|
52
|
+
protected isOpenUpdated(oldValue: boolean, newValue: boolean): Promise<void>;
|
52
53
|
firstUpdated(changedProperties: PropertyValues): Promise<void>;
|
53
54
|
/**
|
54
55
|
* Retrieves the current index of the menu item that triggered the event.
|
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
10
|
import { property } from 'lit/decorators.js';
|
11
11
|
import { KEYS } from '../../utils/keys';
|
12
12
|
import { ROLE } from '../../utils/roles';
|
13
|
+
import { TAG_NAME as MENUITEM_TAGNAME } from '../menuitem/menuitem.constants';
|
13
14
|
import { TAG_NAME as MENUSECTION_TAGNAME } from '../menusection/menusection.constants';
|
14
15
|
import Popover from '../popover/popover.component';
|
15
16
|
import { COLOR } from '../popover/popover.constants';
|
@@ -73,7 +74,7 @@ class MenuPopover extends Popover {
|
|
73
74
|
this.onOutsidePopoverClick = (event) => {
|
74
75
|
if (popoverStack.peek() !== this)
|
75
76
|
return;
|
76
|
-
const popoverOfTarget = event.target
|
77
|
+
const popoverOfTarget = this.findClosestPopover(event.target);
|
77
78
|
// If the click occurred on a submenu, close all popovers until the submenu
|
78
79
|
if (popoverOfTarget && popoverStack.has(popoverOfTarget)) {
|
79
80
|
this.closeAllMenuPopovers(popoverOfTarget);
|
@@ -132,6 +133,18 @@ class MenuPopover extends Popover {
|
|
132
133
|
this.closeButton = false;
|
133
134
|
this.closeButtonAriaLabel = null;
|
134
135
|
}
|
136
|
+
async isOpenUpdated(oldValue, newValue) {
|
137
|
+
if (oldValue === newValue || !this.triggerElement)
|
138
|
+
return Promise.resolve();
|
139
|
+
// Set backdrop to true when the popover is opened with other than menu item.
|
140
|
+
//
|
141
|
+
// make sure backdrop is set before showing the popover, but it does not change when popover is closing, otherwise
|
142
|
+
// `super.isOpenUpdated` will skip the backdrop cleanup
|
143
|
+
if (newValue) {
|
144
|
+
this.backdrop = !(this.triggerElement.tagName.toLowerCase() === MENUITEM_TAGNAME);
|
145
|
+
}
|
146
|
+
return super.isOpenUpdated(oldValue, newValue);
|
147
|
+
}
|
135
148
|
async firstUpdated(changedProperties) {
|
136
149
|
var _a;
|
137
150
|
await super.firstUpdated(changedProperties);
|
@@ -8,8 +8,10 @@ import { TAG_NAME as MENUPOPOVER_TAGNAME } from './menupopover.constants';
|
|
8
8
|
* @returns True if the menu item is a valid menu item, false otherwise.
|
9
9
|
*/
|
10
10
|
const isValidMenuItem = (menuItem) => {
|
11
|
-
|
12
|
-
|
11
|
+
if (!menuItem)
|
12
|
+
return false;
|
13
|
+
const tagName = menuItem.tagName.toLowerCase();
|
14
|
+
return [MENUITEM_TAGNAME, MENUITEMCHECKBOX_TAGNAME, MENUITEMRADIO_TAGNAME].includes(tagName);
|
13
15
|
};
|
14
16
|
const isValidPopover = (el) => { var _a; return ((_a = el === null || el === void 0 ? void 0 : el.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === MENUPOPOVER_TAGNAME; };
|
15
17
|
const isActiveMenuItem = (menuItem) => { var _a, _b; return ((_b = (_a = menuItem === null || menuItem === void 0 ? void 0 : menuItem.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a)) === MENUITEM_TAGNAME && !menuItem.hasAttribute('disabled'); };
|
@@ -213,6 +213,8 @@ declare class Popover extends Popover_base {
|
|
213
213
|
arrowElement: HTMLElement | null;
|
214
214
|
triggerElement: HTMLElement | null;
|
215
215
|
/** @internal */
|
216
|
+
private triggerElementOriginalStyle;
|
217
|
+
/** @internal */
|
216
218
|
private hoverTimer;
|
217
219
|
/** @internal */
|
218
220
|
private isHovered;
|
@@ -265,7 +267,7 @@ declare class Popover extends Popover_base {
|
|
265
267
|
* @param oldValue - The old value of the visible property.
|
266
268
|
* @param newValue - The new value of the visible property.
|
267
269
|
*/
|
268
|
-
|
270
|
+
protected isOpenUpdated(oldValue: boolean, newValue: boolean): Promise<void>;
|
269
271
|
/**
|
270
272
|
* Handles mouse enter event on the trigger element.
|
271
273
|
* This method sets the `isHovered` flag to true and shows the popover
|
@@ -310,6 +312,14 @@ declare class Popover extends Popover_base {
|
|
310
312
|
* It uses the floating-ui/dom library to calculate the position.
|
311
313
|
*/
|
312
314
|
private positionPopover;
|
315
|
+
/**
|
316
|
+
* Finds the closest popover to the passed element in the DOM tree.
|
317
|
+
*
|
318
|
+
* Useful when need to find the parent popover in a nested popover scenario.
|
319
|
+
*
|
320
|
+
* @param element - The element to start searching from.
|
321
|
+
*/
|
322
|
+
protected findClosestPopover(element: Element): Popover | null;
|
313
323
|
render(): import("lit-html").TemplateResult<1>;
|
314
324
|
static styles: Array<CSSResult>;
|
315
325
|
}
|
@@ -227,6 +227,11 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
227
227
|
this.arrowElement = null;
|
228
228
|
this.triggerElement = null;
|
229
229
|
/** @internal */
|
230
|
+
this.triggerElementOriginalStyle = {
|
231
|
+
zIndex: '',
|
232
|
+
position: '',
|
233
|
+
};
|
234
|
+
/** @internal */
|
230
235
|
this.hoverTimer = null;
|
231
236
|
/** @internal */
|
232
237
|
this.isHovered = false;
|
@@ -534,6 +539,11 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
534
539
|
}
|
535
540
|
if (this.backdrop) {
|
536
541
|
this.utils.createBackdrop();
|
542
|
+
this.triggerElementOriginalStyle = {
|
543
|
+
position: this.triggerElement.style.position,
|
544
|
+
zIndex: this.triggerElement.style.zIndex,
|
545
|
+
};
|
546
|
+
this.triggerElement.style.position = 'relative';
|
537
547
|
this.triggerElement.style.zIndex = `${this.zIndex}`;
|
538
548
|
}
|
539
549
|
this.positionPopover();
|
@@ -563,6 +573,10 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
563
573
|
if (popoverStack.peek() === this) {
|
564
574
|
popoverStack.pop();
|
565
575
|
}
|
576
|
+
if (this.backdrop) {
|
577
|
+
this.triggerElement.style.position = this.triggerElementOriginalStyle.position;
|
578
|
+
this.triggerElement.style.zIndex = this.triggerElementOriginalStyle.zIndex;
|
579
|
+
}
|
566
580
|
if (this.backdropElement) {
|
567
581
|
(_d = this.backdropElement) === null || _d === void 0 ? void 0 : _d.remove();
|
568
582
|
this.backdropElement = null;
|
@@ -648,6 +662,20 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
|
|
648
662
|
}
|
649
663
|
});
|
650
664
|
}
|
665
|
+
/**
|
666
|
+
* Finds the closest popover to the passed element in the DOM tree.
|
667
|
+
*
|
668
|
+
* Useful when need to find the parent popover in a nested popover scenario.
|
669
|
+
*
|
670
|
+
* @param element - The element to start searching from.
|
671
|
+
*/
|
672
|
+
findClosestPopover(element) {
|
673
|
+
let el = element;
|
674
|
+
while (el && !(el instanceof Popover)) {
|
675
|
+
el = el.parentElement;
|
676
|
+
}
|
677
|
+
return el;
|
678
|
+
}
|
651
679
|
render() {
|
652
680
|
return html `
|
653
681
|
<div class="popover-hover-bridge"></div>
|