payload-advanced-sidebar 1.1.4 → 1.2.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 +17 -0
- package/dist/components/Nav/Nav.d.ts +2 -0
- package/dist/components/Nav/NavWithGroups.d.ts +5 -2
- package/dist/components/Nav/get-nav-icon.d.ts +6 -0
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/rsc.d.ts +2 -2
- package/dist/index.d.ts +8 -0
- package/package.json +49 -20
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ A Payload CMS 3.0 plugin that enhances your admin sidebar navigation. It allows
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- 📁 **Group Icons**: Assign custom icons to the sidebar groups you've defined in your Payload config.
|
|
10
|
+
- 🔗 **Custom Nav Links**: Add fully custom items and custom groups that point to external sites or custom Payload views.
|
|
10
11
|
- 🎨 **Item Icons**: Assign custom icons to individual collections and globals.
|
|
11
12
|
- ⚡️ **Lucide React Integration**: Uses [Lucide React](https://lucide.dev/) icons by default. Just pass the exact string name of the icon (e.g., `'ShoppingCart'`).
|
|
12
13
|
- ⚙️ **Simple Configuration**: Seamlessly integrates with your existing Payload config without needing to rewrite your navigation structure.
|
|
@@ -65,6 +66,21 @@ export default buildConfig({
|
|
|
65
66
|
icon: 'Users',
|
|
66
67
|
},
|
|
67
68
|
},
|
|
69
|
+
// 3. Add custom navigation links or groups
|
|
70
|
+
navLinks: [
|
|
71
|
+
{
|
|
72
|
+
label: 'Custom Dashboard',
|
|
73
|
+
path: '/custom-dashboard', // relative to adminRoute
|
|
74
|
+
icon: 'Activity',
|
|
75
|
+
group: 'Analytics', // Creates a new 'Analytics' group
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
label: 'External Link',
|
|
79
|
+
path: 'https://payloadcms.com',
|
|
80
|
+
icon: 'ExternalLink',
|
|
81
|
+
group: 'E-commerce', // Adds to existing 'E-commerce' group
|
|
82
|
+
},
|
|
83
|
+
],
|
|
68
84
|
}),
|
|
69
85
|
],
|
|
70
86
|
})
|
|
@@ -78,6 +94,7 @@ export default buildConfig({
|
|
|
78
94
|
| `animations` | `boolean` | `true` | Set to `false` to disable smooth expanding/collapsing animations for sidebar groups. |
|
|
79
95
|
| `groups` | `Record<string, { icon?: string }>` | `{}` | Map your group names (e.g., `'E-commerce'`) to specific Lucide React icon names. |
|
|
80
96
|
| `items` | `Record<string, { icon?: string }>` | `{}` | Map your collection/global slugs (e.g., `'posts'`) to specific Lucide React icon names. |
|
|
97
|
+
| `navLinks` | `CustomNavLink[]` | `[]` | Array of custom navigation links, allowing you to add external URLs or internal custom routes to existing or new groups. |
|
|
81
98
|
|
|
82
99
|
## Development
|
|
83
100
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ServerProps } from 'payload';
|
|
2
2
|
import './Nav.css';
|
|
3
|
+
import type { CustomNavLink } from '../../index';
|
|
3
4
|
type NavProps = {
|
|
4
5
|
animations?: boolean;
|
|
5
6
|
groupsConfig?: Record<string, {
|
|
@@ -8,6 +9,7 @@ type NavProps = {
|
|
|
8
9
|
itemsConfig?: Record<string, {
|
|
9
10
|
icon?: string;
|
|
10
11
|
}>;
|
|
12
|
+
navLinks?: CustomNavLink[];
|
|
11
13
|
} & ServerProps;
|
|
12
14
|
declare const Nav: (props: NavProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
15
|
export default Nav;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { ServerProps } from "payload";
|
|
2
2
|
export type NavWithGroupsProps = {
|
|
3
|
+
animations?: boolean;
|
|
3
4
|
groupsConfig?: Record<string, {
|
|
4
|
-
icon
|
|
5
|
-
|
|
5
|
+
icon?: string;
|
|
6
|
+
}>;
|
|
7
|
+
itemsConfig?: Record<string, {
|
|
8
|
+
icon?: string;
|
|
6
9
|
}>;
|
|
7
10
|
} & ServerProps;
|
|
8
11
|
export declare const NavWithGroups: (props: NavWithGroupsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { LucideProps } from "lucide-react";
|
|
2
2
|
import type { ExoticComponent } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a Lucide icon from sidebar config.
|
|
5
|
+
*
|
|
6
|
+
* Group labels must match Payload `admin.group` labels exactly, such as
|
|
7
|
+
* `E-Mails`, while collection and global items use their slugs.
|
|
8
|
+
*/
|
|
3
9
|
export declare const getNavIcon: (slug: string, config?: Record<string, {
|
|
4
10
|
icon?: string;
|
|
5
11
|
}>) => ExoticComponent<LucideProps> | undefined;
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { NavClient } from '../components/Nav/Nav.client
|
|
1
|
+
export { NavClient } from '../components/Nav/Nav.client';
|
package/dist/exports/rsc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Nav } from '../components/Nav/Nav
|
|
2
|
-
export { default as NavWithGroups } from '../components/Nav/NavWithGroups
|
|
1
|
+
export { default as Nav } from '../components/Nav/Nav';
|
|
2
|
+
export { default as NavWithGroups } from '../components/Nav/NavWithGroups';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { Config } from 'payload';
|
|
2
|
+
export type CustomNavLink = {
|
|
3
|
+
group?: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
label: Record<string, string> | string;
|
|
6
|
+
path: string;
|
|
7
|
+
slug?: string;
|
|
8
|
+
};
|
|
2
9
|
export type SidebarPluginConfig = {
|
|
3
10
|
animations?: boolean;
|
|
4
11
|
enabled?: boolean;
|
|
@@ -8,6 +15,7 @@ export type SidebarPluginConfig = {
|
|
|
8
15
|
items?: Record<string, {
|
|
9
16
|
icon?: string;
|
|
10
17
|
}>;
|
|
18
|
+
navLinks?: CustomNavLink[];
|
|
11
19
|
};
|
|
12
20
|
export declare const advancedSidebarPlugin: (pluginConfig?: SidebarPluginConfig) => (config: Config) => Config;
|
|
13
21
|
export default advancedSidebarPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload-advanced-sidebar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A Payload CMS 3.0 plugin to customize the admin sidebar with grouping, custom icons, and hide functionality.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -44,6 +44,24 @@
|
|
|
44
44
|
"files": [
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
49
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
50
|
+
"build:types": "tsc --outDir dist --rootDir ./src",
|
|
51
|
+
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
52
|
+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
53
|
+
"dev": "next dev dev --turbo",
|
|
54
|
+
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
|
|
55
|
+
"dev:generate-types": "pnpm dev:payload generate:types",
|
|
56
|
+
"dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
|
|
57
|
+
"generate:importmap": "pnpm dev:generate-importmap",
|
|
58
|
+
"generate:types": "pnpm dev:generate-types",
|
|
59
|
+
"lint": "eslint",
|
|
60
|
+
"lint:fix": "eslint ./src --fix",
|
|
61
|
+
"test": "pnpm test:int && pnpm test:e2e",
|
|
62
|
+
"test:e2e": "playwright test",
|
|
63
|
+
"test:int": "vitest"
|
|
64
|
+
},
|
|
47
65
|
"dependencies": {
|
|
48
66
|
"lucide-react": "^1.17.0"
|
|
49
67
|
},
|
|
@@ -90,23 +108,34 @@
|
|
|
90
108
|
"node": "^18.20.2 || >=20.9.0",
|
|
91
109
|
"pnpm": "^9 || ^10"
|
|
92
110
|
},
|
|
111
|
+
"publishConfig": {
|
|
112
|
+
"exports": {
|
|
113
|
+
".": {
|
|
114
|
+
"import": "./dist/index.js",
|
|
115
|
+
"types": "./dist/index.d.ts",
|
|
116
|
+
"default": "./dist/index.js"
|
|
117
|
+
},
|
|
118
|
+
"./client": {
|
|
119
|
+
"import": "./dist/exports/client.js",
|
|
120
|
+
"types": "./dist/exports/client.d.ts",
|
|
121
|
+
"default": "./dist/exports/client.js"
|
|
122
|
+
},
|
|
123
|
+
"./rsc": {
|
|
124
|
+
"import": "./dist/exports/rsc.js",
|
|
125
|
+
"types": "./dist/exports/rsc.d.ts",
|
|
126
|
+
"default": "./dist/exports/rsc.js"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"main": "./dist/index.js",
|
|
130
|
+
"types": "./dist/index.d.ts"
|
|
131
|
+
},
|
|
132
|
+
"pnpm": {
|
|
133
|
+
"onlyBuiltDependencies": [
|
|
134
|
+
"sharp",
|
|
135
|
+
"esbuild",
|
|
136
|
+
"unrs-resolver"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
93
139
|
"registry": "https://registry.npmjs.org/",
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
97
|
-
"build:types": "tsc --outDir dist --rootDir ./src",
|
|
98
|
-
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
99
|
-
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
100
|
-
"dev": "next dev dev --turbo",
|
|
101
|
-
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
|
|
102
|
-
"dev:generate-types": "pnpm dev:payload generate:types",
|
|
103
|
-
"dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
|
|
104
|
-
"generate:importmap": "pnpm dev:generate-importmap",
|
|
105
|
-
"generate:types": "pnpm dev:generate-types",
|
|
106
|
-
"lint": "eslint",
|
|
107
|
-
"lint:fix": "eslint ./src --fix",
|
|
108
|
-
"test": "pnpm test:int && pnpm test:e2e",
|
|
109
|
-
"test:e2e": "playwright test",
|
|
110
|
-
"test:int": "vitest"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
140
|
+
"packageManager": "pnpm@10.34.3"
|
|
141
|
+
}
|