wj-elements 0.1.222 → 0.1.224

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.
@@ -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
@@ -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
- _collapsible: boolean;
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[];
@@ -1444,6 +1444,9 @@ class Popup extends WJElement {
1444
1444
  get portal() {
1445
1445
  return this.hasAttribute("portal");
1446
1446
  }
1447
+ get floatingEl() {
1448
+ return this._floatingEl || this.native;
1449
+ }
1447
1450
  /**
1448
1451
  * Returns the CSS styles for the component.
1449
1452
  * @static
@@ -1532,9 +1535,6 @@ class Popup extends WJElement {
1532
1535
  event.addListener(this.anchorEl, "click", null, this.manualCallback, { stopPropagation: true });
1533
1536
  }
1534
1537
  }
1535
- get floatingEl() {
1536
- return this._floatingEl || this.native;
1537
- }
1538
1538
  /**
1539
1539
  * Toggles the active attribute of the popup.
1540
1540
  */
@@ -1627,6 +1627,10 @@ class Popup extends WJElement {
1627
1627
  this._portalNative = document.createElement("div");
1628
1628
  this._portalNative.setAttribute("part", "native");
1629
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);
1630
1634
  }
1631
1635
  this._portalShadow.append(this._portalNative);
1632
1636
  const mirrorAll = () => {
@@ -1657,7 +1661,7 @@ class Popup extends WJElement {
1657
1661
  const ph = document.createComment("wje-portal-default");
1658
1662
  this._defPlaceholders.push({ node: n, ph });
1659
1663
  n.parentNode && n.parentNode.insertBefore(ph, n.nextSibling);
1660
- this._portalNative.append(n);
1664
+ this._portalContainer.append(n);
1661
1665
  }
1662
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);
1663
1667
  this._arrowPlaceholders = [];
@@ -1665,10 +1669,15 @@ class Popup extends WJElement {
1665
1669
  const ph = document.createComment("wje-portal-arrow");
1666
1670
  this._arrowPlaceholders.push({ node: n, ph });
1667
1671
  n.parentNode && n.parentNode.insertBefore(ph, n.nextSibling);
1668
- this._portalNative.append(n);
1672
+ this._portalContainer.append(n);
1669
1673
  }
1670
1674
  this._floatingEl = this._portalNative;
1671
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 });
1672
1681
  }
1673
1682
  /**
1674
1683
  * Restores the content previously moved to a portal back to its original location.
@@ -1711,6 +1720,15 @@ class Popup extends WJElement {
1711
1720
  this._portalContainer = null;
1712
1721
  this._portalShadow = null;
1713
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
+ }
1714
1732
  }
1715
1733
  /**
1716
1734
  * Ensures that a portal root is created and initialized properly with a shadow DOM and attached styles.
@@ -1766,6 +1784,13 @@ class Popup extends WJElement {
1766
1784
  var _a, _b, _c, _d, _e, _f, _g, _h;
1767
1785
  if (this.portal) {
1768
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
+ }
1769
1794
  }
1770
1795
  if (this.loader) {
1771
1796
  (_b = (_a = this.floatingEl) == null ? void 0 : _a.classList) == null ? void 0 : _b.add("loading");
@@ -1823,4 +1848,4 @@ class Popup extends WJElement {
1823
1848
  export {
1824
1849
  Popup as P
1825
1850
  };
1826
- //# sourceMappingURL=popup.element-CfXgoyrm.js.map
1851
+ //# sourceMappingURL=popup.element-C_eXD5J4.js.map