wj-elements 0.1.221 → 0.1.223
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/packages/wje-dropdown/dropdown.element.d.ts +20 -1
- package/dist/packages/wje-menu-item/menu-item.element.d.ts +3 -1
- package/dist/packages/wje-popup/popup.element.d.ts +3 -1
- package/dist/{popup.element-DmYw9KXv.js → popup.element-C_eXD5J4.js} +37 -8
- package/dist/{popup.element-DmYw9KXv.js.map → popup.element-C_eXD5J4.js.map} +1 -1
- package/dist/wje-dropdown.js +69 -13
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-icon-picker.js +1 -1
- package/dist/wje-master.js +1 -1
- package/dist/wje-menu-item.js +28 -8
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/wje-select.js +27 -2
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-tooltip.js +1 -1
- package/package.json +1 -1
|
@@ -26,6 +26,19 @@ export default class Dropdown extends WJElement {
|
|
|
26
26
|
dependencies: {
|
|
27
27
|
"wje-popup": Popup;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Sets or removes the 'portaled' attribute on the element.
|
|
31
|
+
* When the value is truthy, the attribute 'portaled' is added to the element.
|
|
32
|
+
* When the value is falsy, the attribute 'portaled' is removed from the element.
|
|
33
|
+
* @param {boolean} value - Determines whether to add or remove the 'portaled' attribute.
|
|
34
|
+
*/
|
|
35
|
+
set portaled(value: boolean);
|
|
36
|
+
/**
|
|
37
|
+
* Getter method for the `portaled` property.
|
|
38
|
+
* Checks if the `portaled` attribute is present on the element.
|
|
39
|
+
* @returns {boolean} Returns `true` if the `portaled` attribute exists, otherwise `false`.
|
|
40
|
+
*/
|
|
41
|
+
get portaled(): boolean;
|
|
29
42
|
/**
|
|
30
43
|
* Sets the placement of the dropdown.
|
|
31
44
|
* @param value
|
|
@@ -52,11 +65,16 @@ export default class Dropdown extends WJElement {
|
|
|
52
65
|
*/
|
|
53
66
|
draw(): DocumentFragment;
|
|
54
67
|
anchorSlot: HTMLSlotElement;
|
|
55
|
-
popupHideCallback: (e: any) => void;
|
|
56
68
|
/**
|
|
57
69
|
* Adds event listeners for the mouseenter and mouseleave events.
|
|
58
70
|
*/
|
|
59
71
|
afterDraw(): void;
|
|
72
|
+
popupHideCallback: (e: any) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Handles delegated clicks from inside the popup and closes the dropdown when a leaf menu item is selected.
|
|
75
|
+
* This works even when the menu is portaled, because we rely on the composed path.
|
|
76
|
+
*/
|
|
77
|
+
onMenuItemClick: (e: any) => void;
|
|
60
78
|
/**
|
|
61
79
|
* @summary Toggles the dropdown element between active and inactive states.
|
|
62
80
|
* Calls the `onOpen` method if the element is currently inactive,
|
|
@@ -81,4 +99,5 @@ export default class Dropdown extends WJElement {
|
|
|
81
99
|
beforeClose: () => void;
|
|
82
100
|
afterClose: () => void;
|
|
83
101
|
onClose: () => void;
|
|
102
|
+
#private;
|
|
84
103
|
}
|
|
@@ -43,7 +43,7 @@ export default class MenuItem extends WJElement {
|
|
|
43
43
|
* @returns {Array} An empty array as no attributes are being observed.
|
|
44
44
|
*/
|
|
45
45
|
static get observedAttributes(): any[];
|
|
46
|
-
|
|
46
|
+
_bind: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Getter for placement attribute.
|
|
49
49
|
* @returns {string} The placement attribute of the menu or "right-start" if it doesn't exist.
|
|
@@ -101,6 +101,8 @@ export default class MenuItem extends WJElement {
|
|
|
101
101
|
afterDraw(): void;
|
|
102
102
|
unbindRouterLinks: any;
|
|
103
103
|
mouseenterHandler: (e: any) => void;
|
|
104
|
+
rebindRouterLinks: (e: any) => void;
|
|
105
|
+
unbindPortalRouterLinks: any;
|
|
104
106
|
/**
|
|
105
107
|
* Handles the click event on the MenuItem.
|
|
106
108
|
* @param {object} e
|
|
@@ -52,6 +52,7 @@ export default class Popup extends WJElement {
|
|
|
52
52
|
* @returns {boolean} True if the 'portal' attribute exists, otherwise false.
|
|
53
53
|
*/
|
|
54
54
|
get portal(): boolean;
|
|
55
|
+
get floatingEl(): HTMLDivElement;
|
|
55
56
|
beforeDraw(context: any, store: any, params: any): void;
|
|
56
57
|
/**
|
|
57
58
|
* Draws the component for the popup.
|
|
@@ -74,7 +75,6 @@ export default class Popup extends WJElement {
|
|
|
74
75
|
anchorEl: any;
|
|
75
76
|
manualCallback: (e: any) => void;
|
|
76
77
|
clickHandler: (e: any) => void;
|
|
77
|
-
get floatingEl(): HTMLDivElement;
|
|
78
78
|
/**
|
|
79
79
|
* Toggles the active attribute of the popup.
|
|
80
80
|
*/
|
|
@@ -95,6 +95,8 @@ export default class Popup extends WJElement {
|
|
|
95
95
|
*/
|
|
96
96
|
_mountContentToPortal(): void;
|
|
97
97
|
_portalNative: HTMLDivElement;
|
|
98
|
+
_portalSlot: HTMLSlotElement;
|
|
99
|
+
_portalArrowSlot: HTMLSlotElement;
|
|
98
100
|
_portalAttrObserver: MutationObserver;
|
|
99
101
|
_defPlaceholders: any[];
|
|
100
102
|
_arrowPlaceholders: any[];
|
|
@@ -1385,7 +1385,9 @@ class Popup extends WJElement {
|
|
|
1385
1385
|
this.showHide();
|
|
1386
1386
|
});
|
|
1387
1387
|
__publicField(this, "clickHandler", (e) => {
|
|
1388
|
-
const path = e.composedPath();
|
|
1388
|
+
const path = typeof e.composedPath === "function" ? e.composedPath() : [];
|
|
1389
|
+
const isMenuClick = path.some((n) => n && (n.tagName === "WJE-MENU-ITEM" || n.tagName === "WJE-MENU" || n.tagName === "WJE-DROPDOWN"));
|
|
1390
|
+
if (isMenuClick) return;
|
|
1389
1391
|
const inside = path.includes(this) || this.floatingEl && path.includes(this.floatingEl);
|
|
1390
1392
|
if (!inside && this.hasAttribute("active")) this.hide(true);
|
|
1391
1393
|
});
|
|
@@ -1442,6 +1444,9 @@ class Popup extends WJElement {
|
|
|
1442
1444
|
get portal() {
|
|
1443
1445
|
return this.hasAttribute("portal");
|
|
1444
1446
|
}
|
|
1447
|
+
get floatingEl() {
|
|
1448
|
+
return this._floatingEl || this.native;
|
|
1449
|
+
}
|
|
1445
1450
|
/**
|
|
1446
1451
|
* Returns the CSS styles for the component.
|
|
1447
1452
|
* @static
|
|
@@ -1530,9 +1535,6 @@ class Popup extends WJElement {
|
|
|
1530
1535
|
event.addListener(this.anchorEl, "click", null, this.manualCallback, { stopPropagation: true });
|
|
1531
1536
|
}
|
|
1532
1537
|
}
|
|
1533
|
-
get floatingEl() {
|
|
1534
|
-
return this._floatingEl || this.native;
|
|
1535
|
-
}
|
|
1536
1538
|
/**
|
|
1537
1539
|
* Toggles the active attribute of the popup.
|
|
1538
1540
|
*/
|
|
@@ -1625,6 +1627,10 @@ class Popup extends WJElement {
|
|
|
1625
1627
|
this._portalNative = document.createElement("div");
|
|
1626
1628
|
this._portalNative.setAttribute("part", "native");
|
|
1627
1629
|
this._portalNative.classList.add("native-popup");
|
|
1630
|
+
this._portalSlot = document.createElement("slot");
|
|
1631
|
+
this._portalArrowSlot = document.createElement("slot");
|
|
1632
|
+
this._portalArrowSlot.setAttribute("name", "arrow");
|
|
1633
|
+
this._portalNative.append(this._portalSlot, this._portalArrowSlot);
|
|
1628
1634
|
}
|
|
1629
1635
|
this._portalShadow.append(this._portalNative);
|
|
1630
1636
|
const mirrorAll = () => {
|
|
@@ -1655,7 +1661,7 @@ class Popup extends WJElement {
|
|
|
1655
1661
|
const ph = document.createComment("wje-portal-default");
|
|
1656
1662
|
this._defPlaceholders.push({ node: n, ph });
|
|
1657
1663
|
n.parentNode && n.parentNode.insertBefore(ph, n.nextSibling);
|
|
1658
|
-
this.
|
|
1664
|
+
this._portalContainer.append(n);
|
|
1659
1665
|
}
|
|
1660
1666
|
const arrowNodes = (this.slotArrow instanceof HTMLSlotElement ? this.slotArrow.assignedNodes({ flatten: true }) : []).filter((n) => n && n.nodeType === Node.ELEMENT_NODE || n && n.nodeType === Node.TEXT_NODE);
|
|
1661
1667
|
this._arrowPlaceholders = [];
|
|
@@ -1663,10 +1669,15 @@ class Popup extends WJElement {
|
|
|
1663
1669
|
const ph = document.createComment("wje-portal-arrow");
|
|
1664
1670
|
this._arrowPlaceholders.push({ node: n, ph });
|
|
1665
1671
|
n.parentNode && n.parentNode.insertBefore(ph, n.nextSibling);
|
|
1666
|
-
this.
|
|
1672
|
+
this._portalContainer.append(n);
|
|
1667
1673
|
}
|
|
1668
1674
|
this._floatingEl = this._portalNative;
|
|
1669
1675
|
this._portaled = true;
|
|
1676
|
+
this._floatingEl = this._portalNative;
|
|
1677
|
+
this._portaled = true;
|
|
1678
|
+
console.log("Portal mount 1", { root: this._portalShadow, container: this._portalContainer, floating: this._portalNative });
|
|
1679
|
+
event.dispatchCustomEvent(this, "wje-router:rebind", { root: this._portalShadow, container: this._portalContainer, floating: this._portalNative });
|
|
1680
|
+
console.log("Portal mount 2", { root: this._portalShadow, container: this._portalContainer, floating: this._portalNative });
|
|
1670
1681
|
}
|
|
1671
1682
|
/**
|
|
1672
1683
|
* Restores the content previously moved to a portal back to its original location.
|
|
@@ -1709,6 +1720,15 @@ class Popup extends WJElement {
|
|
|
1709
1720
|
this._portalContainer = null;
|
|
1710
1721
|
this._portalShadow = null;
|
|
1711
1722
|
}
|
|
1723
|
+
const detail = { root: this.shadowRoot, container: this, floating: this.native };
|
|
1724
|
+
this.dispatchEvent(new CustomEvent("wje-portal:restored", { bubbles: true, composed: true, detail }));
|
|
1725
|
+
try {
|
|
1726
|
+
if (typeof window.bindRouterLinks === "function") {
|
|
1727
|
+
window.bindRouterLinks(this.shadowRoot);
|
|
1728
|
+
}
|
|
1729
|
+
document.dispatchEvent(new CustomEvent("wje-router:rebind", { bubbles: true, composed: true, detail }));
|
|
1730
|
+
} catch {
|
|
1731
|
+
}
|
|
1712
1732
|
}
|
|
1713
1733
|
/**
|
|
1714
1734
|
* Ensures that a portal root is created and initialized properly with a shadow DOM and attached styles.
|
|
@@ -1764,6 +1784,13 @@ class Popup extends WJElement {
|
|
|
1764
1784
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1765
1785
|
if (this.portal) {
|
|
1766
1786
|
this._mountContentToPortal();
|
|
1787
|
+
if (this.portal && this._portalShadow) {
|
|
1788
|
+
const detail = { root: this._portalShadow, container: this._portalContainer, floating: this._portalNative };
|
|
1789
|
+
document.dispatchEvent(new CustomEvent("wje-router:rebind", { bubbles: true, composed: true, detail }));
|
|
1790
|
+
if (typeof window.bindRouterLinks === "function") {
|
|
1791
|
+
window.bindRouterLinks(this._portalShadow);
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1767
1794
|
}
|
|
1768
1795
|
if (this.loader) {
|
|
1769
1796
|
(_b = (_a = this.floatingEl) == null ? void 0 : _a.classList) == null ? void 0 : _b.add("loading");
|
|
@@ -1799,7 +1826,9 @@ class Popup extends WJElement {
|
|
|
1799
1826
|
(_c = this.cleanup) == null ? void 0 : _c.call(this);
|
|
1800
1827
|
this.cleanup = void 0;
|
|
1801
1828
|
document.removeEventListener("click", this.clickHandler, { capture: true });
|
|
1802
|
-
this.
|
|
1829
|
+
if (this.portal && this._portaled) {
|
|
1830
|
+
this._restoreContentFromPortal();
|
|
1831
|
+
}
|
|
1803
1832
|
if (this.hasAttribute("active")) {
|
|
1804
1833
|
this.removeAttribute("active");
|
|
1805
1834
|
}
|
|
@@ -1819,4 +1848,4 @@ class Popup extends WJElement {
|
|
|
1819
1848
|
export {
|
|
1820
1849
|
Popup as P
|
|
1821
1850
|
};
|
|
1822
|
-
//# sourceMappingURL=popup.element-
|
|
1851
|
+
//# sourceMappingURL=popup.element-C_eXD5J4.js.map
|