payload-advanced-sidebar 1.0.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 +99 -0
- package/dist/components/Nav/Nav.client.d.ts +12 -0
- package/dist/components/Nav/Nav.client.js +121 -0
- package/dist/components/Nav/Nav.client.js.map +1 -0
- package/dist/components/Nav/Nav.d.ts +12 -0
- package/dist/components/Nav/Nav.js +91 -0
- package/dist/components/Nav/Nav.js.map +1 -0
- package/dist/components/Nav/Nav.scss +82 -0
- package/dist/components/Nav/NavWithGroups.d.ts +9 -0
- package/dist/components/Nav/NavWithGroups.js +11 -0
- package/dist/components/Nav/NavWithGroups.js.map +1 -0
- package/dist/components/Nav/NavWrapper.d.ts +5 -0
- package/dist/components/Nav/NavWrapper.js +24 -0
- package/dist/components/Nav/NavWrapper.js.map +1 -0
- package/dist/components/Nav/get-nav-icon.d.ts +5 -0
- package/dist/components/Nav/get-nav-icon.js +15 -0
- package/dist/components/Nav/get-nav-icon.js.map +1 -0
- package/dist/components/Nav/nav-utils.d.ts +11 -0
- package/dist/components/Nav/nav-utils.js +7 -0
- package/dist/components/Nav/nav-utils.js.map +1 -0
- package/dist/endpoints/customEndpointHandler.d.ts +2 -0
- package/dist/endpoints/customEndpointHandler.js +7 -0
- package/dist/endpoints/customEndpointHandler.js.map +1 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +3 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/rsc.d.ts +2 -0
- package/dist/exports/rsc.js +4 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +139 -0
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Payload Plugin Advanced Sidebar
|
|
2
|
+
|
|
3
|
+
A Payload CMS 3.0 plugin that gives you complete control over your admin sidebar navigation. Organize collections and globals into custom groups, add custom icons, and hide specific items with ease.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 📁 **Custom Groups**: Organize your collections and globals into logical groups.
|
|
10
|
+
- 🎨 **Custom Icons**: Add Lucide React icons or your own custom icons to your navigation items.
|
|
11
|
+
- 👻 **Hide Items**: Easily hide specific collections or globals from the sidebar.
|
|
12
|
+
- 🔗 **External Links**: Add custom external links to your sidebar (if applicable).
|
|
13
|
+
- ⚙️ **Simple Configuration**: Easy to set up and configure directly from your Payload config.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install payload-advanced-sidebar
|
|
19
|
+
# or
|
|
20
|
+
yarn add payload-advanced-sidebar
|
|
21
|
+
# or
|
|
22
|
+
pnpm add payload-advanced-sidebar
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Add the plugin to your Payload configuration:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { buildConfig } from 'payload/config'
|
|
31
|
+
import { advancedSidebarPlugin } from 'payload-advanced-sidebar'
|
|
32
|
+
import { Settings, Users } from 'lucide-react'
|
|
33
|
+
|
|
34
|
+
export default buildConfig({
|
|
35
|
+
// ... rest of your config
|
|
36
|
+
plugins: [
|
|
37
|
+
advancedSidebarPlugin({
|
|
38
|
+
navItems: [
|
|
39
|
+
{
|
|
40
|
+
type: 'group',
|
|
41
|
+
label: 'Content Management',
|
|
42
|
+
icon: Settings, // Optional group icon
|
|
43
|
+
items: [
|
|
44
|
+
{
|
|
45
|
+
type: 'collection',
|
|
46
|
+
slug: 'posts',
|
|
47
|
+
icon: Settings, // Optional item icon
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: 'collection',
|
|
51
|
+
slug: 'pages',
|
|
52
|
+
icon: Settings,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'group',
|
|
58
|
+
label: 'Administration',
|
|
59
|
+
items: [
|
|
60
|
+
{
|
|
61
|
+
type: 'collection',
|
|
62
|
+
slug: 'users',
|
|
63
|
+
icon: Users,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
// Optional: Globally hide specific collections/globals
|
|
69
|
+
hideSettings: {
|
|
70
|
+
collections: ['hidden-collection'],
|
|
71
|
+
globals: ['hidden-global'],
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+

|
|
79
|
+
|
|
80
|
+
## Plugin Options
|
|
81
|
+
|
|
82
|
+
| Option | Type | Description |
|
|
83
|
+
| -------------- | ------------------------------------------------ | --------------------------------------------------------------------------- |
|
|
84
|
+
| `navItems` | `NavItem[]` | Array of custom navigation groups and items to render in the sidebar. |
|
|
85
|
+
| `hideSettings` | `{ collections?: string[], globals?: string[] }` | Optional settings to hide specific collections or globals from the sidebar. |
|
|
86
|
+
| `disabled` | `boolean` | Set to `true` to disable the plugin entirely. |
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
To develop or contribute to this plugin:
|
|
91
|
+
|
|
92
|
+
1. Clone the repository
|
|
93
|
+
2. Run `pnpm install`
|
|
94
|
+
3. Run `pnpm dev` to start the development server
|
|
95
|
+
4. Edit the files in the `src` directory
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NavGroupType } from '@payloadcms/ui/shared';
|
|
2
|
+
type NavProps = {
|
|
3
|
+
groups: NavGroupType[];
|
|
4
|
+
groupsConfig?: Record<string, {
|
|
5
|
+
icon?: string;
|
|
6
|
+
}>;
|
|
7
|
+
itemsConfig?: Record<string, {
|
|
8
|
+
icon?: string;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
export declare const NavClient: ({ groups, groupsConfig, itemsConfig }: NavProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
4
|
+
import { Link, useConfig, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import { EntityType, formatAdminURL } from '@payloadcms/ui/shared';
|
|
6
|
+
import { ChevronDown, ChevronRight, Home } from 'lucide-react';
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { usePathname } from 'next/navigation';
|
|
10
|
+
import { getNavIcon } from './get-nav-icon.js';
|
|
11
|
+
import { getActiveGroup, getSortedGroups } from './nav-utils.js';
|
|
12
|
+
const baseClass = 'nav';
|
|
13
|
+
export const NavClient = ({ groups, groupsConfig, itemsConfig })=>{
|
|
14
|
+
const pathname = usePathname();
|
|
15
|
+
const { config: { routes: { admin: adminRoute } } } = useConfig();
|
|
16
|
+
const { i18n } = useTranslation();
|
|
17
|
+
const activeGroupSlug = getActiveGroup(pathname, adminRoute);
|
|
18
|
+
const sortedGroups = getSortedGroups(groups);
|
|
19
|
+
const [openGroups, setOpenGroups] = useState([]);
|
|
20
|
+
useEffect(()=>{
|
|
21
|
+
const activeNavGroup = sortedGroups.find((g)=>g.entities.some((e)=>e.slug === activeGroupSlug));
|
|
22
|
+
if (activeNavGroup && !openGroups.includes(activeNavGroup.label)) {
|
|
23
|
+
setOpenGroups((prev)=>[
|
|
24
|
+
...prev,
|
|
25
|
+
activeNavGroup.label
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
}, [
|
|
29
|
+
activeGroupSlug,
|
|
30
|
+
sortedGroups
|
|
31
|
+
]);
|
|
32
|
+
const toggleGroup = (label)=>{
|
|
33
|
+
setOpenGroups((prev)=>prev.includes(label) ? prev.filter((g)=>g !== label) : [
|
|
34
|
+
...prev,
|
|
35
|
+
label
|
|
36
|
+
]);
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
39
|
+
className: "menu",
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ _jsx("li", {
|
|
42
|
+
className: "group",
|
|
43
|
+
children: /*#__PURE__*/ _jsxs(Link, {
|
|
44
|
+
className: `${baseClass}__link group-toggle ${pathname === adminRoute ? 'active' : ''}`,
|
|
45
|
+
href: adminRoute,
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ _jsx(Home, {
|
|
48
|
+
size: 16
|
|
49
|
+
}),
|
|
50
|
+
'Home'
|
|
51
|
+
]
|
|
52
|
+
})
|
|
53
|
+
}),
|
|
54
|
+
sortedGroups.map(({ entities, label: groupLabel }, key)=>{
|
|
55
|
+
const groupSlug = groupLabel.toLowerCase();
|
|
56
|
+
const Icon = getNavIcon(groupSlug, groupsConfig);
|
|
57
|
+
const isOpen = openGroups.includes(groupLabel);
|
|
58
|
+
return /*#__PURE__*/ _jsxs("li", {
|
|
59
|
+
className: "group",
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
62
|
+
className: `${baseClass}__link group-toggle`,
|
|
63
|
+
onClick: ()=>toggleGroup(groupLabel),
|
|
64
|
+
style: {
|
|
65
|
+
cursor: 'pointer'
|
|
66
|
+
},
|
|
67
|
+
children: [
|
|
68
|
+
Icon && /*#__PURE__*/ _jsx(Icon, {
|
|
69
|
+
size: 16
|
|
70
|
+
}),
|
|
71
|
+
getTranslation(groupLabel, i18n),
|
|
72
|
+
/*#__PURE__*/ _jsx("div", {
|
|
73
|
+
className: "group-chevron",
|
|
74
|
+
children: isOpen ? /*#__PURE__*/ _jsx(ChevronDown, {
|
|
75
|
+
size: 16
|
|
76
|
+
}) : /*#__PURE__*/ _jsx(ChevronRight, {
|
|
77
|
+
size: 16
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
]
|
|
81
|
+
}),
|
|
82
|
+
isOpen && entities.map(({ slug, type, label })=>{
|
|
83
|
+
let href = null;
|
|
84
|
+
if (type === EntityType.collection) {
|
|
85
|
+
href = formatAdminURL({
|
|
86
|
+
adminRoute,
|
|
87
|
+
path: `/collections/${slug}`
|
|
88
|
+
});
|
|
89
|
+
} else if (type === EntityType.global) {
|
|
90
|
+
href = formatAdminURL({
|
|
91
|
+
adminRoute,
|
|
92
|
+
path: `/globals/${slug}`
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const ItemIcon = getNavIcon(slug, itemsConfig);
|
|
96
|
+
return /*#__PURE__*/ _jsx(Link, {
|
|
97
|
+
className: `${baseClass}__link sub-group-list ${pathname === href ? 'active' : ''}`,
|
|
98
|
+
href: href || '',
|
|
99
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
100
|
+
style: {
|
|
101
|
+
alignItems: 'center',
|
|
102
|
+
display: 'flex',
|
|
103
|
+
gap: '6px'
|
|
104
|
+
},
|
|
105
|
+
children: [
|
|
106
|
+
ItemIcon && /*#__PURE__*/ _jsx(ItemIcon, {
|
|
107
|
+
size: 14
|
|
108
|
+
}),
|
|
109
|
+
getTranslation(label, i18n)
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
}, slug);
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
}, key);
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=Nav.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/Nav.client.tsx"],"sourcesContent":["'use client'\n\nimport type { NavGroupType } from '@payloadcms/ui/shared'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Link, useConfig, useTranslation } from '@payloadcms/ui'\nimport { EntityType, formatAdminURL } from '@payloadcms/ui/shared'\nimport { ChevronDown, ChevronRight, Home } from 'lucide-react'\nimport { useEffect, useState } from 'react'\n// @ts-ignore\nimport { usePathname } from 'next/navigation'\n\nimport { getNavIcon } from './get-nav-icon.js'\nimport { getActiveGroup, getSortedGroups } from './nav-utils.js'\n\ntype NavProps = {\n groups: NavGroupType[]\n groupsConfig?: Record<string, { icon?: string }>\n itemsConfig?: Record<string, { icon?: string }>\n}\n\nconst baseClass = 'nav'\n\nexport const NavClient = ({ groups, groupsConfig, itemsConfig }: NavProps) => {\n const pathname = usePathname()\n const {\n config: {\n routes: { admin: adminRoute },\n },\n } = useConfig()\n const { i18n } = useTranslation()\n\n const activeGroupSlug = getActiveGroup(pathname, adminRoute)\n const sortedGroups = getSortedGroups(groups)\n\n const [openGroups, setOpenGroups] = useState<string[]>([])\n\n useEffect(() => {\n const activeNavGroup = sortedGroups.find((g) =>\n g.entities.some((e) => e.slug === activeGroupSlug),\n )\n if (activeNavGroup && !openGroups.includes(activeNavGroup.label)) {\n setOpenGroups((prev) => [...prev, activeNavGroup.label])\n }\n }, [activeGroupSlug, sortedGroups])\n\n const toggleGroup = (label: string) => {\n setOpenGroups((prev) =>\n prev.includes(label) ? prev.filter((g) => g !== label) : [...prev, label],\n )\n }\n\n return (\n <div className=\"menu\">\n <li className=\"group\">\n <Link\n className={`${baseClass}__link group-toggle ${pathname === adminRoute ? 'active' : ''}`}\n href={adminRoute}\n >\n <Home size={16} />\n {'Home'}\n </Link>\n </li>\n {sortedGroups.map(({ entities, label: groupLabel }: NavGroupType, key: number) => {\n const groupSlug = groupLabel.toLowerCase()\n const Icon = getNavIcon(groupSlug, groupsConfig)\n const isOpen = openGroups.includes(groupLabel)\n\n return (\n <li className=\"group\" key={key}>\n <div\n className={`${baseClass}__link group-toggle`}\n onClick={() => toggleGroup(groupLabel)}\n style={{ cursor: 'pointer' }}\n >\n {Icon && <Icon size={16} />}\n {getTranslation(groupLabel, i18n)}\n <div className=\"group-chevron\">\n {isOpen ? <ChevronDown size={16} /> : <ChevronRight size={16} />}\n </div>\n </div>\n {isOpen &&\n entities.map(({ slug, type, label }: any) => {\n let href: null | string = null\n if (type === EntityType.collection) {\n href = formatAdminURL({\n adminRoute,\n path: `/collections/${slug}`,\n })\n } else if (type === EntityType.global) {\n href = formatAdminURL({\n adminRoute,\n path: `/globals/${slug}`,\n })\n }\n const ItemIcon = getNavIcon(slug, itemsConfig)\n\n return (\n <Link\n className={`${baseClass}__link sub-group-list ${pathname === href ? 'active' : ''}`}\n href={href || ''}\n key={slug}\n >\n <div style={{ alignItems: 'center', display: 'flex', gap: '6px' }}>\n {ItemIcon && <ItemIcon size={14} />}\n {getTranslation(label, i18n)}\n </div>\n </Link>\n )\n })}\n </li>\n )\n })}\n </div>\n )\n}\n"],"names":["getTranslation","Link","useConfig","useTranslation","EntityType","formatAdminURL","ChevronDown","ChevronRight","Home","useEffect","useState","usePathname","getNavIcon","getActiveGroup","getSortedGroups","baseClass","NavClient","groups","groupsConfig","itemsConfig","pathname","config","routes","admin","adminRoute","i18n","activeGroupSlug","sortedGroups","openGroups","setOpenGroups","activeNavGroup","find","g","entities","some","e","slug","includes","label","prev","toggleGroup","filter","div","className","li","href","size","map","groupLabel","key","groupSlug","toLowerCase","Icon","isOpen","onClick","style","cursor","type","collection","path","global","ItemIcon","alignItems","display","gap"],"mappings":"AAAA;;AAIA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,IAAI,EAAEC,SAAS,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,SAASC,UAAU,EAAEC,cAAc,QAAQ,wBAAuB;AAClE,SAASC,WAAW,EAAEC,YAAY,EAAEC,IAAI,QAAQ,eAAc;AAC9D,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC3C,aAAa;AACb,SAASC,WAAW,QAAQ,kBAAiB;AAE7C,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,cAAc,EAAEC,eAAe,QAAQ,iBAAgB;AAQhE,MAAMC,YAAY;AAElB,OAAO,MAAMC,YAAY,CAAC,EAAEC,MAAM,EAAEC,YAAY,EAAEC,WAAW,EAAY;IACvE,MAAMC,WAAWT;IACjB,MAAM,EACJU,QAAQ,EACNC,QAAQ,EAAEC,OAAOC,UAAU,EAAE,EAC9B,EACF,GAAGtB;IACJ,MAAM,EAAEuB,IAAI,EAAE,GAAGtB;IAEjB,MAAMuB,kBAAkBb,eAAeO,UAAUI;IACjD,MAAMG,eAAeb,gBAAgBG;IAErC,MAAM,CAACW,YAAYC,cAAc,GAAGnB,SAAmB,EAAE;IAEzDD,UAAU;QACR,MAAMqB,iBAAiBH,aAAaI,IAAI,CAAC,CAACC,IACxCA,EAAEC,QAAQ,CAACC,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKV;QAEpC,IAAII,kBAAkB,CAACF,WAAWS,QAAQ,CAACP,eAAeQ,KAAK,GAAG;YAChET,cAAc,CAACU,OAAS;uBAAIA;oBAAMT,eAAeQ,KAAK;iBAAC;QACzD;IACF,GAAG;QAACZ;QAAiBC;KAAa;IAElC,MAAMa,cAAc,CAACF;QACnBT,cAAc,CAACU,OACbA,KAAKF,QAAQ,CAACC,SAASC,KAAKE,MAAM,CAAC,CAACT,IAAMA,MAAMM,SAAS;mBAAIC;gBAAMD;aAAM;IAE7E;IAEA,qBACE,MAACI;QAAIC,WAAU;;0BACb,KAACC;gBAAGD,WAAU;0BACZ,cAAA,MAAC1C;oBACC0C,WAAW,GAAG5B,UAAU,oBAAoB,EAAEK,aAAaI,aAAa,WAAW,IAAI;oBACvFqB,MAAMrB;;sCAEN,KAAChB;4BAAKsC,MAAM;;wBACX;;;;YAGJnB,aAAaoB,GAAG,CAAC,CAAC,EAAEd,QAAQ,EAAEK,OAAOU,UAAU,EAAgB,EAAEC;gBAChE,MAAMC,YAAYF,WAAWG,WAAW;gBACxC,MAAMC,OAAOxC,WAAWsC,WAAWhC;gBACnC,MAAMmC,SAASzB,WAAWS,QAAQ,CAACW;gBAEnC,qBACE,MAACJ;oBAAGD,WAAU;;sCACZ,MAACD;4BACCC,WAAW,GAAG5B,UAAU,mBAAmB,CAAC;4BAC5CuC,SAAS,IAAMd,YAAYQ;4BAC3BO,OAAO;gCAAEC,QAAQ;4BAAU;;gCAE1BJ,sBAAQ,KAACA;oCAAKN,MAAM;;gCACpB9C,eAAegD,YAAYvB;8CAC5B,KAACiB;oCAAIC,WAAU;8CACZU,uBAAS,KAAC/C;wCAAYwC,MAAM;uDAAS,KAACvC;wCAAauC,MAAM;;;;;wBAG7DO,UACCpB,SAASc,GAAG,CAAC,CAAC,EAAEX,IAAI,EAAEqB,IAAI,EAAEnB,KAAK,EAAO;4BACtC,IAAIO,OAAsB;4BAC1B,IAAIY,SAASrD,WAAWsD,UAAU,EAAE;gCAClCb,OAAOxC,eAAe;oCACpBmB;oCACAmC,MAAM,CAAC,aAAa,EAAEvB,MAAM;gCAC9B;4BACF,OAAO,IAAIqB,SAASrD,WAAWwD,MAAM,EAAE;gCACrCf,OAAOxC,eAAe;oCACpBmB;oCACAmC,MAAM,CAAC,SAAS,EAAEvB,MAAM;gCAC1B;4BACF;4BACA,MAAMyB,WAAWjD,WAAWwB,MAAMjB;4BAElC,qBACE,KAAClB;gCACC0C,WAAW,GAAG5B,UAAU,sBAAsB,EAAEK,aAAayB,OAAO,WAAW,IAAI;gCACnFA,MAAMA,QAAQ;0CAGd,cAAA,MAACH;oCAAIa,OAAO;wCAAEO,YAAY;wCAAUC,SAAS;wCAAQC,KAAK;oCAAM;;wCAC7DH,0BAAY,KAACA;4CAASf,MAAM;;wCAC5B9C,eAAesC,OAAOb;;;+BAJpBW;wBAQX;;mBAxCuBa;YA2C/B;;;AAGN,EAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ServerProps } from 'payload';
|
|
2
|
+
import './Nav.scss';
|
|
3
|
+
type NavProps = {
|
|
4
|
+
groupsConfig?: Record<string, {
|
|
5
|
+
icon?: string;
|
|
6
|
+
}>;
|
|
7
|
+
itemsConfig?: Record<string, {
|
|
8
|
+
icon?: string;
|
|
9
|
+
}>;
|
|
10
|
+
} & ServerProps;
|
|
11
|
+
declare const Nav: (props: NavProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default Nav;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Logout } from '@payloadcms/ui';
|
|
3
|
+
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
4
|
+
import { EntityType, groupNavItems } from '@payloadcms/ui/shared';
|
|
5
|
+
import { NavClient } from './Nav.client.js';
|
|
6
|
+
import './Nav.scss';
|
|
7
|
+
import { NavWrapper } from './NavWrapper.js';
|
|
8
|
+
const baseClass = 'nav';
|
|
9
|
+
const Nav = (props)=>{
|
|
10
|
+
const { documentSubViewType, groupsConfig, i18n, itemsConfig, locale, params, payload, permissions, searchParams, user, viewType, visibleEntities } = props;
|
|
11
|
+
const { admin: { components: { afterNavLinks, beforeNavLinks, logout } }, collections, globals } = payload.config;
|
|
12
|
+
const LogoutComponent = RenderServerComponent({
|
|
13
|
+
clientProps: {
|
|
14
|
+
documentSubViewType,
|
|
15
|
+
viewType
|
|
16
|
+
},
|
|
17
|
+
Component: logout?.Button,
|
|
18
|
+
Fallback: Logout,
|
|
19
|
+
importMap: payload.importMap,
|
|
20
|
+
serverProps: {
|
|
21
|
+
i18n,
|
|
22
|
+
locale,
|
|
23
|
+
params,
|
|
24
|
+
payload,
|
|
25
|
+
permissions,
|
|
26
|
+
searchParams,
|
|
27
|
+
user
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const groups = groupNavItems([
|
|
31
|
+
...collections.filter(({ slug })=>visibleEntities?.collections.includes(slug)).map((collection)=>({
|
|
32
|
+
type: EntityType.collection,
|
|
33
|
+
entity: collection
|
|
34
|
+
})),
|
|
35
|
+
...globals.filter(({ slug })=>visibleEntities?.globals.includes(slug)).map((global)=>({
|
|
36
|
+
type: EntityType.global,
|
|
37
|
+
entity: global
|
|
38
|
+
}))
|
|
39
|
+
], permissions, i18n);
|
|
40
|
+
return /*#__PURE__*/ _jsxs(NavWrapper, {
|
|
41
|
+
baseClass: baseClass,
|
|
42
|
+
children: [
|
|
43
|
+
RenderServerComponent({
|
|
44
|
+
clientProps: {
|
|
45
|
+
documentSubViewType,
|
|
46
|
+
viewType
|
|
47
|
+
},
|
|
48
|
+
Component: beforeNavLinks,
|
|
49
|
+
importMap: payload.importMap,
|
|
50
|
+
serverProps: {
|
|
51
|
+
i18n,
|
|
52
|
+
locale,
|
|
53
|
+
params,
|
|
54
|
+
payload,
|
|
55
|
+
permissions,
|
|
56
|
+
searchParams,
|
|
57
|
+
user
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ _jsx(NavClient, {
|
|
61
|
+
groups: groups,
|
|
62
|
+
groupsConfig: groupsConfig,
|
|
63
|
+
itemsConfig: itemsConfig
|
|
64
|
+
}),
|
|
65
|
+
RenderServerComponent({
|
|
66
|
+
clientProps: {
|
|
67
|
+
documentSubViewType,
|
|
68
|
+
viewType
|
|
69
|
+
},
|
|
70
|
+
Component: afterNavLinks,
|
|
71
|
+
importMap: payload.importMap,
|
|
72
|
+
serverProps: {
|
|
73
|
+
i18n,
|
|
74
|
+
locale,
|
|
75
|
+
params,
|
|
76
|
+
payload,
|
|
77
|
+
permissions,
|
|
78
|
+
searchParams,
|
|
79
|
+
user
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ _jsx("div", {
|
|
83
|
+
className: `${baseClass}__controls`,
|
|
84
|
+
children: LogoutComponent
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
export default Nav;
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=Nav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/Nav.tsx"],"sourcesContent":["import type { EntityToGroup } from '@payloadcms/ui/shared'\nimport type { ServerProps } from 'payload'\n\nimport { Logout } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { EntityType, groupNavItems } from '@payloadcms/ui/shared'\n\nimport { NavClient } from './Nav.client.js'\nimport './Nav.scss'\nimport { NavWrapper } from './NavWrapper.js'\n\nconst baseClass = 'nav'\n\ntype NavProps = {\n groupsConfig?: Record<string, { icon?: string }>\n itemsConfig?: Record<string, { icon?: string }>\n} & ServerProps\n\nconst Nav = (props: NavProps) => {\n const {\n documentSubViewType,\n groupsConfig,\n i18n,\n itemsConfig,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n viewType,\n visibleEntities,\n } = props\n const {\n admin: {\n components: { afterNavLinks, beforeNavLinks, logout },\n },\n collections,\n globals,\n } = payload.config\n const LogoutComponent = RenderServerComponent({\n clientProps: {\n documentSubViewType,\n viewType,\n },\n Component: logout?.Button,\n Fallback: Logout,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n },\n })\n\n const groups = groupNavItems(\n [\n ...collections\n .filter(({ slug }) => visibleEntities?.collections.includes(slug))\n .map(\n (collection) =>\n ({\n type: EntityType.collection,\n entity: collection,\n }) satisfies EntityToGroup,\n ),\n ...globals\n .filter(({ slug }) => visibleEntities?.globals.includes(slug))\n .map(\n (global) =>\n ({\n type: EntityType.global,\n entity: global,\n }) satisfies EntityToGroup,\n ),\n ],\n permissions as any,\n i18n,\n )\n\n return (\n <NavWrapper baseClass={baseClass}>\n {RenderServerComponent({\n clientProps: {\n documentSubViewType,\n viewType,\n },\n Component: beforeNavLinks,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n },\n })}\n <NavClient groups={groups} groupsConfig={groupsConfig} itemsConfig={itemsConfig} />\n {RenderServerComponent({\n clientProps: {\n documentSubViewType,\n viewType,\n },\n Component: afterNavLinks,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n },\n })}\n <div className={`${baseClass}__controls`}>{LogoutComponent}</div>\n </NavWrapper>\n )\n}\n\nexport default Nav\n"],"names":["Logout","RenderServerComponent","EntityType","groupNavItems","NavClient","NavWrapper","baseClass","Nav","props","documentSubViewType","groupsConfig","i18n","itemsConfig","locale","params","payload","permissions","searchParams","user","viewType","visibleEntities","admin","components","afterNavLinks","beforeNavLinks","logout","collections","globals","config","LogoutComponent","clientProps","Component","Button","Fallback","importMap","serverProps","groups","filter","slug","includes","map","collection","type","entity","global","div","className"],"mappings":";AAGA,SAASA,MAAM,QAAQ,iBAAgB;AACvC,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAuB;AAEjE,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,OAAO,aAAY;AACnB,SAASC,UAAU,QAAQ,kBAAiB;AAE5C,MAAMC,YAAY;AAOlB,MAAMC,MAAM,CAACC;IACX,MAAM,EACJC,mBAAmB,EACnBC,YAAY,EACZC,IAAI,EACJC,WAAW,EACXC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,eAAe,EAChB,GAAGZ;IACJ,MAAM,EACJa,OAAO,EACLC,YAAY,EAAEC,aAAa,EAAEC,cAAc,EAAEC,MAAM,EAAE,EACtD,EACDC,WAAW,EACXC,OAAO,EACR,GAAGZ,QAAQa,MAAM;IAClB,MAAMC,kBAAkB5B,sBAAsB;QAC5C6B,aAAa;YACXrB;YACAU;QACF;QACAY,WAAWN,QAAQO;QACnBC,UAAUjC;QACVkC,WAAWnB,QAAQmB,SAAS;QAC5BC,aAAa;YACXxB;YACAE;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,MAAMkB,SAASjC,cACb;WACKuB,YACAW,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKlB,iBAAiBM,YAAYa,SAASD,OAC3DE,GAAG,CACF,CAACC,aACE,CAAA;gBACCC,MAAMxC,WAAWuC,UAAU;gBAC3BE,QAAQF;YACV,CAAA;WAEHd,QACAU,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKlB,iBAAiBO,QAAQY,SAASD,OACvDE,GAAG,CACF,CAACI,SACE,CAAA;gBACCF,MAAMxC,WAAW0C,MAAM;gBACvBD,QAAQC;YACV,CAAA;KAEP,EACD5B,aACAL;IAGF,qBACE,MAACN;QAAWC,WAAWA;;YACpBL,sBAAsB;gBACrB6B,aAAa;oBACXrB;oBACAU;gBACF;gBACAY,WAAWP;gBACXU,WAAWnB,QAAQmB,SAAS;gBAC5BC,aAAa;oBACXxB;oBACAE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;YACF;0BACA,KAACd;gBAAUgC,QAAQA;gBAAQ1B,cAAcA;gBAAcE,aAAaA;;YACnEX,sBAAsB;gBACrB6B,aAAa;oBACXrB;oBACAU;gBACF;gBACAY,WAAWR;gBACXW,WAAWnB,QAAQmB,SAAS;gBAC5BC,aAAa;oBACXxB;oBACAE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;YACF;0BACA,KAAC2B;gBAAIC,WAAW,GAAGxC,UAAU,UAAU,CAAC;0BAAGuB;;;;AAGjD;AAEA,eAAetB,IAAG"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
$text-color: var(--theme-text, #333);
|
|
2
|
+
$hover-bg: var(--theme-elevation-50, rgba(128, 128, 128, 0.1));
|
|
3
|
+
$active-bg: var(--theme-elevation-100, rgba(128, 128, 128, 0.2));
|
|
4
|
+
$border-radius: 6px;
|
|
5
|
+
|
|
6
|
+
.nav {
|
|
7
|
+
&__link {
|
|
8
|
+
display: flex;
|
|
9
|
+
border-radius: $border-radius;
|
|
10
|
+
transition:
|
|
11
|
+
background-color 0.2s ease,
|
|
12
|
+
color 0.2s ease;
|
|
13
|
+
text-decoration: none;
|
|
14
|
+
color: $text-color;
|
|
15
|
+
|
|
16
|
+
&:focus:not(:focus-visible) {
|
|
17
|
+
box-shadow: none;
|
|
18
|
+
font-weight: 600;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
background-color: $hover-bg;
|
|
23
|
+
text-decoration: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.active {
|
|
27
|
+
font-weight: 600;
|
|
28
|
+
background-color: $active-bg;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
.menu {
|
|
32
|
+
list-style: none;
|
|
33
|
+
padding: 0;
|
|
34
|
+
margin: 0;
|
|
35
|
+
|
|
36
|
+
li {
|
|
37
|
+
margin-bottom: 5px;
|
|
38
|
+
|
|
39
|
+
a {
|
|
40
|
+
display: block;
|
|
41
|
+
padding: 5px 7px;
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&.group {
|
|
46
|
+
.sub-menu {
|
|
47
|
+
// display: none;
|
|
48
|
+
padding-left: 15px;
|
|
49
|
+
list-style: none;
|
|
50
|
+
|
|
51
|
+
li a {
|
|
52
|
+
font-size: 13px;
|
|
53
|
+
padding: 8px;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.group-toggle {
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
gap: 6px;
|
|
61
|
+
padding: 5px 7px;
|
|
62
|
+
|
|
63
|
+
.group-chevron {
|
|
64
|
+
margin-left: auto;
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
opacity: 0.5;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.sub-group-list {
|
|
72
|
+
margin-left: 12px;
|
|
73
|
+
margin-top: 5px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&.open .sub-menu {
|
|
77
|
+
display: block;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ServerProps } from "payload";
|
|
2
|
+
export type NavWithGroupsProps = {
|
|
3
|
+
groupsConfig?: Record<string, {
|
|
4
|
+
icon: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}>;
|
|
7
|
+
} & ServerProps;
|
|
8
|
+
export declare const NavWithGroups: (props: NavWithGroupsProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default NavWithGroups;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Nav from "./Nav.js";
|
|
3
|
+
export const NavWithGroups = (props)=>{
|
|
4
|
+
return /*#__PURE__*/ _jsx(Nav, {
|
|
5
|
+
...props,
|
|
6
|
+
groupsConfig: props.groupsConfig
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export default NavWithGroups;
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=NavWithGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/NavWithGroups.tsx"],"sourcesContent":["import type { ServerProps } from \"payload\";\n\nimport Nav from \"./Nav.js\";\n\nexport type NavWithGroupsProps = {\n groupsConfig?: Record<string, { icon: string; name: string }>;\n} & ServerProps;\n\nexport const NavWithGroups = (props: NavWithGroupsProps) => {\n return <Nav {...props} groupsConfig={props.groupsConfig} />;\n};\n\nexport default NavWithGroups;\n"],"names":["Nav","NavWithGroups","props","groupsConfig"],"mappings":";AAEA,OAAOA,SAAS,WAAW;AAM3B,OAAO,MAAMC,gBAAgB,CAACC;IAC1B,qBAAO,KAACF;QAAK,GAAGE,KAAK;QAAEC,cAAcD,MAAMC,YAAY;;AAC3D,EAAE;AAEF,eAAeF,cAAc"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useNav } from "@payloadcms/ui";
|
|
4
|
+
import React from "react";
|
|
5
|
+
export const NavWrapper = (props)=>{
|
|
6
|
+
const { baseClass, children } = props;
|
|
7
|
+
const { hydrated, navOpen, navRef, shouldAnimate } = useNav();
|
|
8
|
+
return /*#__PURE__*/ _jsx("aside", {
|
|
9
|
+
className: [
|
|
10
|
+
baseClass,
|
|
11
|
+
navOpen && `${baseClass}--nav-open`,
|
|
12
|
+
shouldAnimate && `${baseClass}--nav-animate`,
|
|
13
|
+
hydrated && `${baseClass}--nav-hydrated`
|
|
14
|
+
].filter(Boolean).join(" "),
|
|
15
|
+
inert: !navOpen ? true : undefined,
|
|
16
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
17
|
+
className: `${baseClass}__scroll`,
|
|
18
|
+
ref: navRef,
|
|
19
|
+
children: children
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=NavWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/NavWrapper.tsx"],"sourcesContent":["\"use client\";\nimport { useNav } from \"@payloadcms/ui\";\nimport React from \"react\";\n\nexport const NavWrapper: React.FC<{\n baseClass?: string;\n children: React.ReactNode;\n}> = (props) => {\n const { baseClass, children } = props;\n\n const { hydrated, navOpen, navRef, shouldAnimate } = useNav();\n\n return (\n <aside\n className={[\n baseClass,\n navOpen && `${baseClass}--nav-open`,\n shouldAnimate && `${baseClass}--nav-animate`,\n hydrated && `${baseClass}--nav-hydrated`,\n ]\n .filter(Boolean)\n .join(\" \")}\n inert={!navOpen ? true : undefined}\n >\n <div className={`${baseClass}__scroll`} ref={navRef}>\n {children}\n </div>\n </aside>\n );\n};\n"],"names":["useNav","React","NavWrapper","props","baseClass","children","hydrated","navOpen","navRef","shouldAnimate","aside","className","filter","Boolean","join","inert","undefined","div","ref"],"mappings":"AAAA;;AACA,SAASA,MAAM,QAAQ,iBAAiB;AACxC,OAAOC,WAAW,QAAQ;AAE1B,OAAO,MAAMC,aAGR,CAACC;IACF,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGF;IAEhC,MAAM,EAAEG,QAAQ,EAAEC,OAAO,EAAEC,MAAM,EAAEC,aAAa,EAAE,GAAGT;IAErD,qBACI,KAACU;QACGC,WAAW;YACPP;YACAG,WAAW,GAAGH,UAAU,UAAU,CAAC;YACnCK,iBAAiB,GAAGL,UAAU,aAAa,CAAC;YAC5CE,YAAY,GAAGF,UAAU,cAAc,CAAC;SAC3C,CACIQ,MAAM,CAACC,SACPC,IAAI,CAAC;QACVC,OAAO,CAACR,UAAU,OAAOS;kBAEzB,cAAA,KAACC;YAAIN,WAAW,GAAGP,UAAU,QAAQ,CAAC;YAAEc,KAAKV;sBACxCH;;;AAIjB,EAAE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as LucideIcons from "lucide-react";
|
|
2
|
+
export const getNavIcon = (slug, config)=>{
|
|
3
|
+
if (config?.[slug]) {
|
|
4
|
+
const iconName = config[slug].icon;
|
|
5
|
+
if (iconName) {
|
|
6
|
+
const IconComponent = LucideIcons[iconName];
|
|
7
|
+
if (IconComponent) {
|
|
8
|
+
return IconComponent;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=get-nav-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/get-nav-icon.ts"],"sourcesContent":["import type { LucideProps } from \"lucide-react\";\nimport type { ExoticComponent } from \"react\";\n\nimport * as LucideIcons from \"lucide-react\";\n\nexport const getNavIcon = (\n slug: string,\n config?: Record<string, { icon?: string }>\n): ExoticComponent<LucideProps> | undefined => {\n if (config?.[slug]) {\n const iconName = config[slug].icon;\n if (iconName) {\n const IconComponent = (LucideIcons as unknown as Record<string, ExoticComponent<LucideProps>>)[iconName];\n if (IconComponent) {\n return IconComponent;\n }\n }\n }\n\n return undefined;\n};\n"],"names":["LucideIcons","getNavIcon","slug","config","iconName","icon","IconComponent","undefined"],"mappings":"AAGA,YAAYA,iBAAiB,eAAe;AAE5C,OAAO,MAAMC,aAAa,CACtBC,MACAC;IAEA,IAAIA,QAAQ,CAACD,KAAK,EAAE;QAChB,MAAME,WAAWD,MAAM,CAACD,KAAK,CAACG,IAAI;QAClC,IAAID,UAAU;YACV,MAAME,gBAAgB,AAACN,WAAuE,CAACI,SAAS;YACxG,IAAIE,eAAe;gBACf,OAAOA;YACX;QACJ;IACJ;IAEA,OAAOC;AACX,EAAE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EntityType, NavGroupType } from "@payloadcms/ui/shared";
|
|
2
|
+
import type { StaticLabel } from "payload";
|
|
3
|
+
type IEntityType = {
|
|
4
|
+
label: StaticLabel;
|
|
5
|
+
slug: string;
|
|
6
|
+
type: EntityType;
|
|
7
|
+
};
|
|
8
|
+
export declare const getActiveGroup: (pathname: string, adminRoute: string) => string;
|
|
9
|
+
export declare const getSortedGroups: (groups: NavGroupType[]) => NavGroupType[];
|
|
10
|
+
export declare const getFilteredEntities: (entities: IEntityType[], groupSlug: string) => IEntityType[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const getActiveGroup = (pathname, adminRoute)=>pathname.replace(adminRoute, "").replace("/collections", "").replace("/globals", "").split("/")[1];
|
|
2
|
+
export const getSortedGroups = (groups)=>groups.sort((a, b)=>a.label === "Settings" ? 1 : b.label === "Settings" ? -1 : 0);
|
|
3
|
+
export const getFilteredEntities = (entities, groupSlug)=>{
|
|
4
|
+
return entities.filter((el)=>el.slug !== groupSlug);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=nav-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Nav/nav-utils.ts"],"sourcesContent":["import type { EntityType, NavGroupType } from \"@payloadcms/ui/shared\";\nimport type { StaticLabel } from \"payload\";\n\ntype IEntityType = {\n label: StaticLabel;\n slug: string;\n type: EntityType;\n};\n\nexport const getActiveGroup = (pathname: string, adminRoute: string) =>\n pathname\n .replace(adminRoute, \"\")\n .replace(\"/collections\", \"\")\n .replace(\"/globals\", \"\")\n .split(\"/\")[1];\n\nexport const getSortedGroups = (groups: NavGroupType[]) =>\n groups.sort((a, b) =>\n a.label === \"Settings\" ? 1 : b.label === \"Settings\" ? -1 : 0\n );\n\nexport const getFilteredEntities = (\n entities: IEntityType[],\n groupSlug: string\n) => {\n return entities.filter((el) => el.slug !== groupSlug);\n};\n"],"names":["getActiveGroup","pathname","adminRoute","replace","split","getSortedGroups","groups","sort","a","b","label","getFilteredEntities","entities","groupSlug","filter","el","slug"],"mappings":"AASA,OAAO,MAAMA,iBAAiB,CAACC,UAAkBC,aAC7CD,SACKE,OAAO,CAACD,YAAY,IACpBC,OAAO,CAAC,gBAAgB,IACxBA,OAAO,CAAC,YAAY,IACpBC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;AAEvB,OAAO,MAAMC,kBAAkB,CAACC,SAC5BA,OAAOC,IAAI,CAAC,CAACC,GAAGC,IACZD,EAAEE,KAAK,KAAK,aAAa,IAAID,EAAEC,KAAK,KAAK,aAAa,CAAC,IAAI,GAC7D;AAEN,OAAO,MAAMC,sBAAsB,CAC/BC,UACAC;IAEA,OAAOD,SAASE,MAAM,CAAC,CAACC,KAAOA,GAAGC,IAAI,KAAKH;AAC/C,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/endpoints/customEndpointHandler.ts"],"sourcesContent":["import type { PayloadHandler } from 'payload'\n\nexport const customEndpointHandler: PayloadHandler = () => {\n return Response.json({ message: 'Hello from custom endpoint' })\n}\n"],"names":["customEndpointHandler","Response","json","message"],"mappings":"AAEA,OAAO,MAAMA,wBAAwC;IACnD,OAAOC,SAASC,IAAI,CAAC;QAAEC,SAAS;IAA6B;AAC/D,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NavClient } from '../components/Nav/Nav.client.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { NavClient } from '../components/Nav/Nav.client.js'\n"],"names":["NavClient"],"mappings":"AAAA,SAASA,SAAS,QAAQ,kCAAiC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/rsc.ts"],"sourcesContent":["export { default as Nav } from '../components/Nav/Nav.js'\nexport { default as NavWithGroups } from '../components/Nav/NavWithGroups.js'\n"],"names":["default","Nav","NavWithGroups"],"mappings":"AAAA,SAASA,WAAWC,GAAG,QAAQ,2BAA0B;AACzD,SAASD,WAAWE,aAAa,QAAQ,qCAAoC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config } from "payload";
|
|
2
|
+
export type SidebarPluginConfig = {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
groups?: Record<string, {
|
|
5
|
+
icon?: string;
|
|
6
|
+
}>;
|
|
7
|
+
items?: Record<string, {
|
|
8
|
+
icon?: string;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
export declare const advancedSidebarPlugin: (pluginConfig?: SidebarPluginConfig) => (config: Config) => Config;
|
|
12
|
+
export default advancedSidebarPlugin;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const advancedSidebarPlugin = (pluginConfig = {})=>{
|
|
2
|
+
return (config)=>{
|
|
3
|
+
if (pluginConfig.enabled === false) {
|
|
4
|
+
return config;
|
|
5
|
+
}
|
|
6
|
+
config.admin = {
|
|
7
|
+
...config.admin ?? {},
|
|
8
|
+
components: {
|
|
9
|
+
...config.admin?.components ?? {},
|
|
10
|
+
Nav: {
|
|
11
|
+
clientProps: {
|
|
12
|
+
groupsConfig: pluginConfig.groups,
|
|
13
|
+
itemsConfig: pluginConfig.items
|
|
14
|
+
},
|
|
15
|
+
path: "advanced-sidebar-plugin/rsc#NavWithGroups"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return config;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default advancedSidebarPlugin;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Config } from \"payload\";\n\nexport type SidebarPluginConfig = {\n enabled?: boolean;\n groups?: Record<string, { icon?: string }>;\n items?: Record<string, { icon?: string }>;\n};\n\nexport const advancedSidebarPlugin = (pluginConfig: SidebarPluginConfig = {}) => {\n return (config: Config): Config => {\n if (pluginConfig.enabled === false) {\n return config;\n }\n\n config.admin = {\n ...(config.admin ?? {}),\n components: {\n ...(config.admin?.components ?? {}),\n Nav: {\n clientProps: {\n groupsConfig: pluginConfig.groups,\n itemsConfig: pluginConfig.items,\n },\n path: \"advanced-sidebar-plugin/rsc#NavWithGroups\",\n },\n },\n };\n\n return config;\n };\n};\n\nexport default advancedSidebarPlugin;\n"],"names":["advancedSidebarPlugin","pluginConfig","config","enabled","admin","components","Nav","clientProps","groupsConfig","groups","itemsConfig","items","path"],"mappings":"AAQA,OAAO,MAAMA,wBAAwB,CAACC,eAAoC,CAAC,CAAC;IACxE,OAAO,CAACC;QACJ,IAAID,aAAaE,OAAO,KAAK,OAAO;YAChC,OAAOD;QACX;QAEAA,OAAOE,KAAK,GAAG;YACX,GAAIF,OAAOE,KAAK,IAAI,CAAC,CAAC;YACtBC,YAAY;gBACR,GAAIH,OAAOE,KAAK,EAAEC,cAAc,CAAC,CAAC;gBAClCC,KAAK;oBACDC,aAAa;wBACTC,cAAcP,aAAaQ,MAAM;wBACjCC,aAAaT,aAAaU,KAAK;oBACnC;oBACAC,MAAM;gBACV;YACJ;QACJ;QAEA,OAAOV;IACX;AACJ,EAAE;AAEF,eAAeF,sBAAsB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "payload-advanced-sidebar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Payload CMS 3.0 plugin to customize the admin sidebar with grouping, custom icons, and hide functionality.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"payload",
|
|
7
|
+
"payloadcms",
|
|
8
|
+
"plugin",
|
|
9
|
+
"sidebar",
|
|
10
|
+
"navigation",
|
|
11
|
+
"customization",
|
|
12
|
+
"admin"
|
|
13
|
+
],
|
|
14
|
+
"author": "Mahmoud Hassan",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/Mhmod-Hsn/payload-advanced-sidebar.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Mhmod-Hsn/payload-advanced-sidebar/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/Mhmod-Hsn/payload-advanced-sidebar#readme",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": "./src/index.ts",
|
|
28
|
+
"types": "./src/index.ts",
|
|
29
|
+
"default": "./src/index.ts"
|
|
30
|
+
},
|
|
31
|
+
"./client": {
|
|
32
|
+
"import": "./src/exports/client.ts",
|
|
33
|
+
"types": "./src/exports/client.ts",
|
|
34
|
+
"default": "./src/exports/client.ts"
|
|
35
|
+
},
|
|
36
|
+
"./rsc": {
|
|
37
|
+
"import": "./src/exports/rsc.ts",
|
|
38
|
+
"types": "./src/exports/rsc.ts",
|
|
39
|
+
"default": "./src/exports/rsc.ts"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"main": "./src/index.ts",
|
|
43
|
+
"types": "./src/index.ts",
|
|
44
|
+
"files": [
|
|
45
|
+
"dist"
|
|
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
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
67
|
+
"@payloadcms/db-mongodb": "3.84.1",
|
|
68
|
+
"@payloadcms/db-postgres": "3.84.1",
|
|
69
|
+
"@payloadcms/db-sqlite": "3.84.1",
|
|
70
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
71
|
+
"@payloadcms/next": "3.84.1",
|
|
72
|
+
"@payloadcms/richtext-lexical": "3.84.1",
|
|
73
|
+
"@payloadcms/translations": "^3.85.0",
|
|
74
|
+
"@payloadcms/ui": "3.84.1",
|
|
75
|
+
"@playwright/test": "1.58.2",
|
|
76
|
+
"@swc-node/register": "1.10.9",
|
|
77
|
+
"@swc/cli": "0.6.0",
|
|
78
|
+
"@types/node": "22.19.9",
|
|
79
|
+
"@types/react": "19.2.14",
|
|
80
|
+
"@types/react-dom": "19.2.3",
|
|
81
|
+
"copyfiles": "2.4.1",
|
|
82
|
+
"cross-env": "^7.0.3",
|
|
83
|
+
"eslint": "^9.23.0",
|
|
84
|
+
"eslint-config-next": "16.2.6",
|
|
85
|
+
"graphql": "^16.8.1",
|
|
86
|
+
"lucide-react": "^1.17.0",
|
|
87
|
+
"mongodb-memory-server": "10.1.4",
|
|
88
|
+
"next": "16.2.6",
|
|
89
|
+
"open": "^10.1.0",
|
|
90
|
+
"payload": "3.84.1",
|
|
91
|
+
"prettier": "^3.4.2",
|
|
92
|
+
"qs-esm": "8.0.1",
|
|
93
|
+
"react": "19.2.6",
|
|
94
|
+
"react-dom": "19.2.6",
|
|
95
|
+
"rimraf": "3.0.2",
|
|
96
|
+
"sass": "^1.100.0",
|
|
97
|
+
"sharp": "0.34.2",
|
|
98
|
+
"sort-package-json": "^2.10.0",
|
|
99
|
+
"typescript": "5.7.3",
|
|
100
|
+
"vite-tsconfig-paths": "6.0.5",
|
|
101
|
+
"vitest": "4.0.18"
|
|
102
|
+
},
|
|
103
|
+
"peerDependencies": {
|
|
104
|
+
"payload": "^3.84.1"
|
|
105
|
+
},
|
|
106
|
+
"engines": {
|
|
107
|
+
"node": "^18.20.2 || >=20.9.0",
|
|
108
|
+
"pnpm": "^9 || ^10"
|
|
109
|
+
},
|
|
110
|
+
"publishConfig": {
|
|
111
|
+
"exports": {
|
|
112
|
+
".": {
|
|
113
|
+
"import": "./dist/index.js",
|
|
114
|
+
"types": "./dist/index.d.ts",
|
|
115
|
+
"default": "./dist/index.js"
|
|
116
|
+
},
|
|
117
|
+
"./client": {
|
|
118
|
+
"import": "./dist/exports/client.js",
|
|
119
|
+
"types": "./dist/exports/client.d.ts",
|
|
120
|
+
"default": "./dist/exports/client.js"
|
|
121
|
+
},
|
|
122
|
+
"./rsc": {
|
|
123
|
+
"import": "./dist/exports/rsc.js",
|
|
124
|
+
"types": "./dist/exports/rsc.d.ts",
|
|
125
|
+
"default": "./dist/exports/rsc.js"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"main": "./dist/index.js",
|
|
129
|
+
"types": "./dist/index.d.ts"
|
|
130
|
+
},
|
|
131
|
+
"pnpm": {
|
|
132
|
+
"onlyBuiltDependencies": [
|
|
133
|
+
"sharp",
|
|
134
|
+
"esbuild",
|
|
135
|
+
"unrs-resolver"
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
"registry": "https://registry.npmjs.org/"
|
|
139
|
+
}
|