solid-navigator 0.0.1 → 0.1.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/README.md +10 -0
- package/dist/dev.js +6 -1
- package/dist/dev.jsx +7 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +6 -1
- package/dist/index.jsx +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -55,6 +55,16 @@ const params = useParams<{id: string}>();
|
|
|
55
55
|
}
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
### `useMatch`
|
|
59
|
+
```js
|
|
60
|
+
// path: /chats/1234
|
|
61
|
+
const match = useMatch(() => "/chats/1234");
|
|
62
|
+
{
|
|
63
|
+
path: "/chats/1234"
|
|
64
|
+
params: {}
|
|
65
|
+
} | null
|
|
66
|
+
```
|
|
67
|
+
|
|
58
68
|
## Components
|
|
59
69
|
|
|
60
70
|
### `Router`
|
package/dist/dev.js
CHANGED
|
@@ -310,5 +310,10 @@ var A = (props) => {
|
|
|
310
310
|
return _el$;
|
|
311
311
|
})();
|
|
312
312
|
};
|
|
313
|
+
var useMatch = (path) => {
|
|
314
|
+
const context = useRouterContext();
|
|
315
|
+
const matcher = createMemo(() => createMatcher(path()));
|
|
316
|
+
return createMemo(() => matcher()(context.location.pathname));
|
|
317
|
+
};
|
|
313
318
|
|
|
314
|
-
export { A, Navigate, Outlet, Route, Router, useLocation, useNavigate, useParams };
|
|
319
|
+
export { A, Navigate, Outlet, Route, Router, useLocation, useMatch, useNavigate, useParams };
|
package/dist/dev.jsx
CHANGED
|
@@ -304,9 +304,15 @@ var Route = (props) => {
|
|
|
304
304
|
};
|
|
305
305
|
|
|
306
306
|
// src/Link.tsx
|
|
307
|
+
import { createMemo as createMemo4 } from "solid-js";
|
|
307
308
|
var A = (props) => {
|
|
308
309
|
return <a sn-link {...props} />;
|
|
309
310
|
};
|
|
311
|
+
var useMatch = (path) => {
|
|
312
|
+
const context = useRouterContext();
|
|
313
|
+
const matcher = createMemo4(() => createMatcher(path()));
|
|
314
|
+
return createMemo4(() => matcher()(context.location.pathname));
|
|
315
|
+
};
|
|
310
316
|
export {
|
|
311
317
|
A,
|
|
312
318
|
Navigate,
|
|
@@ -314,6 +320,7 @@ export {
|
|
|
314
320
|
Route,
|
|
315
321
|
Router,
|
|
316
322
|
useLocation,
|
|
323
|
+
useMatch,
|
|
317
324
|
useNavigate,
|
|
318
325
|
useParams
|
|
319
326
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ declare const Outlet: (props: {
|
|
|
24
24
|
name?: string;
|
|
25
25
|
}) => solid_js.JSX.Element;
|
|
26
26
|
|
|
27
|
+
type Params = Record<string, string>;
|
|
28
|
+
interface PathMatch {
|
|
29
|
+
params: Params;
|
|
30
|
+
path: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
interface RouterProps {
|
|
28
34
|
children?: JSX.Element;
|
|
29
35
|
root?: () => JSX.Element;
|
|
@@ -41,5 +47,6 @@ type LinkProps = {
|
|
|
41
47
|
replace?: boolean;
|
|
42
48
|
} & JSX.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
43
49
|
declare const A: (props: LinkProps) => JSX.Element;
|
|
50
|
+
declare const useMatch: (path: () => string) => solid_js.Accessor<PathMatch | null>;
|
|
44
51
|
|
|
45
|
-
export { A, Navigate, type NavigateOptions, Outlet, Route, type RouteObject, Router, type RouterProps, useLocation, useNavigate, useParams };
|
|
52
|
+
export { A, Navigate, type NavigateOptions, Outlet, Route, type RouteObject, Router, type RouterProps, useLocation, useMatch, useNavigate, useParams };
|
package/dist/index.js
CHANGED
|
@@ -307,5 +307,10 @@ var A = (props) => {
|
|
|
307
307
|
return _el$;
|
|
308
308
|
})();
|
|
309
309
|
};
|
|
310
|
+
var useMatch = (path) => {
|
|
311
|
+
const context = useRouterContext();
|
|
312
|
+
const matcher = createMemo(() => createMatcher(path()));
|
|
313
|
+
return createMemo(() => matcher()(context.location.pathname));
|
|
314
|
+
};
|
|
310
315
|
|
|
311
|
-
export { A, Navigate, Outlet, Route, Router, useLocation, useNavigate, useParams };
|
|
316
|
+
export { A, Navigate, Outlet, Route, Router, useLocation, useMatch, useNavigate, useParams };
|
package/dist/index.jsx
CHANGED
|
@@ -301,9 +301,15 @@ var Route = (props) => {
|
|
|
301
301
|
};
|
|
302
302
|
|
|
303
303
|
// src/Link.tsx
|
|
304
|
+
import { createMemo as createMemo4 } from "solid-js";
|
|
304
305
|
var A = (props) => {
|
|
305
306
|
return <a sn-link {...props} />;
|
|
306
307
|
};
|
|
308
|
+
var useMatch = (path) => {
|
|
309
|
+
const context = useRouterContext();
|
|
310
|
+
const matcher = createMemo4(() => createMatcher(path()));
|
|
311
|
+
return createMemo4(() => matcher()(context.location.pathname));
|
|
312
|
+
};
|
|
307
313
|
export {
|
|
308
314
|
A,
|
|
309
315
|
Navigate,
|
|
@@ -311,6 +317,7 @@ export {
|
|
|
311
317
|
Route,
|
|
312
318
|
Router,
|
|
313
319
|
useLocation,
|
|
320
|
+
useMatch,
|
|
314
321
|
useNavigate,
|
|
315
322
|
useParams
|
|
316
323
|
};
|