xladmin-react-router 0.3.0 → 0.3.2
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 +6 -6
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,12 +20,12 @@ npm install xladmin xladmin-react-router react-router-dom
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
22
|
```tsx
|
|
23
|
-
import {Shell,
|
|
24
|
-
import {
|
|
23
|
+
import {Shell, createFetchAdminClient} from 'xladmin';
|
|
24
|
+
import {useReactRouterAdminRouter} from 'xladmin-react-router';
|
|
25
25
|
|
|
26
26
|
export function AdminShell({models, blocks}) {
|
|
27
|
-
const client =
|
|
28
|
-
const router =
|
|
27
|
+
const client = createFetchAdminClient({baseUrl: '/api/admin'});
|
|
28
|
+
const router = useReactRouterAdminRouter();
|
|
29
29
|
|
|
30
30
|
return (
|
|
31
31
|
<Shell client={client} models={models} blocks={blocks} basePath="/admin" locale="en" router={router}>
|
|
@@ -37,8 +37,8 @@ export function AdminShell({models, blocks}) {
|
|
|
37
37
|
|
|
38
38
|
## Exports
|
|
39
39
|
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
40
|
+
- `useReactRouterAdminRouter()`
|
|
41
|
+
- `createReactRouterAdminRouter(...)`
|
|
42
42
|
|
|
43
43
|
## Docs
|
|
44
44
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AdminRouter } from 'xladmin';
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
type ReactRouterAdminAdapter = {
|
|
4
4
|
pathname: string;
|
|
5
5
|
search: string;
|
|
6
6
|
push: (href: string) => void;
|
|
7
7
|
replace: (href: string) => void;
|
|
8
8
|
back: () => void;
|
|
9
9
|
};
|
|
10
|
-
declare function
|
|
11
|
-
declare function
|
|
10
|
+
declare function createReactRouterAdminRouter(adapter: ReactRouterAdminAdapter): AdminRouter;
|
|
11
|
+
declare function useReactRouterAdminRouter(): AdminRouter;
|
|
12
12
|
|
|
13
|
-
export { type
|
|
13
|
+
export { type ReactRouterAdminAdapter, createReactRouterAdminRouter, useReactRouterAdminRouter };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/index.tsx
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
5
|
import { useLocation, useNavigate } from "react-router-dom";
|
|
6
|
-
function
|
|
6
|
+
function createReactRouterAdminRouter(adapter) {
|
|
7
7
|
return {
|
|
8
8
|
getLocation: () => ({
|
|
9
9
|
pathname: adapter.pathname,
|
|
@@ -22,7 +22,7 @@ function createReactRouterXLAdminRouter(adapter) {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function useReactRouterAdminRouter() {
|
|
26
26
|
const location = useLocation();
|
|
27
27
|
const navigate = useNavigate();
|
|
28
28
|
const listenersRef = useRef(/* @__PURE__ */ new Set());
|
|
@@ -39,7 +39,7 @@ function useReactRouterXLAdminRouter() {
|
|
|
39
39
|
};
|
|
40
40
|
navigateRef.current = navigate;
|
|
41
41
|
if (routerRef.current === null) {
|
|
42
|
-
routerRef.current =
|
|
42
|
+
routerRef.current = createReactRouterAdminRouter({
|
|
43
43
|
pathname: locationRef.current.pathname,
|
|
44
44
|
search: locationRef.current.search,
|
|
45
45
|
push: (href) => {
|
|
@@ -76,6 +76,6 @@ function useReactRouterXLAdminRouter() {
|
|
|
76
76
|
return routerRef.current;
|
|
77
77
|
}
|
|
78
78
|
export {
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
createReactRouterAdminRouter,
|
|
80
|
+
useReactRouterAdminRouter
|
|
81
81
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xladmin-react-router",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "React Router adapter for xladmin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"react": ">=19.0.0 <20.0.0",
|
|
40
40
|
"react-dom": ">=19.0.0 <20.0.0",
|
|
41
41
|
"react-router-dom": ">=6.4.0 <8.0.0",
|
|
42
|
-
"xladmin": "^0.3.
|
|
42
|
+
"xladmin": "^0.3.2"
|
|
43
43
|
}
|
|
44
44
|
}
|