@solidjs/router 0.4.2 → 0.4.3
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/README.md +0 -3
- package/dist/index.js +4 -2
- package/dist/routing.js +3 -1
- package/dist/types.d.ts +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
<img src="https://assets.solidjs.com/banner?project=Router&type=core" alt="Solid Router" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
> 0.3.x only works with Solid v1.3.5 or later.
|
|
6
|
-
> `useData` has been renamed to `useRouteData` and no longer takes arguments. Refer to documentation below.
|
|
7
|
-
|
|
8
5
|
# Solid Router [](https://www.npmjs.org/package/@solidjs/router)
|
|
9
6
|
|
|
10
7
|
A router lets you change your view based on the URL in the browser. This allows your "single-page" application to simulate a traditional multipage site. To use Solid Router, you specify components called Routes that depend on the value of the URL (the "path"), and the router handles the mechanism of swapping them in and out.
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isServer, createComponent as createComponent$1, mergeProps as mergeProps$1, spread, insert, effect, setAttribute, template } from 'solid-js/web';
|
|
1
|
+
import { isServer, delegateEvents, createComponent as createComponent$1, mergeProps as mergeProps$1, spread, insert, effect, setAttribute, template } from 'solid-js/web';
|
|
2
2
|
import { createSignal, onCleanup, runWithOwner, createMemo, getOwner, createContext, useContext, untrack, useTransition, on, resetErrorBoundaries, createRenderEffect, createComponent, children, createRoot, Show, mergeProps, splitProps } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
function bindEvent(target, type, handler) {
|
|
@@ -650,8 +650,10 @@ function createRouterContext(integration, base = "", data, out) {
|
|
|
650
650
|
scroll: !a.hasAttribute("noscroll"),
|
|
651
651
|
state: state && JSON.parse(state)
|
|
652
652
|
});
|
|
653
|
-
}
|
|
653
|
+
} // ensure delegated events run first
|
|
654
|
+
|
|
654
655
|
|
|
656
|
+
delegateEvents(["click"]);
|
|
655
657
|
document.addEventListener("click", handleAnchorClick);
|
|
656
658
|
onCleanup(() => document.removeEventListener("click", handleAnchorClick));
|
|
657
659
|
}
|
package/dist/routing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent, createContext, createMemo, createRenderEffect, createSignal, on, onCleanup, untrack, useContext, useTransition, resetErrorBoundaries } from "solid-js";
|
|
2
|
-
import { isServer } from "solid-js/web";
|
|
2
|
+
import { isServer, delegateEvents } from "solid-js/web";
|
|
3
3
|
import { normalizeIntegration } from "./integration";
|
|
4
4
|
import { createMemoObject, extractSearchParams, invariant, resolvePath, createMatcher, joinPaths, scoreRoute, mergeSearchString, urlDecode, expandOptionals } from "./utils";
|
|
5
5
|
const MAX_REDIRECTS = 100;
|
|
@@ -331,6 +331,8 @@ export function createRouterContext(integration, base = "", data, out) {
|
|
|
331
331
|
state: state && JSON.parse(state)
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
|
+
// ensure delegated events run first
|
|
335
|
+
delegateEvents(["click"]);
|
|
334
336
|
document.addEventListener("click", handleAnchorClick);
|
|
335
337
|
onCleanup(() => document.removeEventListener("click", handleAnchorClick));
|
|
336
338
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -33,13 +33,13 @@ export interface RouterIntegration {
|
|
|
33
33
|
signal: LocationChangeSignal;
|
|
34
34
|
utils?: Partial<RouterUtils>;
|
|
35
35
|
}
|
|
36
|
-
export interface RouteDataFuncArgs {
|
|
37
|
-
data:
|
|
36
|
+
export interface RouteDataFuncArgs<T = unknown> {
|
|
37
|
+
data: T extends RouteDataFunc ? ReturnType<T> : T;
|
|
38
38
|
params: Params;
|
|
39
39
|
location: Location;
|
|
40
40
|
navigate: Navigator;
|
|
41
41
|
}
|
|
42
|
-
export declare type RouteDataFunc<T = unknown> = (args: RouteDataFuncArgs) =>
|
|
42
|
+
export declare type RouteDataFunc<T = unknown, R = unknown> = (args: RouteDataFuncArgs<T>) => R;
|
|
43
43
|
export declare type RouteDefinition = {
|
|
44
44
|
path: string | string[];
|
|
45
45
|
data?: RouteDataFunc;
|