@lolyjs/core 0.1.0-alpha.2 → 0.1.0-alpha.4
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/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +25 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +25 -9
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +26 -10
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5499,11 +5499,19 @@ async function navigate(nextUrl, handlers, options) {
|
|
|
5499
5499
|
}
|
|
5500
5500
|
function createClickHandler(navigate2) {
|
|
5501
5501
|
return function handleClick(ev) {
|
|
5502
|
+
const path25 = ev.composedPath();
|
|
5503
|
+
for (const element of path25) {
|
|
5504
|
+
if (!(element instanceof HTMLElement)) continue;
|
|
5505
|
+
const tagName = element.tagName.toLowerCase();
|
|
5506
|
+
if (tagName === "input" || tagName === "textarea" || tagName === "button" || tagName === "select" || element.isContentEditable || tagName === "label" && element.control) {
|
|
5507
|
+
return;
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
const target = ev.target;
|
|
5511
|
+
if (!target) return;
|
|
5502
5512
|
if (ev.defaultPrevented) return;
|
|
5503
5513
|
if (ev.button !== 0) return;
|
|
5504
5514
|
if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey) return;
|
|
5505
|
-
const target = ev.target;
|
|
5506
|
-
if (!target) return;
|
|
5507
5515
|
const anchor = target.closest("a[href]");
|
|
5508
5516
|
if (!anchor) return;
|
|
5509
5517
|
const href = anchor.getAttribute("href");
|
|
@@ -5537,25 +5545,33 @@ function AppShell({
|
|
|
5537
5545
|
errorRoute
|
|
5538
5546
|
}) {
|
|
5539
5547
|
const [state, setState] = (0, import_react2.useState)(initialState);
|
|
5548
|
+
const handlersRef = (0, import_react2.useRef)({
|
|
5549
|
+
setState,
|
|
5550
|
+
routes,
|
|
5551
|
+
notFoundRoute,
|
|
5552
|
+
errorRoute
|
|
5553
|
+
});
|
|
5540
5554
|
(0, import_react2.useEffect)(() => {
|
|
5541
|
-
|
|
5555
|
+
handlersRef.current = {
|
|
5542
5556
|
setState,
|
|
5543
5557
|
routes,
|
|
5544
5558
|
notFoundRoute,
|
|
5545
5559
|
errorRoute
|
|
5546
5560
|
};
|
|
5561
|
+
}, [routes, notFoundRoute, errorRoute]);
|
|
5562
|
+
(0, import_react2.useEffect)(() => {
|
|
5547
5563
|
async function handleNavigate(nextUrl, options) {
|
|
5548
|
-
await navigate(nextUrl,
|
|
5564
|
+
await navigate(nextUrl, handlersRef.current, options);
|
|
5549
5565
|
}
|
|
5550
5566
|
const handleClick = createClickHandler(handleNavigate);
|
|
5551
5567
|
const handlePopState = createPopStateHandler(handleNavigate);
|
|
5552
|
-
window.addEventListener("click", handleClick);
|
|
5553
|
-
window.addEventListener("popstate", handlePopState);
|
|
5568
|
+
window.addEventListener("click", handleClick, { capture: false });
|
|
5569
|
+
window.addEventListener("popstate", handlePopState, { capture: false });
|
|
5554
5570
|
return () => {
|
|
5555
|
-
window.removeEventListener("click", handleClick);
|
|
5556
|
-
window.removeEventListener("popstate", handlePopState);
|
|
5571
|
+
window.removeEventListener("click", handleClick, { capture: false });
|
|
5572
|
+
window.removeEventListener("popstate", handlePopState, { capture: false });
|
|
5557
5573
|
};
|
|
5558
|
-
}, [
|
|
5574
|
+
}, []);
|
|
5559
5575
|
const isError = state.route === errorRoute;
|
|
5560
5576
|
const isNotFound = state.route === notFoundRoute;
|
|
5561
5577
|
const routeType = isError ? "error" : isNotFound ? "notfound" : "normal";
|