wj-elements 0.6.0 → 0.7.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/packages/wje-breadcrumbs/breadcrumbs.element.d.ts +1 -1
- package/dist/packages/wje-dropdown/dropdown.element.d.ts +18 -0
- package/dist/packages/wje-orgchart/orgchart.element.d.ts +15 -0
- package/dist/packages/wje-orgchart-item/orgchart-item.element.d.ts +3 -1
- package/dist/packages/wje-popup/popup.element.d.ts +48 -1
- package/dist/packages/wje-sliding-container/sliding-container.element.d.ts +360 -3
- package/dist/packages/wje-toolbar-action/toolbar-action.element.d.ts +11 -0
- package/dist/{popup.element-C8-g3WLs.js → popup.element-CwXvVFK7.js} +275 -43
- package/dist/popup.element-CwXvVFK7.js.map +1 -0
- package/dist/styles.css +0 -38
- package/dist/wje-animation.js +1 -1
- package/dist/wje-breadcrumbs.js +4 -0
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-dropdown.js +28 -4
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-master.js +1 -1
- package/dist/wje-orgchart-group.js +1 -1
- package/dist/wje-orgchart-item.js +13 -4
- package/dist/wje-orgchart-item.js.map +1 -1
- package/dist/wje-orgchart.js +27 -0
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/wje-select.js +28 -5
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-sliding-container.js +865 -14
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-toolbar-action.js +25 -1
- package/dist/wje-toolbar-action.js.map +1 -1
- package/dist/wje-toolbar.js +1 -1
- package/dist/wje-tooltip.js +1 -1
- package/package.json +2 -1
- package/dist/popup.element-C8-g3WLs.js.map +0 -1
|
@@ -1404,7 +1404,8 @@ const computePosition = (reference, floating, options) => {
|
|
|
1404
1404
|
platform: platformWithCache
|
|
1405
1405
|
});
|
|
1406
1406
|
};
|
|
1407
|
-
const styles = "/*\n[ WJ Popup ]\n*/\n\n:host {\n --wje-popup-top: auto;\n --wje-popup-left: auto;\n\n display: flex; /* zmenene z contents na flex kvoli breadcrumbs v a jeho trom bodkam */\n}\n\n.native-popup {\n position: absolute;\n isolation: isolate;\n z-index: 999;\n left: var(--wje-popup-left);\n top: var(--wje-popup-top);\n}\n.native-popup:not(.popup-active) {\n display: none;\n}\n\n.popup-loader.overlay {\n position: absolute;\n inset:
|
|
1407
|
+
const styles = "/*\n[ WJ Popup ]\n*/\n\n:host {\n --wje-popup-top: auto;\n --wje-popup-left: auto;\n --wje-popup-mobile-transition-duration: 250ms;\n --wje-popup-mobile-transition-easing: ease;\n\n display: flex; /* zmenene z contents na flex kvoli breadcrumbs v a jeho trom bodkam */\n}\n\n.popup-backdrop {\n display: none;\n}\n\n.native-popup {\n position: absolute;\n isolation: isolate;\n z-index: 999;\n left: var(--wje-popup-left);\n top: var(--wje-popup-top);\n}\n.native-popup:not(.popup-active) {\n display: none;\n}\n\n.popup-backdrop.popup-mobile-sheet {\n display: block;\n position: fixed;\n inset: 0;\n z-index: 998;\n opacity: 0;\n pointer-events: none;\n background: var(\n --wje-popup-backdrop-background,\n var(--wje-sliding-container-backdrop-background, var(--wje-backdrop, rgba(0, 0, 0, 0.35)))\n );\n transition:\n opacity var(--wje-popup-mobile-transition-duration) var(--wje-popup-mobile-transition-easing),\n visibility 0s linear var(--wje-popup-mobile-transition-duration);\n visibility: hidden;\n}\n\n.popup-backdrop.popup-mobile-sheet.popup-active {\n opacity: var(\n --wje-popup-backdrop-opacity,\n var(--wje-sliding-container-backdrop-opacity, var(--wje-backdrop-opacity, 1))\n );\n pointer-events: auto;\n visibility: visible;\n transition-delay: 0s;\n}\n\n.native-popup.popup-mobile-sheet {\n display: flex;\n flex-direction: column;\n align-items: stretch;\n position: fixed;\n inset: auto 0 0 0;\n left: 0;\n right: 0;\n top: auto;\n width: 100vw;\n max-width: 100vw;\n max-height: var(--wje-popup-mobile-max-height, 90vh);\n overflow: auto;\n background: var(\n --wje-popup-mobile-background,\n var(--wje-select-options-background-color, var(--wje-color-contrast-0, #fff))\n );\n box-shadow: var(--wje-popup-mobile-box-shadow, 0 -8px 32px rgba(0, 0, 0, 0.16));\n border-radius: var(\n --wje-popup-mobile-border-radius,\n var(\n --wje-sliding-container-sheet-border-radius,\n var(--wje-border-radius-large, 16px) var(--wje-border-radius-large, 16px) 0 0\n )\n );\n padding-bottom: env(safe-area-inset-bottom, 0);\n transform: translateY(100%);\n transition:\n transform var(--wje-popup-mobile-transition-duration) var(--wje-popup-mobile-transition-easing),\n visibility 0s linear var(--wje-popup-mobile-transition-duration);\n visibility: hidden;\n pointer-events: none;\n}\n\n.native-popup.popup-mobile-sheet.popup-active {\n transform: translateY(0);\n visibility: visible;\n pointer-events: auto;\n transition-delay: 0s;\n}\n\n.popup-loader.overlay {\n position: absolute;\n inset: var(--wje-popup-loader-inset, 0);\n background: var(\n --wje-popup-overlay-background,\n var(--wje-select-options-background-color, var(--wje-color-contrast-0, #fff))\n );\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 1;\n}\n.popup-loader.fade-out {\n opacity: 0;\n transition: opacity 0.3s ease;\n pointer-events: none;\n}\n";
|
|
1408
|
+
const POPUP_MOBILE_SHEET_TRANSITION_FALLBACK_MS = 250;
|
|
1408
1409
|
class Popup extends WJElement {
|
|
1409
1410
|
/**
|
|
1410
1411
|
* Creates an instance of Popup.
|
|
@@ -1419,11 +1420,25 @@ class Popup extends WJElement {
|
|
|
1419
1420
|
});
|
|
1420
1421
|
__publicField(this, "clickHandler", (e) => {
|
|
1421
1422
|
const path = typeof e.composedPath === "function" ? e.composedPath() : [];
|
|
1422
|
-
const isMenuClick = path.some(
|
|
1423
|
+
const isMenuClick = path.some(
|
|
1424
|
+
(n) => n && (n.tagName === "WJE-MENU-ITEM" || n.tagName === "WJE-MENU")
|
|
1425
|
+
// ||
|
|
1426
|
+
// n.tagName === 'WJE-DROPDOWNs'
|
|
1427
|
+
);
|
|
1423
1428
|
if (isMenuClick) return;
|
|
1424
1429
|
const inside = path.includes(this) || this.floatingEl && path.includes(this.floatingEl);
|
|
1425
1430
|
if (!inside && this.hasAttribute("active")) this.hide(true);
|
|
1426
1431
|
});
|
|
1432
|
+
__publicField(this, "handleBackdropClick", (e) => {
|
|
1433
|
+
var _a;
|
|
1434
|
+
if (!this.hasAttribute("active") || !((_a = this.floatingEl) == null ? void 0 : _a.classList.contains("popup-mobile-sheet"))) return;
|
|
1435
|
+
e.stopPropagation();
|
|
1436
|
+
this.hide(true);
|
|
1437
|
+
});
|
|
1438
|
+
__publicField(this, "handleViewportResize", () => {
|
|
1439
|
+
if (!this.mobilePresentation || !this.hasAttribute("active")) return;
|
|
1440
|
+
this.syncResponsivePresentation();
|
|
1441
|
+
});
|
|
1427
1442
|
/**
|
|
1428
1443
|
* Removes the active attribute when the popup is hidden.
|
|
1429
1444
|
*/
|
|
@@ -1431,17 +1446,28 @@ class Popup extends WJElement {
|
|
|
1431
1446
|
this.removeAttribute("active");
|
|
1432
1447
|
});
|
|
1433
1448
|
this._manual = false;
|
|
1449
|
+
this._contentAwareSize = false;
|
|
1450
|
+
this._contentReadyHandler = () => this.markContentReady();
|
|
1451
|
+
this._bottomSheetRestoreTimeout = null;
|
|
1434
1452
|
}
|
|
1435
1453
|
set loader(value) {
|
|
1436
1454
|
if (value) {
|
|
1437
1455
|
this.setAttribute("loader", "");
|
|
1456
|
+
this._showLoader();
|
|
1438
1457
|
} else {
|
|
1439
1458
|
this.removeAttribute("loader");
|
|
1459
|
+
this._hideLoader();
|
|
1440
1460
|
}
|
|
1441
1461
|
}
|
|
1442
1462
|
get loader() {
|
|
1443
1463
|
return this.hasAttribute("loader");
|
|
1444
1464
|
}
|
|
1465
|
+
set contentAwareSize(value) {
|
|
1466
|
+
this._contentAwareSize = Boolean(value);
|
|
1467
|
+
}
|
|
1468
|
+
get contentAwareSize() {
|
|
1469
|
+
return this._contentAwareSize === true;
|
|
1470
|
+
}
|
|
1445
1471
|
/**
|
|
1446
1472
|
* Sets the manual property of the popup.
|
|
1447
1473
|
* @param {boolean} value The value to set.
|
|
@@ -1477,9 +1503,26 @@ class Popup extends WJElement {
|
|
|
1477
1503
|
get portal() {
|
|
1478
1504
|
return this.hasAttribute("portal");
|
|
1479
1505
|
}
|
|
1506
|
+
set mobilePresentation(value) {
|
|
1507
|
+
if (value) this.setAttribute("mobile-presentation", value);
|
|
1508
|
+
else this.removeAttribute("mobile-presentation");
|
|
1509
|
+
}
|
|
1510
|
+
get mobilePresentation() {
|
|
1511
|
+
return this.getAttribute("mobile-presentation");
|
|
1512
|
+
}
|
|
1513
|
+
set mobileBreakPoint(value) {
|
|
1514
|
+
if (value) this.setAttribute("mobile-break-point", value);
|
|
1515
|
+
else this.removeAttribute("mobile-break-point");
|
|
1516
|
+
}
|
|
1517
|
+
get mobileBreakPoint() {
|
|
1518
|
+
return this.getAttribute("mobile-break-point") || "768";
|
|
1519
|
+
}
|
|
1480
1520
|
get floatingEl() {
|
|
1481
1521
|
return this._floatingEl || this.native;
|
|
1482
1522
|
}
|
|
1523
|
+
get backdropEl() {
|
|
1524
|
+
return this._portaled ? this._portalBackdrop : this.backdrop;
|
|
1525
|
+
}
|
|
1483
1526
|
/**
|
|
1484
1527
|
* Returns the CSS styles for the component.
|
|
1485
1528
|
* @static
|
|
@@ -1501,13 +1544,42 @@ class Popup extends WJElement {
|
|
|
1501
1544
|
*/
|
|
1502
1545
|
setupAttributes() {
|
|
1503
1546
|
this.isShadowRoot = "open";
|
|
1547
|
+
this._hideFloatingLightDomContentBeforeRender();
|
|
1548
|
+
}
|
|
1549
|
+
_hideFloatingLightDomContentBeforeRender() {
|
|
1550
|
+
if (this._hiddenFloatingLightDomContent) return;
|
|
1551
|
+
const floatingChildren = Array.from(this.children).filter((el) => el.getAttribute("slot") !== "anchor");
|
|
1552
|
+
if (floatingChildren.length === 0) return;
|
|
1553
|
+
this._hiddenFloatingLightDomContent = floatingChildren.map((el) => {
|
|
1554
|
+
const display = el.style.getPropertyValue("display");
|
|
1555
|
+
const priority = el.style.getPropertyPriority("display");
|
|
1556
|
+
el.style.setProperty("display", "none");
|
|
1557
|
+
return { el, display, priority };
|
|
1558
|
+
});
|
|
1504
1559
|
}
|
|
1505
|
-
|
|
1560
|
+
_restoreFloatingLightDomContentAfterRender() {
|
|
1506
1561
|
var _a;
|
|
1562
|
+
(_a = this._hiddenFloatingLightDomContent) == null ? void 0 : _a.forEach(({ el, display, priority }) => {
|
|
1563
|
+
if (display) {
|
|
1564
|
+
el.style.setProperty("display", display, priority);
|
|
1565
|
+
} else {
|
|
1566
|
+
el.style.removeProperty("display");
|
|
1567
|
+
}
|
|
1568
|
+
});
|
|
1569
|
+
this._hiddenFloatingLightDomContent = null;
|
|
1570
|
+
}
|
|
1571
|
+
afterDisconnect() {
|
|
1572
|
+
var _a, _b, _c;
|
|
1573
|
+
this.clearBottomSheetRestoreTimeout();
|
|
1574
|
+
window.removeEventListener("resize", this.handleViewportResize);
|
|
1507
1575
|
event.removeListener(this.anchorEl, "click", this.manualCallback);
|
|
1508
1576
|
document.removeEventListener("click", this.clickHandler, { capture: true });
|
|
1577
|
+
this.removeEventListener("wje-popup:content-ready", this._contentReadyHandler);
|
|
1578
|
+
this._contentReadyListenerAttached = false;
|
|
1579
|
+
(_a = this.backdrop) == null ? void 0 : _a.removeEventListener("click", this.handleBackdropClick);
|
|
1580
|
+
(_b = this._portalBackdrop) == null ? void 0 : _b.removeEventListener("click", this.handleBackdropClick);
|
|
1509
1581
|
this._restoreContentFromPortal();
|
|
1510
|
-
(
|
|
1582
|
+
(_c = this.cleanup) == null ? void 0 : _c.call(this);
|
|
1511
1583
|
}
|
|
1512
1584
|
beforeDraw(context, store, params) {
|
|
1513
1585
|
var _a;
|
|
@@ -1523,6 +1595,10 @@ class Popup extends WJElement {
|
|
|
1523
1595
|
slotAnchor.setAttribute("name", "anchor");
|
|
1524
1596
|
let slotArrow = document.createElement("slot");
|
|
1525
1597
|
slotArrow.setAttribute("name", "arrow");
|
|
1598
|
+
let backdrop = document.createElement("div");
|
|
1599
|
+
backdrop.setAttribute("part", "backdrop");
|
|
1600
|
+
backdrop.classList.add("popup-backdrop");
|
|
1601
|
+
backdrop.addEventListener("click", this.handleBackdropClick);
|
|
1526
1602
|
let native = document.createElement("div");
|
|
1527
1603
|
native.setAttribute("part", "native");
|
|
1528
1604
|
native.classList.add("native-popup");
|
|
@@ -1535,9 +1611,12 @@ class Popup extends WJElement {
|
|
|
1535
1611
|
native.append(slot);
|
|
1536
1612
|
native.append(slotArrow);
|
|
1537
1613
|
fragment.append(slotAnchor);
|
|
1614
|
+
fragment.append(backdrop);
|
|
1538
1615
|
fragment.append(native);
|
|
1539
1616
|
this.slotAnchor = slotAnchor;
|
|
1540
1617
|
this.slotArrow = slotArrow;
|
|
1618
|
+
this.defaultSlot = slot;
|
|
1619
|
+
this.backdrop = backdrop;
|
|
1541
1620
|
this.native = native;
|
|
1542
1621
|
this.loaderEl = loader;
|
|
1543
1622
|
return fragment;
|
|
@@ -1546,10 +1625,14 @@ class Popup extends WJElement {
|
|
|
1546
1625
|
* After Draws the component.
|
|
1547
1626
|
*/
|
|
1548
1627
|
afterDraw() {
|
|
1628
|
+
this._restoreFloatingLightDomContentAfterRender();
|
|
1549
1629
|
this.setAnchor();
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1630
|
+
window.removeEventListener("resize", this.handleViewportResize);
|
|
1631
|
+
window.addEventListener("resize", this.handleViewportResize);
|
|
1632
|
+
if (!this._contentReadyListenerAttached) {
|
|
1633
|
+
this.addEventListener("wje-popup:content-ready", this._contentReadyHandler);
|
|
1634
|
+
this._contentReadyListenerAttached = true;
|
|
1635
|
+
}
|
|
1553
1636
|
if (this.hasAttribute("active")) this.show(false);
|
|
1554
1637
|
if (!this.hasAttribute("active")) this.hide(false);
|
|
1555
1638
|
}
|
|
@@ -1568,6 +1651,101 @@ class Popup extends WJElement {
|
|
|
1568
1651
|
event.addListener(this.anchorEl, "click", null, this.manualCallback, { stopPropagation: true });
|
|
1569
1652
|
}
|
|
1570
1653
|
}
|
|
1654
|
+
clearBottomSheetRestoreTimeout() {
|
|
1655
|
+
if (this._bottomSheetRestoreTimeout === null) return;
|
|
1656
|
+
window.clearTimeout(this._bottomSheetRestoreTimeout);
|
|
1657
|
+
this._bottomSheetRestoreTimeout = null;
|
|
1658
|
+
}
|
|
1659
|
+
isBottomSheetActive() {
|
|
1660
|
+
return this.mobilePresentation === "bottom-sheet" && window.innerWidth <= +this.mobileBreakPoint;
|
|
1661
|
+
}
|
|
1662
|
+
setBottomSheetState(isActive) {
|
|
1663
|
+
const native = this.floatingEl;
|
|
1664
|
+
const backdrop = this.backdropEl;
|
|
1665
|
+
if (!native || !backdrop) return;
|
|
1666
|
+
native.classList.add("popup-mobile-sheet");
|
|
1667
|
+
backdrop.classList.add("popup-mobile-sheet");
|
|
1668
|
+
native.classList.toggle("popup-active", isActive);
|
|
1669
|
+
backdrop.classList.toggle("popup-active", isActive);
|
|
1670
|
+
}
|
|
1671
|
+
clearBottomSheetState() {
|
|
1672
|
+
[this.native, this.backdrop, this._portalNative, this._portalBackdrop].forEach((el) => {
|
|
1673
|
+
el == null ? void 0 : el.classList.remove("popup-mobile-sheet", "popup-active");
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
rebindPortaledRouter() {
|
|
1677
|
+
if (!this._portalShadow) return;
|
|
1678
|
+
const detail = {
|
|
1679
|
+
root: this._portalShadow,
|
|
1680
|
+
container: this._portalContainer,
|
|
1681
|
+
floating: this._portalNative
|
|
1682
|
+
};
|
|
1683
|
+
document.dispatchEvent(new CustomEvent("wje-router:rebind", { bubbles: true, composed: true, detail }));
|
|
1684
|
+
if (typeof window.bindRouterLinks === "function") {
|
|
1685
|
+
window.bindRouterLinks(this._portalShadow);
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
syncResponsivePresentation() {
|
|
1689
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1690
|
+
const shouldUseBottomSheet = this.isBottomSheetActive();
|
|
1691
|
+
const isUsingBottomSheet = (_b = (_a = this.floatingEl) == null ? void 0 : _a.classList) == null ? void 0 : _b.contains("popup-mobile-sheet");
|
|
1692
|
+
if (shouldUseBottomSheet) {
|
|
1693
|
+
(_c = this.cleanup) == null ? void 0 : _c.call(this);
|
|
1694
|
+
this.cleanup = void 0;
|
|
1695
|
+
if (!this._portaled) {
|
|
1696
|
+
this._mountContentToPortal();
|
|
1697
|
+
this.rebindPortaledRouter();
|
|
1698
|
+
}
|
|
1699
|
+
this.setBottomSheetState(false);
|
|
1700
|
+
(_d = this.floatingEl) == null ? void 0 : _d.getBoundingClientRect();
|
|
1701
|
+
(_e = this.backdropEl) == null ? void 0 : _e.getBoundingClientRect();
|
|
1702
|
+
requestAnimationFrame(() => {
|
|
1703
|
+
if (!this.hasAttribute("active") || !this.isBottomSheetActive()) return;
|
|
1704
|
+
this.setBottomSheetState(true);
|
|
1705
|
+
});
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
if (isUsingBottomSheet) {
|
|
1709
|
+
this.clearBottomSheetRestoreTimeout();
|
|
1710
|
+
this.clearBottomSheetState();
|
|
1711
|
+
if (!this.portal && this._portaled) {
|
|
1712
|
+
this._restoreContentFromPortal();
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
if (this.anchorEl && this.floatingEl) {
|
|
1716
|
+
this.floatingEl.classList.add("popup-active");
|
|
1717
|
+
(_f = this.cleanup) == null ? void 0 : _f.call(this);
|
|
1718
|
+
this.cleanup = autoUpdate(this.anchorEl, this.floatingEl, () => {
|
|
1719
|
+
this.reposition();
|
|
1720
|
+
});
|
|
1721
|
+
this.reposition();
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
getBottomSheetTransitionDurationMs() {
|
|
1725
|
+
const parseDuration = (value) => {
|
|
1726
|
+
const trimmedValue = value == null ? void 0 : value.trim();
|
|
1727
|
+
if (!trimmedValue) return 0;
|
|
1728
|
+
if (trimmedValue.endsWith("ms")) return Number.parseFloat(trimmedValue) || 0;
|
|
1729
|
+
if (trimmedValue.endsWith("s")) return (Number.parseFloat(trimmedValue) || 0) * 1e3;
|
|
1730
|
+
return Number.parseFloat(trimmedValue) || 0;
|
|
1731
|
+
};
|
|
1732
|
+
const getMaxDuration = (el) => {
|
|
1733
|
+
if (!el) return 0;
|
|
1734
|
+
const computedStyles = getComputedStyle(el);
|
|
1735
|
+
const durations = computedStyles.transitionDuration.split(",");
|
|
1736
|
+
const delays = computedStyles.transitionDelay.split(",");
|
|
1737
|
+
const count = Math.max(durations.length, delays.length);
|
|
1738
|
+
let maxDuration = 0;
|
|
1739
|
+
for (let i = 0; i < count; i++) {
|
|
1740
|
+
const duration = parseDuration(durations[i] || durations[durations.length - 1]);
|
|
1741
|
+
const delay = parseDuration(delays[i] || delays[delays.length - 1]);
|
|
1742
|
+
maxDuration = Math.max(maxDuration, duration + delay);
|
|
1743
|
+
}
|
|
1744
|
+
return maxDuration;
|
|
1745
|
+
};
|
|
1746
|
+
const transitionDuration = Math.max(getMaxDuration(this.floatingEl), getMaxDuration(this.backdropEl));
|
|
1747
|
+
return transitionDuration || POPUP_MOBILE_SHEET_TRANSITION_FALLBACK_MS;
|
|
1748
|
+
}
|
|
1571
1749
|
/**
|
|
1572
1750
|
* Toggles the active attribute of the popup.
|
|
1573
1751
|
*/
|
|
@@ -1585,6 +1763,8 @@ class Popup extends WJElement {
|
|
|
1585
1763
|
* Uses the floating-ui library to compute the position.
|
|
1586
1764
|
*/
|
|
1587
1765
|
reposition() {
|
|
1766
|
+
var _a, _b;
|
|
1767
|
+
if ((_b = (_a = this.floatingEl) == null ? void 0 : _a.classList) == null ? void 0 : _b.contains("popup-mobile-sheet")) return;
|
|
1588
1768
|
const middleware = [];
|
|
1589
1769
|
this.offsetCalc = +this.offset || 0;
|
|
1590
1770
|
if (this.portal && this._portaled && this.floatingEl) {
|
|
@@ -1605,8 +1785,16 @@ class Popup extends WJElement {
|
|
|
1605
1785
|
if (this.hasAttribute("size")) {
|
|
1606
1786
|
middleware.push(
|
|
1607
1787
|
size({
|
|
1608
|
-
apply({
|
|
1788
|
+
apply: ({ elements }) => {
|
|
1789
|
+
if (this.contentAwareSize) {
|
|
1790
|
+
Object.assign(elements.floating.style, {
|
|
1791
|
+
minWidth: `${elements.reference.offsetWidth}px`,
|
|
1792
|
+
width: ""
|
|
1793
|
+
});
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1609
1796
|
Object.assign(elements.floating.style, {
|
|
1797
|
+
minWidth: "",
|
|
1610
1798
|
width: `${elements.reference.offsetWidth}px`
|
|
1611
1799
|
});
|
|
1612
1800
|
}
|
|
@@ -1657,6 +1845,10 @@ class Popup extends WJElement {
|
|
|
1657
1845
|
if (this._portaled) return;
|
|
1658
1846
|
this._ensurePortalRoot();
|
|
1659
1847
|
if (!this._portalNative) {
|
|
1848
|
+
this._portalBackdrop = document.createElement("div");
|
|
1849
|
+
this._portalBackdrop.setAttribute("part", "backdrop");
|
|
1850
|
+
this._portalBackdrop.classList.add("popup-backdrop");
|
|
1851
|
+
this._portalBackdrop.addEventListener("click", this.handleBackdropClick);
|
|
1660
1852
|
this._portalNative = document.createElement("div");
|
|
1661
1853
|
this._portalNative.setAttribute("part", "native");
|
|
1662
1854
|
this._portalNative.classList.add("native-popup");
|
|
@@ -1665,9 +1857,11 @@ class Popup extends WJElement {
|
|
|
1665
1857
|
this._portalArrowSlot.setAttribute("name", "arrow");
|
|
1666
1858
|
this._portalNative.append(this._portalSlot, this._portalArrowSlot);
|
|
1667
1859
|
}
|
|
1860
|
+
this._portalShadow.append(this._portalBackdrop);
|
|
1668
1861
|
this._portalShadow.append(this._portalNative);
|
|
1669
1862
|
const mirrorAll = () => {
|
|
1670
1863
|
for (const { name } of Array.from(this._portalContainer.attributes)) {
|
|
1864
|
+
if (name === "data-wje-popup-portal") continue;
|
|
1671
1865
|
this._portalContainer.removeAttribute(name);
|
|
1672
1866
|
}
|
|
1673
1867
|
for (const attr of Array.from(this.attributes)) {
|
|
@@ -1687,8 +1881,10 @@ class Popup extends WJElement {
|
|
|
1687
1881
|
}
|
|
1688
1882
|
});
|
|
1689
1883
|
this._portalAttrObserver.observe(this, { attributes: true });
|
|
1690
|
-
const defaultSlot = this.
|
|
1691
|
-
const defNodes = (defaultSlot ? defaultSlot.assignedNodes({ flatten: true }) : []).filter(
|
|
1884
|
+
const defaultSlot = this.defaultSlot;
|
|
1885
|
+
const defNodes = (defaultSlot ? defaultSlot.assignedNodes({ flatten: true }) : []).filter(
|
|
1886
|
+
(n) => n && n.nodeType === Node.ELEMENT_NODE || n && n.nodeType === Node.TEXT_NODE
|
|
1887
|
+
);
|
|
1692
1888
|
this._defPlaceholders = [];
|
|
1693
1889
|
for (const n of defNodes) {
|
|
1694
1890
|
const ph = document.createComment("wje-portal-default");
|
|
@@ -1708,7 +1904,11 @@ class Popup extends WJElement {
|
|
|
1708
1904
|
this._portaled = true;
|
|
1709
1905
|
this._floatingEl = this._portalNative;
|
|
1710
1906
|
this._portaled = true;
|
|
1711
|
-
event.dispatchCustomEvent(this, "wje-router:rebind", {
|
|
1907
|
+
event.dispatchCustomEvent(this, "wje-router:rebind", {
|
|
1908
|
+
root: this._portalShadow,
|
|
1909
|
+
container: this._portalContainer,
|
|
1910
|
+
floating: this._portalNative
|
|
1911
|
+
});
|
|
1712
1912
|
}
|
|
1713
1913
|
/**
|
|
1714
1914
|
* Restores the content previously moved to a portal back to its original location.
|
|
@@ -1744,6 +1944,9 @@ class Popup extends WJElement {
|
|
|
1744
1944
|
if (this._portalNative && this._portalNative.parentNode) {
|
|
1745
1945
|
this._portalNative.remove();
|
|
1746
1946
|
}
|
|
1947
|
+
if (this._portalBackdrop && this._portalBackdrop.parentNode) {
|
|
1948
|
+
this._portalBackdrop.remove();
|
|
1949
|
+
}
|
|
1747
1950
|
this._floatingEl = void 0;
|
|
1748
1951
|
this._portaled = false;
|
|
1749
1952
|
if (this._portalContainer) {
|
|
@@ -1801,9 +2004,9 @@ class Popup extends WJElement {
|
|
|
1801
2004
|
host.style.setProperty(prop, comp.getPropertyValue(prop));
|
|
1802
2005
|
}
|
|
1803
2006
|
}
|
|
1804
|
-
if (this.getAttribute("portal") === "dialog") {
|
|
2007
|
+
if (this.getAttribute("portal") === "dialog" || this.isBottomSheetActive() && this.findDialog(this)) {
|
|
1805
2008
|
const dialog = this.findDialog(this);
|
|
1806
|
-
if (
|
|
2009
|
+
if (dialog) {
|
|
1807
2010
|
dialog.append(host);
|
|
1808
2011
|
} else {
|
|
1809
2012
|
document.body.append(host);
|
|
@@ -1830,29 +2033,32 @@ class Popup extends WJElement {
|
|
|
1830
2033
|
* @returns {void} Does not return any value.
|
|
1831
2034
|
*/
|
|
1832
2035
|
show(dispatchEvent = true) {
|
|
1833
|
-
var _a, _b, _c, _d, _e
|
|
2036
|
+
var _a, _b, _c, _d, _e;
|
|
2037
|
+
this.clearBottomSheetRestoreTimeout();
|
|
1834
2038
|
event.dispatchCustomEvent(document, "wje-popup:opened", { popup: this });
|
|
1835
|
-
if (this.portal) {
|
|
2039
|
+
if (this.portal || this.isBottomSheetActive()) {
|
|
1836
2040
|
this._mountContentToPortal();
|
|
1837
|
-
|
|
1838
|
-
const detail = { root: this._portalShadow, container: this._portalContainer, floating: this._portalNative };
|
|
1839
|
-
document.dispatchEvent(new CustomEvent("wje-router:rebind", { bubbles: true, composed: true, detail }));
|
|
1840
|
-
if (typeof window.bindRouterLinks === "function") {
|
|
1841
|
-
window.bindRouterLinks(this._portalShadow);
|
|
1842
|
-
}
|
|
1843
|
-
}
|
|
2041
|
+
this.rebindPortaledRouter();
|
|
1844
2042
|
}
|
|
1845
2043
|
if (this.loader) {
|
|
1846
|
-
|
|
1847
|
-
(_d = (_c = this.loaderEl) == null ? void 0 : _c.classList) == null ? void 0 : _d.remove("fade-out");
|
|
1848
|
-
(_e = this.floatingEl) == null ? void 0 : _e.prepend(this.loaderEl);
|
|
2044
|
+
this._showLoader();
|
|
1849
2045
|
}
|
|
1850
2046
|
if (dispatchEvent) {
|
|
1851
2047
|
event.dispatchCustomEvent(this, "wje-popup:show");
|
|
1852
2048
|
}
|
|
1853
|
-
if (this.
|
|
1854
|
-
|
|
1855
|
-
(
|
|
2049
|
+
if (this.isBottomSheetActive()) {
|
|
2050
|
+
this.setBottomSheetState(false);
|
|
2051
|
+
(_a = this.floatingEl) == null ? void 0 : _a.getBoundingClientRect();
|
|
2052
|
+
(_b = this.backdropEl) == null ? void 0 : _b.getBoundingClientRect();
|
|
2053
|
+
requestAnimationFrame(() => {
|
|
2054
|
+
if (!this.hasAttribute("active")) return;
|
|
2055
|
+
this.setBottomSheetState(true);
|
|
2056
|
+
});
|
|
2057
|
+
document.addEventListener("click", this.clickHandler, { capture: true });
|
|
2058
|
+
} else if (this.anchorEl && this.floatingEl) {
|
|
2059
|
+
this.clearBottomSheetState();
|
|
2060
|
+
(_d = (_c = this.floatingEl) == null ? void 0 : _c.classList) == null ? void 0 : _d.add("popup-active");
|
|
2061
|
+
(_e = this.cleanup) == null ? void 0 : _e.call(this);
|
|
1856
2062
|
this.cleanup = autoUpdate(this.anchorEl, this.floatingEl, () => {
|
|
1857
2063
|
this.reposition();
|
|
1858
2064
|
});
|
|
@@ -1868,34 +2074,60 @@ class Popup extends WJElement {
|
|
|
1868
2074
|
* Cleans up the auto update for repositioning.
|
|
1869
2075
|
*/
|
|
1870
2076
|
hide(dispatchEvent = true) {
|
|
1871
|
-
var _a, _b, _c;
|
|
2077
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1872
2078
|
if (dispatchEvent) {
|
|
1873
2079
|
event.dispatchCustomEvent(this, "wje-popup:hide");
|
|
1874
2080
|
}
|
|
1875
|
-
(
|
|
1876
|
-
(_c = this.cleanup) == null ? void 0 : _c.call(this);
|
|
2081
|
+
(_a = this.cleanup) == null ? void 0 : _a.call(this);
|
|
1877
2082
|
this.cleanup = void 0;
|
|
1878
2083
|
document.removeEventListener("click", this.clickHandler, { capture: true });
|
|
1879
|
-
|
|
1880
|
-
|
|
2084
|
+
const shouldAnimateBottomSheetClose = (_c = (_b = this.floatingEl) == null ? void 0 : _b.classList) == null ? void 0 : _c.contains("popup-mobile-sheet");
|
|
2085
|
+
if (shouldAnimateBottomSheetClose) {
|
|
2086
|
+
(_e = (_d = this.backdropEl) == null ? void 0 : _d.classList) == null ? void 0 : _e.remove("popup-active");
|
|
2087
|
+
(_g = (_f = this.floatingEl) == null ? void 0 : _f.classList) == null ? void 0 : _g.remove("popup-active");
|
|
2088
|
+
this.clearBottomSheetRestoreTimeout();
|
|
2089
|
+
this._bottomSheetRestoreTimeout = window.setTimeout(() => {
|
|
2090
|
+
this.clearBottomSheetState();
|
|
2091
|
+
if (this._portaled) {
|
|
2092
|
+
this._restoreContentFromPortal();
|
|
2093
|
+
}
|
|
2094
|
+
this._bottomSheetRestoreTimeout = null;
|
|
2095
|
+
}, this.getBottomSheetTransitionDurationMs());
|
|
2096
|
+
} else {
|
|
2097
|
+
(_i = (_h = this.floatingEl) == null ? void 0 : _h.classList) == null ? void 0 : _i.remove("popup-active");
|
|
2098
|
+
this.clearBottomSheetState();
|
|
2099
|
+
if (this._portaled) {
|
|
2100
|
+
this._restoreContentFromPortal();
|
|
2101
|
+
}
|
|
1881
2102
|
}
|
|
1882
2103
|
if (this.hasAttribute("active")) {
|
|
1883
2104
|
this.removeAttribute("active");
|
|
1884
2105
|
}
|
|
1885
2106
|
}
|
|
1886
|
-
|
|
1887
|
-
this.
|
|
1888
|
-
if (this.
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
this.loader = false;
|
|
1894
|
-
}, 300);
|
|
2107
|
+
_showLoader() {
|
|
2108
|
+
const floating = this.floatingEl;
|
|
2109
|
+
if (!(floating instanceof HTMLElement) || !(this.loaderEl instanceof HTMLElement)) return;
|
|
2110
|
+
floating.classList.add("loading");
|
|
2111
|
+
this.loaderEl.classList.remove("fade-out");
|
|
2112
|
+
if (this.loaderEl.parentElement !== floating) {
|
|
2113
|
+
floating.prepend(this.loaderEl);
|
|
1895
2114
|
}
|
|
1896
2115
|
}
|
|
2116
|
+
_hideLoader() {
|
|
2117
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2118
|
+
(_b = (_a = this.native) == null ? void 0 : _a.classList) == null ? void 0 : _b.remove("loading");
|
|
2119
|
+
(_d = (_c = this._portalNative) == null ? void 0 : _c.classList) == null ? void 0 : _d.remove("loading");
|
|
2120
|
+
(_f = (_e = this.floatingEl) == null ? void 0 : _e.classList) == null ? void 0 : _f.remove("loading");
|
|
2121
|
+
if (this.loaderEl instanceof HTMLElement) {
|
|
2122
|
+
this.loaderEl.classList.remove("fade-out");
|
|
2123
|
+
this.loaderEl.remove();
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
markContentReady() {
|
|
2127
|
+
this.loader = false;
|
|
2128
|
+
}
|
|
1897
2129
|
}
|
|
1898
2130
|
export {
|
|
1899
2131
|
Popup as P
|
|
1900
2132
|
};
|
|
1901
|
-
//# sourceMappingURL=popup.element-
|
|
2133
|
+
//# sourceMappingURL=popup.element-CwXvVFK7.js.map
|