xladmin-next 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
|
@@ -22,12 +22,12 @@ npm install xladmin xladmin-next
|
|
|
22
22
|
```tsx
|
|
23
23
|
'use client';
|
|
24
24
|
|
|
25
|
-
import {Shell,
|
|
26
|
-
import {
|
|
25
|
+
import {Shell, createFetchAdminClient} from 'xladmin';
|
|
26
|
+
import {useNextAdminRouter} from 'xladmin-next';
|
|
27
27
|
|
|
28
28
|
export function AdminShell({models, blocks}) {
|
|
29
|
-
const client =
|
|
30
|
-
const router =
|
|
29
|
+
const client = createFetchAdminClient({baseUrl: '/api/admin'});
|
|
30
|
+
const router = useNextAdminRouter();
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<Shell client={client} models={models} blocks={blocks} basePath="/admin" locale="en" router={router}>
|
|
@@ -39,8 +39,8 @@ export function AdminShell({models, blocks}) {
|
|
|
39
39
|
|
|
40
40
|
## Exports
|
|
41
41
|
|
|
42
|
-
- `
|
|
43
|
-
- `
|
|
42
|
+
- `useNextAdminRouter()`
|
|
43
|
+
- `createNextAdminRouter(...)`
|
|
44
44
|
|
|
45
45
|
## Docs
|
|
46
46
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AdminRouter } from 'xladmin';
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
type NextAdminRouterAdapter = {
|
|
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 createNextAdminRouter(adapter: NextAdminRouterAdapter): AdminRouter;
|
|
11
|
+
declare function useNextAdminRouter(): AdminRouter;
|
|
12
12
|
|
|
13
|
-
export { type
|
|
13
|
+
export { type NextAdminRouterAdapter, createNextAdminRouter, useNextAdminRouter };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/index.tsx
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
5
|
import { usePathname, useRouter, useSearchParams } from "next/navigation.js";
|
|
6
|
-
function
|
|
6
|
+
function createNextAdminRouter(adapter) {
|
|
7
7
|
return {
|
|
8
8
|
getLocation: () => ({
|
|
9
9
|
pathname: adapter.pathname,
|
|
@@ -22,7 +22,7 @@ function createNextXLAdminRouter(adapter) {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function useNextAdminRouter() {
|
|
26
26
|
const nextRouter = useRouter();
|
|
27
27
|
const pathname = usePathname();
|
|
28
28
|
const searchParams = useSearchParams();
|
|
@@ -40,7 +40,7 @@ function useNextXLAdminRouter() {
|
|
|
40
40
|
};
|
|
41
41
|
navigationRef.current = nextRouter;
|
|
42
42
|
if (routerRef.current === null) {
|
|
43
|
-
routerRef.current =
|
|
43
|
+
routerRef.current = createNextAdminRouter({
|
|
44
44
|
pathname: locationRef.current.pathname,
|
|
45
45
|
search: locationRef.current.search,
|
|
46
46
|
push: (href) => {
|
|
@@ -77,6 +77,6 @@ function useNextXLAdminRouter() {
|
|
|
77
77
|
return routerRef.current;
|
|
78
78
|
}
|
|
79
79
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
createNextAdminRouter,
|
|
81
|
+
useNextAdminRouter
|
|
82
82
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xladmin-next",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Next.js router adapter for xladmin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"next": ">=15.0.0 <17.0.0",
|
|
40
40
|
"react": ">=19.0.0 <20.0.0",
|
|
41
41
|
"react-dom": ">=19.0.0 <20.0.0",
|
|
42
|
-
"xladmin": "^0.3.
|
|
42
|
+
"xladmin": "^0.3.2"
|
|
43
43
|
}
|
|
44
44
|
}
|