release: WRNexusJS 0.5.10
This commit is contained in:
@@ -2011,10 +2011,234 @@ export const REACTIVE_RUNTIME = String.raw`
|
||||
}
|
||||
|
||||
ensureBehaviorObserver();
|
||||
hydrateNavbarControllers(host);
|
||||
hydratePreferenceControllers(host);
|
||||
hydrateSidebarControllers(host);
|
||||
hydrateDropdownControllers(host);
|
||||
hydrateSelectControllers(host);
|
||||
hydratePinInputControllers(host);
|
||||
}
|
||||
|
||||
var navbarOutsideClickBound = false;
|
||||
var preferenceOutsideClickBound = false;
|
||||
var dropdownOutsideClickBound = false;
|
||||
|
||||
function hydrateSidebarControllers(root) {
|
||||
var host = root || document;
|
||||
var sidebars = [];
|
||||
if (host.nodeType === 1 && host.matches && host.matches(".wire-sidebar-shell")) {
|
||||
sidebars.push(host);
|
||||
}
|
||||
if (host.querySelectorAll) {
|
||||
Array.prototype.push.apply(sidebars, host.querySelectorAll(".wire-sidebar-shell"));
|
||||
}
|
||||
sidebars.forEach(function (sidebar) {
|
||||
var current = window.location.pathname.replace(/\/+$/, "") || "/";
|
||||
var best = null;
|
||||
var bestLength = -1;
|
||||
sidebar.querySelectorAll(".wire-sidebar-items a[href]").forEach(function (link) {
|
||||
var url;
|
||||
try { url = new URL(link.getAttribute("href"), window.location.origin); } catch (_) { return; }
|
||||
var path = url.pathname.replace(/\/+$/, "") || "/";
|
||||
var matches = path === current || (path !== "/" && current.indexOf(path + "/") === 0);
|
||||
link.classList.remove("is-active");
|
||||
if (!matches || path.length <= bestLength) return;
|
||||
best = link;
|
||||
bestLength = path.length;
|
||||
});
|
||||
sidebar.querySelectorAll(".wire-sidebar-items a[aria-current='page']").forEach(function (link) {
|
||||
if (link !== best) link.removeAttribute("aria-current");
|
||||
});
|
||||
sidebar.querySelectorAll(".wire-sidebar-group.has-active").forEach(function (group) {
|
||||
group.classList.remove("has-active");
|
||||
});
|
||||
if (best) {
|
||||
best.classList.add("is-active");
|
||||
best.setAttribute("aria-current", "page");
|
||||
var group = best.closest(".wire-sidebar-group");
|
||||
if (group) {
|
||||
group.setAttribute("open", "");
|
||||
group.classList.add("has-active");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function hydrateDropdownControllers(root) {
|
||||
var host = root || document;
|
||||
var dropdowns = [];
|
||||
if (host.nodeType === 1 && host.matches && host.matches("[data-wrn-dropdown]")) {
|
||||
dropdowns.push(host);
|
||||
}
|
||||
if (host.querySelectorAll) {
|
||||
Array.prototype.push.apply(dropdowns, host.querySelectorAll("[data-wrn-dropdown]"));
|
||||
}
|
||||
dropdowns.forEach(function (dropdown) {
|
||||
if (dropdown.dataset.wrnDropdownBound === "true") return;
|
||||
dropdown.dataset.wrnDropdownBound = "true";
|
||||
dropdown.addEventListener("toggle", function () {
|
||||
if (!dropdown.open) return;
|
||||
document.querySelectorAll("[data-wrn-dropdown][open]").forEach(function (candidate) {
|
||||
if (candidate !== dropdown) candidate.removeAttribute("open");
|
||||
});
|
||||
});
|
||||
});
|
||||
if (!dropdownOutsideClickBound) {
|
||||
dropdownOutsideClickBound = true;
|
||||
document.addEventListener("pointerdown", function (event) {
|
||||
document.querySelectorAll("[data-wrn-dropdown][open]").forEach(function (dropdown) {
|
||||
if (!dropdown.contains(event.target)) dropdown.removeAttribute("open");
|
||||
});
|
||||
});
|
||||
document.addEventListener("keydown", function (event) {
|
||||
if (event.key !== "Escape") return;
|
||||
document.querySelectorAll("[data-wrn-dropdown][open]").forEach(function (dropdown) {
|
||||
dropdown.removeAttribute("open");
|
||||
var summary = dropdown.querySelector(":scope > summary");
|
||||
if (summary) summary.focus();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function hydratePreferenceControllers(root) {
|
||||
var host = root || document;
|
||||
var switchers = [];
|
||||
if (host.nodeType === 1 && host.matches && host.matches("[data-wrn-preferences]")) {
|
||||
switchers.push(host);
|
||||
}
|
||||
if (host.querySelectorAll) {
|
||||
Array.prototype.push.apply(
|
||||
switchers,
|
||||
host.querySelectorAll("[data-wrn-preferences]"),
|
||||
);
|
||||
}
|
||||
switchers.forEach(function (switcher) {
|
||||
if (switcher.dataset.wrnPreferencesBound === "true") return;
|
||||
switcher.dataset.wrnPreferencesBound = "true";
|
||||
switcher.addEventListener("toggle", function (event) {
|
||||
var opened = event.target;
|
||||
if (!opened || opened.tagName !== "DETAILS" || !opened.open) return;
|
||||
switcher.querySelectorAll(".wire-preferences__menu[open]").forEach(function (menu) {
|
||||
if (menu !== opened) menu.removeAttribute("open");
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
if (!preferenceOutsideClickBound) {
|
||||
preferenceOutsideClickBound = true;
|
||||
document.addEventListener("pointerdown", function (event) {
|
||||
document.querySelectorAll("[data-wrn-preferences]").forEach(function (switcher) {
|
||||
if (switcher.contains(event.target)) return;
|
||||
switcher.querySelectorAll(".wire-preferences__menu[open]").forEach(function (menu) {
|
||||
menu.removeAttribute("open");
|
||||
});
|
||||
});
|
||||
});
|
||||
document.addEventListener("keydown", function (event) {
|
||||
if (event.key !== "Escape") return;
|
||||
document.querySelectorAll("[data-wrn-preferences] .wire-preferences__menu[open]").forEach(function (menu) {
|
||||
menu.removeAttribute("open");
|
||||
var summary = menu.querySelector(":scope > summary");
|
||||
if (summary) summary.focus();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function hydrateNavbarControllers(root) {
|
||||
var host = root || document;
|
||||
var navbars = [];
|
||||
if (host.nodeType === 1 && host.matches && host.matches("[data-wrn-navbar]")) {
|
||||
navbars.push(host);
|
||||
}
|
||||
if (host.querySelectorAll) {
|
||||
Array.prototype.push.apply(
|
||||
navbars,
|
||||
host.querySelectorAll("[data-wrn-navbar]"),
|
||||
);
|
||||
}
|
||||
|
||||
navbars.forEach(function (navbar) {
|
||||
var current = window.location.pathname.replace(/\/+$/, "") || "/";
|
||||
var best = null;
|
||||
var bestLength = -1;
|
||||
navbar.querySelectorAll(".wire-navbar__menus a[href]").forEach(function (link) {
|
||||
var url;
|
||||
try { url = new URL(link.getAttribute("href"), window.location.origin); } catch (_) { return; }
|
||||
if (url.origin !== window.location.origin) return;
|
||||
var path = url.pathname.replace(/\/+$/, "") || "/";
|
||||
var matches = path === current || (path !== "/" && current.indexOf(path + "/") === 0);
|
||||
if (!matches || path.length <= bestLength) return;
|
||||
best = link;
|
||||
bestLength = path.length;
|
||||
});
|
||||
navbar.querySelectorAll(".wire-navbar__menus [aria-current='page']").forEach(function (item) {
|
||||
item.removeAttribute("aria-current");
|
||||
});
|
||||
if (best) {
|
||||
best.setAttribute("aria-current", "page");
|
||||
var parentMenu = best.closest(".wire-navbar__dropdown");
|
||||
var parentSummary = parentMenu && parentMenu.querySelector(":scope > summary");
|
||||
if (parentSummary) parentSummary.setAttribute("aria-current", "page");
|
||||
}
|
||||
|
||||
if (navbar.dataset.wrnNavbarBound === "true") return;
|
||||
navbar.dataset.wrnNavbarBound = "true";
|
||||
var hoverEnabled = navbar.getAttribute("data-open-on-hover") === "true";
|
||||
var hoverCapable =
|
||||
typeof window.matchMedia !== "function" ||
|
||||
window.matchMedia("(hover: hover) and (pointer: fine)").matches;
|
||||
if (hoverEnabled && hoverCapable) {
|
||||
navbar.querySelectorAll(".wire-navbar__dropdown").forEach(function (menu) {
|
||||
menu.addEventListener("pointerenter", function () {
|
||||
if (menu.__wrnNavbarCloseTimer) {
|
||||
clearTimeout(menu.__wrnNavbarCloseTimer);
|
||||
menu.__wrnNavbarCloseTimer = null;
|
||||
}
|
||||
navbar.querySelectorAll(".wire-navbar__dropdown[open]").forEach(function (candidate) {
|
||||
if (candidate !== menu) candidate.removeAttribute("open");
|
||||
});
|
||||
menu.setAttribute("open", "");
|
||||
});
|
||||
menu.addEventListener("pointerleave", function () {
|
||||
if (menu.__wrnNavbarCloseTimer) clearTimeout(menu.__wrnNavbarCloseTimer);
|
||||
menu.__wrnNavbarCloseTimer = setTimeout(function () {
|
||||
menu.removeAttribute("open");
|
||||
menu.__wrnNavbarCloseTimer = null;
|
||||
}, 240);
|
||||
});
|
||||
});
|
||||
}
|
||||
navbar.addEventListener("toggle", function (event) {
|
||||
var opened = event.target;
|
||||
if (!opened || opened.tagName !== "DETAILS" || !opened.open) return;
|
||||
navbar.querySelectorAll(".wire-navbar__dropdown[open]").forEach(function (menu) {
|
||||
if (menu !== opened) menu.removeAttribute("open");
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
|
||||
if (!navbarOutsideClickBound) {
|
||||
navbarOutsideClickBound = true;
|
||||
document.addEventListener("pointerdown", function (event) {
|
||||
document.querySelectorAll("[data-wrn-navbar]").forEach(function (navbar) {
|
||||
if (navbar.contains(event.target)) return;
|
||||
navbar.querySelectorAll(".wire-navbar__dropdown[open]").forEach(function (menu) {
|
||||
menu.removeAttribute("open");
|
||||
});
|
||||
});
|
||||
});
|
||||
document.addEventListener("keydown", function (event) {
|
||||
if (event.key !== "Escape") return;
|
||||
document.querySelectorAll("[data-wrn-navbar] .wire-navbar__dropdown[open]").forEach(function (menu) {
|
||||
menu.removeAttribute("open");
|
||||
var summary = menu.querySelector(":scope > summary");
|
||||
if (summary) summary.focus();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var selectOutsideClickBound = false;
|
||||
|
||||
function selectScopeApi(root) {
|
||||
|
||||
Reference in New Issue
Block a user