@veiag/payload-enhanced-sidebar 0.3.0-beta.2 → 0.3.0-beta.4
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 +59 -0
- package/dist/components/EnhancedSidebar/InternalBadgeProvider/index.js +1 -1
- package/dist/components/EnhancedSidebar/InternalBadgeProvider/index.js.map +1 -1
- package/dist/components/EnhancedSidebar/SidebarContent.d.ts +1 -0
- package/dist/components/EnhancedSidebar/SidebarContent.js +2 -1
- package/dist/components/EnhancedSidebar/SidebarContent.js.map +1 -1
- package/dist/components/EnhancedSidebar/TabsBar/index.d.ts +1 -0
- package/dist/components/EnhancedSidebar/TabsBar/index.js +4 -1
- package/dist/components/EnhancedSidebar/TabsBar/index.js.map +1 -1
- package/dist/components/EnhancedSidebar/index.js +29 -3
- package/dist/components/EnhancedSidebar/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +29 -11
- package/dist/types.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,6 +164,7 @@ Array of tabs and links to show in the sidebar.
|
|
|
164
164
|
| `globals` | `GlobalSlug[]` | No | Globals to show in this tab |
|
|
165
165
|
| `customItems` | `SidebarTabItem[]` | No | Custom navigation items (see below) |
|
|
166
166
|
| `badge` | `BadgeConfig` | No | Badge configuration for the tab icon |
|
|
167
|
+
| `access` | `TabAccessFunction` | No | Server-side access control — return `false` to hide |
|
|
167
168
|
|
|
168
169
|
> \* Exactly one of `icon` or `iconComponent` is required — they are mutually exclusive.
|
|
169
170
|
> If neither `collections` nor `globals` are specified, the tab shows all collections and globals.
|
|
@@ -181,9 +182,30 @@ Array of tabs and links to show in the sidebar.
|
|
|
181
182
|
| `href` | `string` | Yes | URL |
|
|
182
183
|
| `isExternal` | `boolean` | No | If true, `href` is absolute URL, if not, `href` is relative to admin route |
|
|
183
184
|
| `badge` | `BadgeConfig` | No | Badge configuration for the link icon |
|
|
185
|
+
| `access` | `TabAccessFunction` | No | Server-side access control — return `false` to hide |
|
|
184
186
|
|
|
185
187
|
> \* Exactly one of `icon` or `iconComponent` is required — they are mutually exclusive.
|
|
186
188
|
|
|
189
|
+
**Custom slot (`type: 'custom'`)**
|
|
190
|
+
|
|
191
|
+
Renders an arbitrary component in the tabs bar — useful for spacers, separators, decorative elements, etc. Does not open any navigation content.
|
|
192
|
+
|
|
193
|
+
| Property | Type | Required | Description |
|
|
194
|
+
|----------|------|----------|-------------|
|
|
195
|
+
| `id` | `string` | Yes | Unique identifier |
|
|
196
|
+
| `type` | `'custom'` | Yes | Custom slot type |
|
|
197
|
+
| `component` | `SidebarComponent` | Yes | Component to render (string path or `{ path, clientProps }`) |
|
|
198
|
+
| `access` | `TabAccessFunction` | No | Server-side access control — return `false` to hide |
|
|
199
|
+
|
|
200
|
+
The component receives `{ id }` plus any `clientProps` you pass. See [Custom Components](docs/custom-components.md) for details.
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
{
|
|
204
|
+
id: 'separator',
|
|
205
|
+
type: 'custom',
|
|
206
|
+
component: './components/Sidebar#TabSeparator',
|
|
207
|
+
}
|
|
208
|
+
```
|
|
187
209
|
|
|
188
210
|

|
|
189
211
|
|
|
@@ -445,6 +467,43 @@ type ItemAccessFunction = (args: {
|
|
|
445
467
|
|
|
446
468
|
> Default collections and globals already respect Payload's built-in access control — they are filtered by `visibleEntities` automatically. The `access` function is only needed for tabs, links, and custom items.
|
|
447
469
|
|
|
470
|
+
### Behavior when `req` is unavailable
|
|
471
|
+
|
|
472
|
+
Access functions are **fail-closed**: if `req` is not available (e.g. on certain error pages), all items with an `access` function will be hidden. This is a known limitation caused by a [Payload bug](https://github.com/payloadcms/payload/issues) where `req` is not passed to the Nav component on 404 admin pages.
|
|
473
|
+
|
|
474
|
+
### Custom views and access control
|
|
475
|
+
|
|
476
|
+
If you have custom admin views, you must pass `req` to `DefaultTemplate` for access control to work correctly. Retrieve it from `props.initPageResult.req`:
|
|
477
|
+
|
|
478
|
+
```tsx
|
|
479
|
+
import type { AdminViewProps } from 'payload'
|
|
480
|
+
import { DefaultTemplate } from '@payloadcms/next/templates'
|
|
481
|
+
|
|
482
|
+
export async function MyCustomView(props: AdminViewProps) {
|
|
483
|
+
const { initPageResult, params, searchParams } = props
|
|
484
|
+
const { permissions, req, visibleEntities } = initPageResult
|
|
485
|
+
const { i18n, locale, payload, user } = req
|
|
486
|
+
|
|
487
|
+
return (
|
|
488
|
+
<DefaultTemplate
|
|
489
|
+
i18n={i18n}
|
|
490
|
+
locale={locale}
|
|
491
|
+
params={params}
|
|
492
|
+
payload={payload}
|
|
493
|
+
permissions={permissions}
|
|
494
|
+
req={req}
|
|
495
|
+
searchParams={searchParams}
|
|
496
|
+
user={user ?? undefined}
|
|
497
|
+
visibleEntities={visibleEntities}
|
|
498
|
+
>
|
|
499
|
+
{/* your view content */}
|
|
500
|
+
</DefaultTemplate>
|
|
501
|
+
)
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
Without `req={req}`, the sidebar will treat the page as unauthenticated and hide all access-controlled items.
|
|
506
|
+
|
|
448
507
|
### `showLogout`
|
|
449
508
|
|
|
450
509
|
Show/hide the logout button at the bottom of the tabs bar.
|
|
@@ -17,7 +17,7 @@ import { BadgeProvider } from '../BadgeProvider';
|
|
|
17
17
|
// From tabs
|
|
18
18
|
if (sidebarConfig.tabs) {
|
|
19
19
|
for (const tab of sidebarConfig.tabs){
|
|
20
|
-
if (tab.badge && tab.badge.type !== 'provider') {
|
|
20
|
+
if (tab.type !== 'custom' && tab.badge && tab.badge.type !== 'provider') {
|
|
21
21
|
badges.push({
|
|
22
22
|
slug: tab.id,
|
|
23
23
|
config: tab.badge
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/EnhancedSidebar/InternalBadgeProvider/index.tsx"],"sourcesContent":["'use client'\n\nimport { useConfig } from '@payloadcms/ui'\nimport { stringify } from 'qs-esm'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport type { BadgeConfig, BadgeValues, EnhancedSidebarConfig } from '../../../types'\n\nimport { BadgeProvider } from '../BadgeProvider'\n\ntype BadgeToFetch = {\n config: BadgeConfig\n slug: string\n}\n\nexport type InternalBadgeProviderProps = {\n children: React.ReactNode\n /**\n * Sidebar configuration containing badge configs\n */\n sidebarConfig: EnhancedSidebarConfig\n}\n\n/**\n * Internal provider that fetches all API-based badges once on mount.\n * This provider is automatically injected by the plugin.\n * Values are stored in context and don't refetch on navigation.\n */\nexport const InternalBadgeProvider: React.FC<InternalBadgeProviderProps> = ({\n children,\n sidebarConfig,\n}) => {\n const [values, setValues] = useState<BadgeValues>({})\n\n const {\n config: {\n routes: { api: apiRoute },\n serverURL,\n },\n } = useConfig()\n\n // Collect all badges that need to be fetched (api and collection-count types)\n const badgesToFetch = useMemo(() => {\n const badges: BadgeToFetch[] = []\n\n // From tabs\n if (sidebarConfig.tabs) {\n for (const tab of sidebarConfig.tabs) {\n if (tab.badge && tab.badge.type !== 'provider') {\n badges.push({ slug: tab.id, config: tab.badge })\n }\n }\n }\n\n // From badges config\n if (sidebarConfig.badges) {\n for (const [slug, config] of Object.entries(sidebarConfig.badges)) {\n if (config.type !== 'provider') {\n badges.push({ slug, config })\n }\n }\n }\n\n return badges\n }, [sidebarConfig])\n\n // Fetch a single badge value\n const fetchBadge = useCallback(\n async (badge: BadgeToFetch): Promise<{ slug: string; value: number | undefined }> => {\n const { slug, config } = badge\n\n try {\n let url: string\n let responseKey: string\n\n if (config.type === 'api') {\n url = config.endpoint\n responseKey = config.responseKey ?? 'count'\n\n // If endpoint is relative, prepend serverURL\n if (!url.startsWith('http')) {\n url = `${serverURL || ''}${url}`\n }\n } else if (config.type === 'collection-count') {\n const collectionSlug = config.collectionSlug ?? slug\n const baseUrl = `${serverURL || ''}${apiRoute}/${collectionSlug}`\n\n if (config.where) {\n const whereParams = stringify({\n where: config.where,\n })\n url = `${baseUrl}?${whereParams}`\n } else {\n url = `${baseUrl}`\n }\n\n responseKey = 'totalDocs'\n } else {\n return { slug, value: undefined }\n }\n\n const response = await fetch(url, {\n credentials: 'include',\n method: config.type === 'api' ? (config.method ?? 'GET') : 'GET',\n })\n\n if (response.ok) {\n const data = await response.json()\n // Extract value from nested key (e.g., \"data.count\")\n const keys = responseKey.split('.')\n let value = data\n for (const key of keys) {\n value = value?.[key]\n }\n return { slug, value: typeof value === 'number' ? value : undefined }\n }\n } catch (error) {\n //eslint-disable-next-line no-console\n console.error(`Failed to fetch badge data for ${slug}:`, error)\n }\n\n return { slug, value: undefined }\n },\n [apiRoute, serverURL],\n )\n\n // Fetch all badges on mount\n useEffect(() => {\n if (badgesToFetch.length === 0) {\n return\n }\n\n const fetchAll = async () => {\n const results = await Promise.all(badgesToFetch.map(fetchBadge))\n\n const newValues: BadgeValues = {}\n for (const result of results) {\n if (result.value !== undefined) {\n newValues[result.slug] = result.value\n }\n }\n\n setValues(newValues)\n }\n\n fetchAll().catch((err) => {\n //eslint-disable-next-line no-console\n console.error('Error fetching badge data:', err)\n })\n }, [badgesToFetch, fetchBadge])\n\n return <BadgeProvider values={values}>{children}</BadgeProvider>\n}\n"],"names":["useConfig","stringify","React","useCallback","useEffect","useMemo","useState","BadgeProvider","InternalBadgeProvider","children","sidebarConfig","values","setValues","config","routes","api","apiRoute","serverURL","badgesToFetch","badges","tabs","tab","
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/EnhancedSidebar/InternalBadgeProvider/index.tsx"],"sourcesContent":["'use client'\n\nimport { useConfig } from '@payloadcms/ui'\nimport { stringify } from 'qs-esm'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport type { BadgeConfig, BadgeValues, EnhancedSidebarConfig } from '../../../types'\n\nimport { BadgeProvider } from '../BadgeProvider'\n\ntype BadgeToFetch = {\n config: BadgeConfig\n slug: string\n}\n\nexport type InternalBadgeProviderProps = {\n children: React.ReactNode\n /**\n * Sidebar configuration containing badge configs\n */\n sidebarConfig: EnhancedSidebarConfig\n}\n\n/**\n * Internal provider that fetches all API-based badges once on mount.\n * This provider is automatically injected by the plugin.\n * Values are stored in context and don't refetch on navigation.\n */\nexport const InternalBadgeProvider: React.FC<InternalBadgeProviderProps> = ({\n children,\n sidebarConfig,\n}) => {\n const [values, setValues] = useState<BadgeValues>({})\n\n const {\n config: {\n routes: { api: apiRoute },\n serverURL,\n },\n } = useConfig()\n\n // Collect all badges that need to be fetched (api and collection-count types)\n const badgesToFetch = useMemo(() => {\n const badges: BadgeToFetch[] = []\n\n // From tabs\n if (sidebarConfig.tabs) {\n for (const tab of sidebarConfig.tabs) {\n if (tab.type !== 'custom' && tab.badge && tab.badge.type !== 'provider') {\n badges.push({ slug: tab.id, config: tab.badge })\n }\n }\n }\n\n // From badges config\n if (sidebarConfig.badges) {\n for (const [slug, config] of Object.entries(sidebarConfig.badges)) {\n if (config.type !== 'provider') {\n badges.push({ slug, config })\n }\n }\n }\n\n return badges\n }, [sidebarConfig])\n\n // Fetch a single badge value\n const fetchBadge = useCallback(\n async (badge: BadgeToFetch): Promise<{ slug: string; value: number | undefined }> => {\n const { slug, config } = badge\n\n try {\n let url: string\n let responseKey: string\n\n if (config.type === 'api') {\n url = config.endpoint\n responseKey = config.responseKey ?? 'count'\n\n // If endpoint is relative, prepend serverURL\n if (!url.startsWith('http')) {\n url = `${serverURL || ''}${url}`\n }\n } else if (config.type === 'collection-count') {\n const collectionSlug = config.collectionSlug ?? slug\n const baseUrl = `${serverURL || ''}${apiRoute}/${collectionSlug}`\n\n if (config.where) {\n const whereParams = stringify({\n where: config.where,\n })\n url = `${baseUrl}?${whereParams}`\n } else {\n url = `${baseUrl}`\n }\n\n responseKey = 'totalDocs'\n } else {\n return { slug, value: undefined }\n }\n\n const response = await fetch(url, {\n credentials: 'include',\n method: config.type === 'api' ? (config.method ?? 'GET') : 'GET',\n })\n\n if (response.ok) {\n const data = await response.json()\n // Extract value from nested key (e.g., \"data.count\")\n const keys = responseKey.split('.')\n let value = data\n for (const key of keys) {\n value = value?.[key]\n }\n return { slug, value: typeof value === 'number' ? value : undefined }\n }\n } catch (error) {\n //eslint-disable-next-line no-console\n console.error(`Failed to fetch badge data for ${slug}:`, error)\n }\n\n return { slug, value: undefined }\n },\n [apiRoute, serverURL],\n )\n\n // Fetch all badges on mount\n useEffect(() => {\n if (badgesToFetch.length === 0) {\n return\n }\n\n const fetchAll = async () => {\n const results = await Promise.all(badgesToFetch.map(fetchBadge))\n\n const newValues: BadgeValues = {}\n for (const result of results) {\n if (result.value !== undefined) {\n newValues[result.slug] = result.value\n }\n }\n\n setValues(newValues)\n }\n\n fetchAll().catch((err) => {\n //eslint-disable-next-line no-console\n console.error('Error fetching badge data:', err)\n })\n }, [badgesToFetch, fetchBadge])\n\n return <BadgeProvider values={values}>{children}</BadgeProvider>\n}\n"],"names":["useConfig","stringify","React","useCallback","useEffect","useMemo","useState","BadgeProvider","InternalBadgeProvider","children","sidebarConfig","values","setValues","config","routes","api","apiRoute","serverURL","badgesToFetch","badges","tabs","tab","type","badge","push","slug","id","Object","entries","fetchBadge","url","responseKey","endpoint","startsWith","collectionSlug","baseUrl","where","whereParams","value","undefined","response","fetch","credentials","method","ok","data","json","keys","split","key","error","console","length","fetchAll","results","Promise","all","map","newValues","result","catch","err"],"mappings":"AAAA;;AAEA,SAASA,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,SAAS,QAAQ,SAAQ;AAClC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAIxE,SAASC,aAAa,QAAQ,mBAAkB;AAehD;;;;CAIC,GACD,OAAO,MAAMC,wBAA8D,CAAC,EAC1EC,QAAQ,EACRC,aAAa,EACd;IACC,MAAM,CAACC,QAAQC,UAAU,GAAGN,SAAsB,CAAC;IAEnD,MAAM,EACJO,QAAQ,EACNC,QAAQ,EAAEC,KAAKC,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OrB,KAAK;gBACvC;YACF;YAEA1B,UAAU8C;QACZ;QAEAL,WAAWO,KAAK,CAAC,CAACC;YAChB,qCAAqC;YACrCV,QAAQD,KAAK,CAAC,8BAA8BW;QAC9C;IACF,GAAG;QAAC3C;QAAeW;KAAW;IAE9B,qBAAO,KAACtB;QAAcI,QAAQA;kBAASF;;AACzC,EAAC"}
|
|
@@ -5,6 +5,7 @@ export type SidebarContentProps = {
|
|
|
5
5
|
allContent?: React.ReactNode;
|
|
6
6
|
beforeNavLinks?: React.ReactNode;
|
|
7
7
|
customNavContent?: React.ReactNode;
|
|
8
|
+
customTabComponents?: Record<string, React.ReactNode>;
|
|
8
9
|
initialActiveTabId: string;
|
|
9
10
|
renderedTabItems?: React.ReactNode[];
|
|
10
11
|
settingsMenu?: React.ReactNode[];
|
|
@@ -10,7 +10,7 @@ const COOKIE_KEY = 'payload-enhanced-sidebar-active-tab';
|
|
|
10
10
|
const setTabCookie = (tabId)=>{
|
|
11
11
|
document.cookie = `${COOKIE_KEY}=${tabId}; path=/; max-age=31536000; SameSite=Lax`;
|
|
12
12
|
};
|
|
13
|
-
export const SidebarContent = ({ afterNavLinks, allContent, beforeNavLinks, customNavContent, initialActiveTabId, renderedTabItems, settingsMenu, sidebarConfig, tabIcons, tabsContent })=>{
|
|
13
|
+
export const SidebarContent = ({ afterNavLinks, allContent, beforeNavLinks, customNavContent, customTabComponents, initialActiveTabId, renderedTabItems, settingsMenu, sidebarConfig, tabIcons, tabsContent })=>{
|
|
14
14
|
const [activeTabId, setActiveTabId] = useState(initialActiveTabId);
|
|
15
15
|
const handleTabChange = useCallback((tabId)=>{
|
|
16
16
|
setActiveTabId(tabId);
|
|
@@ -31,6 +31,7 @@ export const SidebarContent = ({ afterNavLinks, allContent, beforeNavLinks, cust
|
|
|
31
31
|
children: [
|
|
32
32
|
/*#__PURE__*/ _jsx(TabsBar, {
|
|
33
33
|
activeTabId: activeTabId,
|
|
34
|
+
customTabComponents: customTabComponents,
|
|
34
35
|
onTabChange: handleTabChange,
|
|
35
36
|
renderedTabItems: renderedTabItems,
|
|
36
37
|
settingsMenu: settingsMenu,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/EnhancedSidebar/SidebarContent.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { EnhancedSidebarConfig } from '../../types'\n\nimport { EnhancedSidebarContext } from './context'\nimport { NavContent } from './NavContent'\nimport { SidebarWrapper } from './SidebarWrapper'\nimport { TabsBar } from './TabsBar'\n\nconst baseClass = 'enhanced-sidebar'\n\nexport type SidebarContentProps = {\n afterNavLinks?: React.ReactNode\n allContent?: React.ReactNode\n beforeNavLinks?: React.ReactNode\n customNavContent?: React.ReactNode\n initialActiveTabId: string\n renderedTabItems?: React.ReactNode[]\n settingsMenu?: React.ReactNode[]\n sidebarConfig: EnhancedSidebarConfig\n tabIcons?: Record<string, React.ReactNode>\n tabsContent: Record<string, React.ReactNode>\n}\n\nconst COOKIE_KEY = 'payload-enhanced-sidebar-active-tab'\n\nconst setTabCookie = (tabId: string) => {\n document.cookie = `${COOKIE_KEY}=${tabId}; path=/; max-age=31536000; SameSite=Lax`\n}\n\nexport const SidebarContent: React.FC<SidebarContentProps> = ({\n afterNavLinks,\n allContent,\n beforeNavLinks,\n customNavContent,\n initialActiveTabId,\n renderedTabItems,\n settingsMenu,\n sidebarConfig,\n tabIcons,\n tabsContent,\n}) => {\n const [activeTabId, setActiveTabId] = useState(initialActiveTabId)\n\n const handleTabChange = useCallback((tabId: string) => {\n setActiveTabId(tabId)\n setTabCookie(tabId)\n }, [])\n\n const contextValue = useMemo(\n () => ({ activeTabId, onTabChange: handleTabChange }),\n [activeTabId, handleTabChange],\n )\n\n const tabs = sidebarConfig.tabs?.filter((t) => t.type === 'tab') ?? []\n\n return (\n <EnhancedSidebarContext.Provider value={contextValue}>\n <SidebarWrapper baseClass={baseClass}>\n <TabsBar\n activeTabId={activeTabId}\n onTabChange={handleTabChange}\n renderedTabItems={renderedTabItems}\n settingsMenu={settingsMenu}\n sidebarConfig={sidebarConfig}\n tabIcons={tabIcons}\n />\n {customNavContent ?? (\n <NavContent\n afterNavLinks={afterNavLinks}\n allContent={allContent}\n beforeNavLinks={beforeNavLinks}\n tabs={tabs}\n tabsContent={tabsContent}\n />\n )}\n </SidebarWrapper>\n </EnhancedSidebarContext.Provider>\n )\n}\n"],"names":["React","useCallback","useMemo","useState","EnhancedSidebarContext","NavContent","SidebarWrapper","TabsBar","baseClass","COOKIE_KEY","setTabCookie","tabId","document","cookie","SidebarContent","afterNavLinks","allContent","beforeNavLinks","customNavContent","initialActiveTabId","renderedTabItems","settingsMenu","sidebarConfig","tabIcons","tabsContent","activeTabId","setActiveTabId","handleTabChange","contextValue","onTabChange","tabs","filter","t","type","Provider","value"],"mappings":"AAAA;;AAEA,OAAOA,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAI7D,SAASC,sBAAsB,QAAQ,YAAW;AAClD,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,OAAO,QAAQ,YAAW;AAEnC,MAAMC,YAAY;
|
|
1
|
+
{"version":3,"sources":["../../../src/components/EnhancedSidebar/SidebarContent.tsx"],"sourcesContent":["'use client'\n\nimport React, { useCallback, useMemo, useState } from 'react'\n\nimport type { EnhancedSidebarConfig } from '../../types'\n\nimport { EnhancedSidebarContext } from './context'\nimport { NavContent } from './NavContent'\nimport { SidebarWrapper } from './SidebarWrapper'\nimport { TabsBar } from './TabsBar'\n\nconst baseClass = 'enhanced-sidebar'\n\nexport type SidebarContentProps = {\n afterNavLinks?: React.ReactNode\n allContent?: React.ReactNode\n beforeNavLinks?: React.ReactNode\n customNavContent?: React.ReactNode\n customTabComponents?: Record<string, React.ReactNode>\n initialActiveTabId: string\n renderedTabItems?: React.ReactNode[]\n settingsMenu?: React.ReactNode[]\n sidebarConfig: EnhancedSidebarConfig\n tabIcons?: Record<string, React.ReactNode>\n tabsContent: Record<string, React.ReactNode>\n}\n\nconst COOKIE_KEY = 'payload-enhanced-sidebar-active-tab'\n\nconst setTabCookie = (tabId: string) => {\n document.cookie = `${COOKIE_KEY}=${tabId}; path=/; max-age=31536000; SameSite=Lax`\n}\n\nexport const SidebarContent: React.FC<SidebarContentProps> = ({\n afterNavLinks,\n allContent,\n beforeNavLinks,\n customNavContent,\n customTabComponents,\n initialActiveTabId,\n renderedTabItems,\n settingsMenu,\n sidebarConfig,\n tabIcons,\n tabsContent,\n}) => {\n const [activeTabId, setActiveTabId] = useState(initialActiveTabId)\n\n const handleTabChange = useCallback((tabId: string) => {\n setActiveTabId(tabId)\n setTabCookie(tabId)\n }, [])\n\n const contextValue = useMemo(\n () => ({ activeTabId, onTabChange: handleTabChange }),\n [activeTabId, handleTabChange],\n )\n\n const tabs = sidebarConfig.tabs?.filter((t) => t.type === 'tab') ?? []\n\n return (\n <EnhancedSidebarContext.Provider value={contextValue}>\n <SidebarWrapper baseClass={baseClass}>\n <TabsBar\n activeTabId={activeTabId}\n customTabComponents={customTabComponents}\n onTabChange={handleTabChange}\n renderedTabItems={renderedTabItems}\n settingsMenu={settingsMenu}\n sidebarConfig={sidebarConfig}\n tabIcons={tabIcons}\n />\n {customNavContent ?? (\n <NavContent\n afterNavLinks={afterNavLinks}\n allContent={allContent}\n beforeNavLinks={beforeNavLinks}\n tabs={tabs}\n tabsContent={tabsContent}\n />\n )}\n </SidebarWrapper>\n </EnhancedSidebarContext.Provider>\n )\n}\n"],"names":["React","useCallback","useMemo","useState","EnhancedSidebarContext","NavContent","SidebarWrapper","TabsBar","baseClass","COOKIE_KEY","setTabCookie","tabId","document","cookie","SidebarContent","afterNavLinks","allContent","beforeNavLinks","customNavContent","customTabComponents","initialActiveTabId","renderedTabItems","settingsMenu","sidebarConfig","tabIcons","tabsContent","activeTabId","setActiveTabId","handleTabChange","contextValue","onTabChange","tabs","filter","t","type","Provider","value"],"mappings":"AA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idebarConfig } from '../../../types';
|
|
|
3
3
|
import './index.scss';
|
|
4
4
|
export type TabsBarProps = {
|
|
5
5
|
activeTabId: string;
|
|
6
|
+
customTabComponents?: Record<string, React.ReactNode>;
|
|
6
7
|
onTabChange: (tabId: string) => void;
|
|
7
8
|
renderedTabItems?: React.ReactNode[];
|
|
8
9
|
settingsMenu?: React.ReactNode[];
|
|
@@ -10,7 +10,7 @@ import { SettingsMenuButton } from '../SettingsMenuButton';
|
|
|
10
10
|
import { TabButton, TabLink } from './TabItem';
|
|
11
11
|
import './index.scss';
|
|
12
12
|
const tabsBaseClass = 'tabs-bar';
|
|
13
|
-
export const TabsBar = ({ activeTabId, onTabChange, renderedTabItems, settingsMenu, sidebarConfig, tabIcons })=>{
|
|
13
|
+
export const TabsBar = ({ activeTabId, customTabComponents, onTabChange, renderedTabItems, settingsMenu, sidebarConfig, tabIcons })=>{
|
|
14
14
|
const { i18n } = useTranslation();
|
|
15
15
|
const pathname = usePathname();
|
|
16
16
|
const { config: { admin: { routes: { browseByFolder: foldersRoute, logout: logoutRoute } }, folders, routes: { admin: adminRoute } } } = useConfig();
|
|
@@ -22,6 +22,9 @@ export const TabsBar = ({ activeTabId, onTabChange, renderedTabItems, settingsMe
|
|
|
22
22
|
});
|
|
23
23
|
const isFoldersActive = pathname.startsWith(folderURL);
|
|
24
24
|
const renderTabItem = (item)=>{
|
|
25
|
+
if (item.type === 'custom') {
|
|
26
|
+
return customTabComponents?.[item.id] ?? null;
|
|
27
|
+
}
|
|
25
28
|
if (item.type === 'tab') {
|
|
26
29
|
return /*#__PURE__*/ _jsx(TabButton, {
|
|
27
30
|
icon: tabIcons?.[item.id],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/EnhancedSidebar/TabsBar/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Link, useConfig, useTranslation } from '@payloadcms/ui'\nimport { usePathname } from 'next/navigation'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { EnhancedSidebarConfig, SidebarTabContent, SidebarTabLink } from '../../../types'\n\nimport { Icon } from '../Icon'\nimport { SettingsMenuButton } from '../SettingsMenuButton'\nimport { TabButton, TabLink } from './TabItem'\nimport './index.scss'\n\nconst tabsBaseClass = 'tabs-bar'\n\nexport type TabsBarProps = {\n activeTabId: string\n onTabChange: (tabId: string) => void\n renderedTabItems?: React.ReactNode[]\n settingsMenu?: React.ReactNode[]\n sidebarConfig: EnhancedSidebarConfig\n tabIcons?: Record<string, React.ReactNode>\n}\n\nexport const TabsBar: React.FC<TabsBarProps> = ({\n activeTabId,\n onTabChange,\n renderedTabItems,\n settingsMenu,\n sidebarConfig,\n tabIcons,\n}) => {\n const { i18n } = useTranslation()\n const pathname = usePathname()\n\n const {\n config: {\n admin: {\n routes: { browseByFolder: foldersRoute, logout: logoutRoute },\n },\n folders,\n routes: { admin: adminRoute },\n },\n } = useConfig()\n\n const showLogout = sidebarConfig.showLogout !== false\n const showFolders = folders && folders.browseByFolder\n\n const folderURL = formatAdminURL({\n adminRoute,\n path: foldersRoute,\n })\n const isFoldersActive = pathname.startsWith(folderURL)\n\n const renderTabItem = (item:
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/EnhancedSidebar/TabsBar/index.tsx"],"sourcesContent":["'use client'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Link, useConfig, useTranslation } from '@payloadcms/ui'\nimport { usePathname } from 'next/navigation'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { EnhancedSidebarConfig, SidebarTab, SidebarTabContent, SidebarTabLink } from '../../../types'\n\nimport { Icon } from '../Icon'\nimport { SettingsMenuButton } from '../SettingsMenuButton'\nimport { TabButton, TabLink } from './TabItem'\nimport './index.scss'\n\nconst tabsBaseClass = 'tabs-bar'\n\nexport type TabsBarProps = {\n activeTabId: string\n customTabComponents?: Record<string, React.ReactNode>\n onTabChange: (tabId: string) => void\n renderedTabItems?: React.ReactNode[]\n settingsMenu?: React.ReactNode[]\n sidebarConfig: EnhancedSidebarConfig\n tabIcons?: Record<string, React.ReactNode>\n}\n\nexport const TabsBar: React.FC<TabsBarProps> = ({\n activeTabId,\n customTabComponents,\n onTabChange,\n renderedTabItems,\n settingsMenu,\n sidebarConfig,\n tabIcons,\n}) => {\n const { i18n } = useTranslation()\n const pathname = usePathname()\n\n const {\n config: {\n admin: {\n routes: { browseByFolder: foldersRoute, logout: logoutRoute },\n },\n folders,\n routes: { admin: adminRoute },\n },\n } = useConfig()\n\n const showLogout = sidebarConfig.showLogout !== false\n const showFolders = folders && folders.browseByFolder\n\n const folderURL = formatAdminURL({\n adminRoute,\n path: foldersRoute,\n })\n const isFoldersActive = pathname.startsWith(folderURL)\n\n const renderTabItem = (item: SidebarTab) => {\n if (item.type === 'custom') {\n return customTabComponents?.[item.id] ?? null\n }\n\n if (item.type === 'tab') {\n return (\n <TabButton\n icon={tabIcons?.[item.id]}\n isActive={activeTabId === item.id}\n key={item.id}\n onTabChange={onTabChange}\n tab={item}\n />\n )\n }\n\n // Check if link is active\n const href = item.isExternal\n ? item.href\n : formatAdminURL({ adminRoute, path: item.href })\n const isActive = pathname === href || (item.href === '/' && pathname === adminRoute)\n\n return <TabLink href={href} icon={tabIcons?.[item.id]} isActive={isActive} key={item.id} link={item} />\n }\n\n const tabItems = sidebarConfig.tabs ?? []\n\n return (\n <div className={tabsBaseClass}>\n <div className={`${tabsBaseClass}__tabs`}>\n {renderedTabItems ?? tabItems.map(renderTabItem)}\n </div>\n\n <div className={`${tabsBaseClass}__actions`}>\n {showFolders && (\n <Link\n className={`${tabsBaseClass}__action ${isFoldersActive ? `${tabsBaseClass}__link--active` : ''}`}\n href={folderURL}\n title={getTranslation({ en: 'Browse by Folder', uk: 'Переглянути по папках' }, i18n)}\n >\n <Icon name=\"Folder\" size={20} />\n </Link>\n )}\n <SettingsMenuButton settingsMenu={settingsMenu} />\n {showLogout && (\n <Link\n className={`${tabsBaseClass}__action`}\n href={formatAdminURL({\n adminRoute,\n path: logoutRoute,\n })}\n title={getTranslation({ en: 'Logout', uk: 'Вийти' }, i18n)}\n type=\"button\"\n >\n <Icon name=\"LogOut\" size={20} />\n </Link>\n )}\n </div>\n </div>\n )\n}\n"],"names":["getTranslation","Link","useConfig","useTranslation","usePathname","formatAdminURL","React","Icon","SettingsMenuButton","TabButton","TabLink","tabsBaseClass","TabsBar","activeTabId","customTabComponents","onTabChange","renderedTabItems","settingsMenu","sidebarConfig","tabIcons","i18n","pathname","config","admin","routes","browseByFolder","foldersRoute","logout","logoutRoute","folders","adminRoute","showLogout","showFolders","folderURL","path","isFoldersActive","startsWith","renderTabItem","item","type","id","icon","isActive","tab","href","isExternal","link","tabItems","tabs","div","className","map","title","en","uk","name","size"],"mappings":"AAAA;;AAEA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,IAAI,EAAEC,SAAS,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,SAASC,WAAW,QAAQ,kBAAiB;AAC7C,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAIzB,SAASC,IAAI,QAAQ,UAAS;AAC9B,SAASC,kBAAkB,QAAQ,wBAAuB;AAC1D,SAASC,SAAS,EAAEC,OAAO,QAAQ,YAAW;AAC9C,OAAO,eAAc;AAErB,MAAMC,gBAAgB;AAYtB,OAAO,MAAMC,UAAkC,CAAC,EAC9CC,WAAW,EACXC,mBAAmB,EACnBC,WAAW,EACXC,gBAAgB,EAChBC,YAAY,EACZC,aAAa,EACbC,QAAQ,EACT;IACC,MAAM,EAAEC,IAAI,EAAE,GAAGjB;IACjB,MAAMkB,WAAWjB;IAEjB,MAAM,EACJkB,QAAQ,EACNC,OAAO,EACLC,QAAQ,EAAEC,gBAAgBC,YAAY,EAAEC,QAAQC,WAAW,EAAE,EAC9D,EACDC,OAAO,EACPL,QAAQ,EAAED,OAAOO,UAAU,EAAE,EAC9B,EACF,GAAG5B;IAEJ,MAAM6B,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qD,IAAI;4BAAoBC,IAAI;wBAAwB,GAAGlC;kCAE/E,cAAA,KAACb;4BAAKgD,MAAK;4BAASC,MAAM;;;kCAG9B,KAAChD;wBAAmBS,cAAcA;;oBACjCc,4BACC,KAAC9B;wBACCiD,WAAW,GAAGvC,cAAc,QAAQ,CAAC;wBACrCiC,MAAMvC,eAAe;4BACnByB;4BACAI,MAAMN;wBACR;wBACAwB,OAAOpD,eAAe;4BAAEqD,IAAI;4BAAUC,IAAI;wBAAQ,GAAGlC;wBACrDmB,MAAK;kCAEL,cAAA,KAAChC;4BAAKgD,MAAK;4BAASC,MAAM;;;;;;;AAMtC,EAAC"}
|
|
@@ -185,13 +185,13 @@ export const EnhancedSidebar = async (props)=>{
|
|
|
185
185
|
const { slug, type } = entity;
|
|
186
186
|
let href;
|
|
187
187
|
let id;
|
|
188
|
-
if (type ===
|
|
188
|
+
if (type === EntityType.collection) {
|
|
189
189
|
href = formatAdminURL({
|
|
190
190
|
adminRoute,
|
|
191
191
|
path: `/collections/${slug}`
|
|
192
192
|
});
|
|
193
193
|
id = `nav-${slug}`;
|
|
194
|
-
} else if (type ===
|
|
194
|
+
} else if (type === EntityType.global) {
|
|
195
195
|
href = formatAdminURL({
|
|
196
196
|
adminRoute,
|
|
197
197
|
path: `/globals/${slug}`
|
|
@@ -282,13 +282,38 @@ export const EnhancedSidebar = async (props)=>{
|
|
|
282
282
|
// Build server-side icon and tab button rendering
|
|
283
283
|
const allTabItems = visibleTabItems;
|
|
284
284
|
const hasCustomTabButton = !!config.customComponents?.TabButton;
|
|
285
|
-
const hasAnyIconComponent = allTabItems.some((t)=>t.iconComponent);
|
|
285
|
+
const hasAnyIconComponent = allTabItems.some((t)=>t.type !== 'custom' && t.iconComponent);
|
|
286
286
|
// tabIcons: per-id icon node (only built when no custom TabButton, just iconComponent overrides)
|
|
287
287
|
const tabIcons = {};
|
|
288
288
|
// renderedTabItems: fully custom tab button nodes (built when customComponents.TabButton is set)
|
|
289
289
|
const renderedTabItems = [];
|
|
290
|
+
// customTabComponents: server-rendered components for type:'custom' tab bar slots
|
|
291
|
+
const customTabComponents = {};
|
|
292
|
+
// Pre-render all type:'custom' items
|
|
293
|
+
for (const item of allTabItems){
|
|
294
|
+
if (item.type === 'custom') {
|
|
295
|
+
const { clientProps: extraProps, path } = resolveSidebarComponent(item.component);
|
|
296
|
+
customTabComponents[item.id] = RenderServerComponent({
|
|
297
|
+
clientProps: {
|
|
298
|
+
id: item.id,
|
|
299
|
+
...extraProps
|
|
300
|
+
},
|
|
301
|
+
Component: path,
|
|
302
|
+
importMap: payload.importMap,
|
|
303
|
+
key: item.id,
|
|
304
|
+
serverProps
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
290
308
|
if (hasCustomTabButton || hasAnyIconComponent) {
|
|
291
309
|
for (const item of allTabItems){
|
|
310
|
+
if (item.type === 'custom') {
|
|
311
|
+
// Include pre-rendered custom slot in renderedTabItems when using custom TabButton
|
|
312
|
+
if (hasCustomTabButton) {
|
|
313
|
+
renderedTabItems.push(customTabComponents[item.id]);
|
|
314
|
+
}
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
292
317
|
const label = getTranslation(item.label, i18n);
|
|
293
318
|
// Resolve icon: custom iconComponent > default Lucide
|
|
294
319
|
let iconNode;
|
|
@@ -371,6 +396,7 @@ export const EnhancedSidebar = async (props)=>{
|
|
|
371
396
|
allContent: allContent,
|
|
372
397
|
beforeNavLinks: beforeNavLinksRendered,
|
|
373
398
|
customNavContent: customNavContent,
|
|
399
|
+
customTabComponents: Object.keys(customTabComponents).length > 0 ? customTabComponents : undefined,
|
|
374
400
|
initialActiveTabId: initialActiveTabId,
|
|
375
401
|
renderedTabItems: renderedTabItems.length > 0 ? renderedTabItems : undefined,
|
|
376
402
|
settingsMenu: renderedSettingsMenu,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/EnhancedSidebar/index.tsx"],"sourcesContent":["import type { EntityToGroup } from '@payloadcms/ui/shared'\nimport type { PayloadRequest, ServerProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { NavGroup } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { EntityType, groupNavItems } from '@payloadcms/ui/shared'\nimport { cookies } from 'next/headers'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nconst COOKIE_KEY = 'payload-enhanced-sidebar-active-tab'\n\nimport type {\n EnhancedSidebarConfig,\n ExtendedEntity,\n ExtendedGroup,\n SidebarTab,\n SidebarTabContent as SidebarTabContentType,\n SidebarTabItem,\n} from '../../types'\n\nimport { extractLocalizedValue, resolveSidebarComponent, sanitizeSidebarConfig } from '../../utils'\nimport { getNavPrefs } from './getNavPrefs'\nimport { Icon } from './Icon'\nimport { NavItem } from './NavItem'\nimport { SidebarContent } from './SidebarContent'\nimport './index.scss'\n\nexport type EnhancedSidebarProps = {\n req?: PayloadRequest\n sidebarConfig?: EnhancedSidebarConfig\n} & ServerProps\n\n/**\n * Computes filtered and merged groups for a specific tab (server-side).\n */\nconst computeGroupsForTab = async (\n tab: SidebarTabContentType,\n groups: ExtendedGroup[],\n currentLang: string,\n req: PayloadRequest | undefined,\n): Promise<ExtendedGroup[]> => {\n const { collections: tabCollections, customItems, globals: tabGlobals } = tab\n\n const showAll = !tabCollections && !tabGlobals\n const allowedSlugs = new Set([...(tabCollections ?? []), ...(tabGlobals ?? [])])\n\n let result: ExtendedGroup[] = []\n\n if (showAll) {\n result = groups.map((g) => ({ ...g, entities: [...g.entities] }))\n } else if (allowedSlugs.size > 0) {\n result = groups\n .map((group) => ({\n ...group,\n entities: group.entities.filter((entity) => allowedSlugs.has(entity.slug)),\n }))\n .filter((group) => group.entities.length > 0)\n }\n\n if (customItems && customItems.length > 0) {\n const topAdditions: ExtendedGroup[] = []\n const topUngrouped: SidebarTabItem[] = []\n const bottomUngrouped: SidebarTabItem[] = []\n\n const toEntity = (item: SidebarTabItem): ExtendedEntity =>\n ({\n slug: item.slug,\n type: 'custom',\n href: item.href,\n isExternal: item.isExternal,\n label: item.label,\n }) as ExtendedEntity\n\n // Filter custom items by access — fail-closed: missing req denies access\n const accessResults = await Promise.all(\n customItems.map((item) => (item.access ? (req ? item.access({ item, req }) : false) : true)),\n )\n const visibleItems = customItems.filter((_, i) => accessResults[i])\n\n for (const item of visibleItems) {\n if (item.group) {\n const itemGroupLabel = extractLocalizedValue(item.group, currentLang)\n const existingGroup = result.find((g) => {\n const groupLabel = extractLocalizedValue(g.label, currentLang)\n return groupLabel === itemGroupLabel\n })\n\n if (existingGroup) {\n // Merged into existing collection group — position has no effect here\n existingGroup.entities.push(toEntity(item))\n } else {\n // New custom group — position controls top vs bottom\n const newGroup: ExtendedGroup = { entities: [toEntity(item)], label: item.group }\n if (item.position === 'top') {\n topAdditions.push(newGroup)\n } else {\n result.push(newGroup)\n }\n }\n } else {\n if (item.position === 'top') {\n topUngrouped.push(item)\n } else {\n bottomUngrouped.push(item)\n }\n }\n }\n\n if (topUngrouped.length > 0) {\n topAdditions.unshift({ entities: topUngrouped.map(toEntity), label: '' })\n }\n\n if (bottomUngrouped.length > 0) {\n result.push({ entities: bottomUngrouped.map(toEntity), label: '' })\n }\n\n result = [...topAdditions, ...result]\n }\n\n return result\n}\n\nexport const EnhancedSidebar: React.FC<EnhancedSidebarProps> = async (props) => {\n const {\n documentSubViewType,\n i18n,\n locale,\n params,\n payload,\n permissions,\n req,\n searchParams,\n sidebarConfig,\n user,\n viewType,\n visibleEntities,\n } = props\n\n if (!payload?.config) {\n return null\n }\n\n const {\n admin: {\n components: { afterNavLinks, beforeNavLinks, settingsMenu },\n },\n collections,\n globals,\n } = payload.config\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 || {},\n i18n,\n ) as unknown as ExtendedGroup[]\n\n const navPreferences = await getNavPrefs(req)\n\n const serverProps = {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const clientProps = {\n documentSubViewType,\n viewType,\n }\n\n const beforeNavLinksRendered = RenderServerComponent({\n clientProps,\n Component: beforeNavLinks,\n importMap: payload.importMap,\n serverProps,\n })\n\n const afterNavLinksRendered = RenderServerComponent({\n clientProps,\n Component: afterNavLinks,\n importMap: payload.importMap,\n serverProps,\n })\n\n const renderedSettingsMenu =\n settingsMenu && Array.isArray(settingsMenu)\n ? settingsMenu.map((item, index) =>\n RenderServerComponent({\n clientProps,\n Component: item,\n importMap: payload.importMap,\n key: `settings-menu-item-${index}`,\n serverProps,\n }),\n )\n : []\n\n const config: EnhancedSidebarConfig = sidebarConfig ?? {\n tabs: [\n {\n id: 'default',\n type: 'tab',\n icon: 'LayoutGrid',\n label: 'Collections',\n },\n ],\n }\n\n // Filter all tab bar items by access — fail-closed: missing req denies access\n // Note: req can be undefined on 404 pages due to a Payload bug (NotFound view omits req from props)\n const allConfigTabs = config.tabs ?? []\n const tabAccessResults = await Promise.all(\n allConfigTabs.map((t) => (t.access ? (req ? t.access({ item: t, req }) : false) : true)),\n )\n const visibleTabItems = allConfigTabs.filter((_, i) => tabAccessResults[i])\n\n // Read active tab from cookie\n const cookieStore = await cookies()\n const storedTabId = cookieStore.get(COOKIE_KEY)?.value\n const tabs = visibleTabItems.filter((t) => t.type === 'tab') as SidebarTabContentType[]\n const defaultTabId = tabs[0]?.id ?? 'default'\n const initialActiveTabId =\n storedTabId && tabs.some((t) => t.id === storedTabId) ? storedTabId : defaultTabId\n\n const adminRoute = payload.config.routes.admin\n const currentLang = i18n.language\n\n /**\n * Renders a single entity as a NavItem (default or custom).\n */\n const renderEntity = (entity: ExtendedEntity, key: string): React.ReactNode => {\n const { slug, type } = entity\n let href: string\n let id: string\n\n if (type === 'collection') {\n href = formatAdminURL({ adminRoute, path: `/collections/${slug}` })\n id = `nav-${slug}`\n } else if (type === 'global') {\n href = formatAdminURL({ adminRoute, path: `/globals/${slug}` })\n id = `nav-global-${slug}`\n } else if (type === 'custom' && entity.href) {\n id = `nav-custom-${slug}`\n href = entity.isExternal ? entity.href : formatAdminURL({ adminRoute, path: entity.href })\n } else {\n return null\n }\n\n const badgeConfig = config.badges?.[slug]\n\n if (config.customComponents?.NavItem) {\n const label = getTranslation(entity.label, i18n)\n const { clientProps: extraProps, path } = resolveSidebarComponent(\n config.customComponents.NavItem,\n )\n return RenderServerComponent({\n clientProps: { id, badgeConfig, entity, href, label, ...extraProps },\n Component: path,\n importMap: payload.importMap,\n key,\n serverProps,\n })\n }\n\n return <NavItem badgeConfig={badgeConfig} entity={entity} href={href} id={id} key={key} />\n }\n\n /**\n * Renders a group with its entities (default NavGroup or custom).\n */\n const renderGroup = (group: ExtendedGroup, key: string): React.ReactNode => {\n const { entities, label } = group\n const isUngrouped = !label || (typeof label === 'string' && label === '')\n const translatedLabel = getTranslation(label || '', i18n)\n\n const items = entities.map((entity, i) => renderEntity(entity, `${key}-${i}`))\n\n if (isUngrouped) {\n return <Fragment key={key}>{items}</Fragment>\n }\n\n if (config.customComponents?.NavGroup) {\n const { clientProps: extraProps, path } = resolveSidebarComponent(\n config.customComponents.NavGroup,\n )\n return RenderServerComponent({\n clientProps: {\n children: items,\n isOpen: navPreferences?.groups?.[translatedLabel]?.open,\n label: translatedLabel,\n ...extraProps,\n },\n Component: path,\n importMap: payload.importMap,\n key,\n serverProps,\n })\n }\n\n return (\n <NavGroup\n isOpen={navPreferences?.groups?.[translatedLabel]?.open}\n key={key}\n label={translatedLabel}\n >\n {items}\n </NavGroup>\n )\n }\n\n // Pre-render content for every tab on the server (computed in parallel)\n const tabGroupResults = await Promise.all(\n tabs.map((tab) => computeGroupsForTab(tab, groups, currentLang, req)),\n )\n const tabsContent: Record<string, React.ReactNode> = {}\n for (let i = 0; i < tabs.length; i++) {\n const tab = tabs[i]\n const tabGroups = tabGroupResults[i]\n tabsContent[tab.id] = (\n <Fragment>{tabGroups.map((group, j) => renderGroup(group, `${tab.id}-${j}`))}</Fragment>\n )\n }\n\n // For the no-tabs fallback\n const allContent =\n tabs.length === 0 ? (\n <Fragment>{groups.map((group, i) => renderGroup(group, `all-${i}`))}</Fragment>\n ) : undefined\n\n // Build server-side icon and tab button rendering\n const allTabItems = visibleTabItems\n const hasCustomTabButton = !!config.customComponents?.TabButton\n const hasAnyIconComponent = allTabItems.some((t) => t.iconComponent)\n\n // tabIcons: per-id icon node (only built when no custom TabButton, just iconComponent overrides)\n const tabIcons: Record<string, React.ReactNode> = {}\n // renderedTabItems: fully custom tab button nodes (built when customComponents.TabButton is set)\n const renderedTabItems: React.ReactNode[] = []\n\n if (hasCustomTabButton || hasAnyIconComponent) {\n for (const item of allTabItems) {\n const label = getTranslation(item.label, i18n)\n\n // Resolve icon: custom iconComponent > default Lucide\n let iconNode: React.ReactNode\n if (item.iconComponent) {\n const { clientProps: iconExtraProps, path: iconPath } = resolveSidebarComponent(\n item.iconComponent,\n )\n iconNode = RenderServerComponent({\n clientProps: { id: item.id, type: item.type, label, ...iconExtraProps },\n Component: iconPath,\n importMap: payload.importMap,\n serverProps,\n })\n } else {\n iconNode = item.icon ? <Icon name={item.icon} size={20} /> : null\n }\n\n if (hasCustomTabButton) {\n // Compute href for links\n let href: string | undefined\n if (item.type === 'link') {\n href = item.isExternal ? item.href : formatAdminURL({ adminRoute, path: item.href })\n }\n\n const { clientProps: tabBtnExtraProps, path: tabBtnPath } = resolveSidebarComponent(\n config.customComponents!.TabButton!,\n )\n renderedTabItems.push(\n RenderServerComponent({\n clientProps: {\n id: item.id,\n type: item.type,\n badge: item.badge,\n href,\n icon: iconNode,\n isExternal: item.type === 'link' ? item.isExternal : undefined,\n label,\n ...tabBtnExtraProps,\n },\n Component: tabBtnPath,\n importMap: payload.importMap,\n key: item.id,\n serverProps,\n }),\n )\n } else if (item.iconComponent) {\n tabIcons[item.id] = iconNode\n }\n }\n }\n\n const customNavContent = config.customComponents?.NavContent\n ? (() => {\n const { clientProps: extraProps, path } = resolveSidebarComponent(\n config.customComponents.NavContent,\n )\n return RenderServerComponent({\n clientProps: {\n afterNavLinks: afterNavLinksRendered,\n allContent,\n beforeNavLinks: beforeNavLinksRendered,\n tabs: tabs.map((t) => ({ id: t.id })),\n tabsContent,\n ...extraProps,\n },\n Component: path,\n importMap: payload.importMap,\n key: 'enhanced-sidebar-nav-content',\n serverProps,\n })\n })()\n : undefined\n\n // Strip access functions and use only visible tabs before passing to client component\n const clientSidebarConfig = sanitizeSidebarConfig({ ...config, tabs: visibleTabItems })\n\n return (\n <SidebarContent\n afterNavLinks={afterNavLinksRendered}\n allContent={allContent}\n beforeNavLinks={beforeNavLinksRendered}\n customNavContent={customNavContent}\n initialActiveTabId={initialActiveTabId}\n renderedTabItems={renderedTabItems.length > 0 ? renderedTabItems : undefined}\n settingsMenu={renderedSettingsMenu}\n sidebarConfig={clientSidebarConfig}\n tabIcons={Object.keys(tabIcons).length > 0 ? tabIcons : undefined}\n tabsContent={tabsContent}\n />\n )\n}\n\nexport default EnhancedSidebar\n"],"names":["getTranslation","NavGroup","RenderServerComponent","EntityType","groupNavItems","cookies","formatAdminURL","React","Fragment","COOKIE_KEY","extractLocalizedValue","resolveSidebarComponent","sanitizeSidebarConfig","getNavPrefs","Icon","NavItem","SidebarContent","computeGroupsForTab","tab","groups","currentLang","req","collections","tabCollections","customItems","globals","tabGlobals","showAll","allowedSlugs","Set","result","map","g","entities","size","group","filter","entity","has","slug","length","topAdditions","topUngrouped","bottomUngrouped","toEntity","item","type","href","isExternal","label","accessResults","Promise","all","access","visibleItems","_","i","itemGroupLabel","existingGroup","find","groupLabel","push","newGroup","position","unshift","EnhancedSidebar","props","documentSubViewType","i18n","locale","params","payload","permissions","searchParams","sidebarConfig","user","viewType","visibleEntities","config","admin","components","afterNavLinks","beforeNavLinks","settingsMenu","includes","collection","global","navPreferences","serverProps","clientProps","beforeNavLinksRendered","Component","importMap","afterNavLinksRendered","renderedSettingsMenu","Array","isArray","index","key","tabs","id","icon","allConfigTabs","tabAccessResults","t","visibleTabItems","cookieStore","storedTabId","get","value","defaultTabId","initialActiveTabId","some","adminRoute","routes","language","renderEntity","path","badgeConfig","badges","customComponents","extraProps","renderGroup","isUngrouped","translatedLabel","items","children","isOpen","open","tabGroupResults","tabsContent","tabGroups","j","allContent","undefined","allTabItems","hasCustomTabButton","TabButton","hasAnyIconComponent","iconComponent","tabIcons","renderedTabItems","iconNode","iconExtraProps","iconPath","name","tabBtnExtraProps","tabBtnPath","badge","customNavContent","NavContent","clientSidebarConfig","Object","keys"],"mappings":";AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAuB;AACjE,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,MAAMC,aAAa;AAWnB,SAASC,qBAAqB,EAAEC,uBAAuB,EAAEC,qBAAqB,QAAQ,cAAa;AACnG,SAASC,WAAW,QAAQ,gBAAe;AAC3C,SAASC,IAAI,QAAQ,SAAQ;AAC7B,SAASC,OAAO,QAAQ,YAAW;AACnC,SAASC,cAAc,QAAQ,mBAAkB;AACjD,OAAO,eAAc;AAOrB;;CAEC,GACD,MAAMC,sBAAsB,OAC1BC,KACAC,QACAC,aACAC;IAEA,MAAM,EAAEC,aAAaC,cAAc,EAAEC,WAAW,EAAEC,SAASC,UAAU,EAAE,GAAGR;IAE1E,MAAMS,UAAU,CAACJ,kBAAkB,CAACG;IACpC,MAAME,eAAe,IAAIC,IAAI;WAAKN,kBAAkB,EAAE;WAAOG,cAA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DrF;wBACA,GAAGiG,gBAAgB;oBACrB;oBACAvD,WAAWwD;oBACXvD,WAAWrB,QAAQqB,SAAS;oBAC5BM,KAAKrD,KAAKuD,EAAE;oBACZZ;gBACF;YAEJ,OAAO,IAAI3C,KAAK8F,aAAa,EAAE;gBAC7BC,QAAQ,CAAC/F,KAAKuD,EAAE,CAAC,GAAG0C;YACtB;QACF;IACF;IAEA,MAAMO,mBAAmBvE,OAAO0C,gBAAgB,EAAE8B,aAC9C,AAAC,CAAA;QACC,MAAM,EAAE7D,aAAagC,UAAU,EAAEJ,IAAI,EAAE,GAAG1G,wBACxCmE,OAAO0C,gBAAgB,CAAC8B,UAAU;QAEpC,OAAOpJ,sBAAsB;YAC3BuF,aAAa;gBACXR,eAAeY;gBACfwC;gBACAnD,gBAAgBQ;gBAChBS,MAAMA,KAAKpE,GAAG,CAAC,CAACyE,IAAO,CAAA;wBAAEJ,IAAII,EAAEJ,EAAE;oBAAC,CAAA;gBAClC8B;gBACA,GAAGT,UAAU;YACf;YACA9B,WAAW0B;YACXzB,WAAWrB,QAAQqB,SAAS;YAC5BM,KAAK;YACLV;QACF;IACF,CAAA,MACA8C;IAEJ,sFAAsF;IACtF,MAAMiB,sBAAsB3I,sBAAsB;QAAE,GAAGkE,MAAM;QAAEqB,MAAMM;IAAgB;IAErF,qBACE,KAACzF;QACCiE,eAAeY;QACfwC,YAAYA;QACZnD,gBAAgBQ;QAChB2D,kBAAkBA;QAClBtC,oBAAoBA;QACpB8B,kBAAkBA,iBAAiBrG,MAAM,GAAG,IAAIqG,mBAAmBP;QACnEnD,cAAcW;QACdpB,eAAe6E;QACfX,UAAUY,OAAOC,IAAI,CAACb,UAAUpG,MAAM,GAAG,IAAIoG,WAAWN;QACxDJ,aAAaA;;AAGnB,EAAC;AAED,eAAejE,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/EnhancedSidebar/index.tsx"],"sourcesContent":["import type { EntityToGroup } from '@payloadcms/ui/shared'\nimport type { PayloadRequest, ServerProps } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { NavGroup } from '@payloadcms/ui'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { EntityType, groupNavItems } from '@payloadcms/ui/shared'\nimport { cookies } from 'next/headers'\nimport { formatAdminURL } from 'payload/shared'\nimport React, { Fragment } from 'react'\n\nconst COOKIE_KEY = 'payload-enhanced-sidebar-active-tab'\n\nimport type {\n EnhancedSidebarConfig,\n ExtendedEntity,\n ExtendedGroup,\n SidebarTab,\n SidebarTabContent as SidebarTabContentType,\n SidebarTabItem,\n} from '../../types'\n\nimport { extractLocalizedValue, resolveSidebarComponent, sanitizeSidebarConfig } from '../../utils'\nimport { getNavPrefs } from './getNavPrefs'\nimport { Icon } from './Icon'\nimport { NavItem } from './NavItem'\nimport { SidebarContent } from './SidebarContent'\nimport './index.scss'\n\nexport type EnhancedSidebarProps = {\n req?: PayloadRequest\n sidebarConfig?: EnhancedSidebarConfig\n} & ServerProps\n\n/**\n * Computes filtered and merged groups for a specific tab (server-side).\n */\nconst computeGroupsForTab = async (\n tab: SidebarTabContentType,\n groups: ExtendedGroup[],\n currentLang: string,\n req: PayloadRequest | undefined,\n): Promise<ExtendedGroup[]> => {\n const { collections: tabCollections, customItems, globals: tabGlobals } = tab\n\n const showAll = !tabCollections && !tabGlobals\n const allowedSlugs = new Set([...(tabCollections ?? []), ...(tabGlobals ?? [])])\n\n let result: ExtendedGroup[] = []\n\n if (showAll) {\n result = groups.map((g) => ({ ...g, entities: [...g.entities] }))\n } else if (allowedSlugs.size > 0) {\n result = groups\n .map((group) => ({\n ...group,\n entities: group.entities.filter((entity) => allowedSlugs.has(entity.slug)),\n }))\n .filter((group) => group.entities.length > 0)\n }\n\n if (customItems && customItems.length > 0) {\n const topAdditions: ExtendedGroup[] = []\n const topUngrouped: SidebarTabItem[] = []\n const bottomUngrouped: SidebarTabItem[] = []\n\n const toEntity = (item: SidebarTabItem): ExtendedEntity =>\n ({\n slug: item.slug,\n type: 'custom',\n href: item.href,\n isExternal: item.isExternal,\n label: item.label,\n }) as ExtendedEntity\n\n // Filter custom items by access — fail-closed: missing req denies access\n const accessResults = await Promise.all(\n customItems.map((item) => (item.access ? (req ? item.access({ item, req }) : false) : true)),\n )\n const visibleItems = customItems.filter((_, i) => accessResults[i])\n\n for (const item of visibleItems) {\n if (item.group) {\n const itemGroupLabel = extractLocalizedValue(item.group, currentLang)\n const existingGroup = result.find((g) => {\n const groupLabel = extractLocalizedValue(g.label, currentLang)\n return groupLabel === itemGroupLabel\n })\n\n if (existingGroup) {\n // Merged into existing collection group — position has no effect here\n existingGroup.entities.push(toEntity(item))\n } else {\n // New custom group — position controls top vs bottom\n const newGroup: ExtendedGroup = { entities: [toEntity(item)], label: item.group }\n if (item.position === 'top') {\n topAdditions.push(newGroup)\n } else {\n result.push(newGroup)\n }\n }\n } else {\n if (item.position === 'top') {\n topUngrouped.push(item)\n } else {\n bottomUngrouped.push(item)\n }\n }\n }\n\n if (topUngrouped.length > 0) {\n topAdditions.unshift({ entities: topUngrouped.map(toEntity), label: '' })\n }\n\n if (bottomUngrouped.length > 0) {\n result.push({ entities: bottomUngrouped.map(toEntity), label: '' })\n }\n\n result = [...topAdditions, ...result]\n }\n\n return result\n}\n\nexport const EnhancedSidebar: React.FC<EnhancedSidebarProps> = async (props) => {\n const {\n documentSubViewType,\n i18n,\n locale,\n params,\n payload,\n permissions,\n req,\n searchParams,\n sidebarConfig,\n user,\n viewType,\n visibleEntities,\n } = props\n\n if (!payload?.config) {\n return null\n }\n\n const {\n admin: {\n components: { afterNavLinks, beforeNavLinks, settingsMenu },\n },\n collections,\n globals,\n } = payload.config\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 || {},\n i18n,\n ) as unknown as ExtendedGroup[]\n\n const navPreferences = await getNavPrefs(req)\n\n const serverProps = {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n }\n\n const clientProps = {\n documentSubViewType,\n viewType,\n }\n\n const beforeNavLinksRendered = RenderServerComponent({\n clientProps,\n Component: beforeNavLinks,\n importMap: payload.importMap,\n serverProps,\n })\n\n const afterNavLinksRendered = RenderServerComponent({\n clientProps,\n Component: afterNavLinks,\n importMap: payload.importMap,\n serverProps,\n })\n\n const renderedSettingsMenu =\n settingsMenu && Array.isArray(settingsMenu)\n ? settingsMenu.map((item, index) =>\n RenderServerComponent({\n clientProps,\n Component: item,\n importMap: payload.importMap,\n key: `settings-menu-item-${index}`,\n serverProps,\n }),\n )\n : []\n\n const config: EnhancedSidebarConfig = sidebarConfig ?? {\n tabs: [\n {\n id: 'default',\n type: 'tab',\n icon: 'LayoutGrid',\n label: 'Collections',\n },\n ],\n }\n\n // Filter all tab bar items by access — fail-closed: missing req denies access\n // Note: req can be undefined on 404 pages due to a Payload bug (NotFound view omits req from props)\n const allConfigTabs = config.tabs ?? []\n const tabAccessResults = await Promise.all(\n allConfigTabs.map((t) => (t.access ? (req ? t.access({ item: t, req }) : false) : true)),\n )\n const visibleTabItems = allConfigTabs.filter((_, i) => tabAccessResults[i])\n\n // Read active tab from cookie\n const cookieStore = await cookies()\n const storedTabId = cookieStore.get(COOKIE_KEY)?.value\n const tabs = visibleTabItems.filter((t) => t.type === 'tab') as SidebarTabContentType[]\n const defaultTabId = tabs[0]?.id ?? 'default'\n const initialActiveTabId =\n storedTabId && tabs.some((t) => t.id === storedTabId) ? storedTabId : defaultTabId\n\n const adminRoute = payload.config.routes.admin\n const currentLang = i18n.language\n\n /**\n * Renders a single entity as a NavItem (default or custom).\n */\n const renderEntity = (entity: ExtendedEntity, key: string): React.ReactNode => {\n const { slug, type } = entity\n let href: string\n let id: string\n\n if (type === EntityType.collection) {\n href = formatAdminURL({ adminRoute, path: `/collections/${slug}` })\n id = `nav-${slug}`\n } else if (type === EntityType.global) {\n href = formatAdminURL({ adminRoute, path: `/globals/${slug}` })\n id = `nav-global-${slug}`\n } else if (type === 'custom' && entity.href) {\n id = `nav-custom-${slug}`\n href = entity.isExternal ? entity.href : formatAdminURL({ adminRoute, path: entity.href })\n } else {\n return null\n }\n\n const badgeConfig = config.badges?.[slug]\n\n if (config.customComponents?.NavItem) {\n const label = getTranslation(entity.label, i18n)\n const { clientProps: extraProps, path } = resolveSidebarComponent(\n config.customComponents.NavItem,\n )\n return RenderServerComponent({\n clientProps: { id, badgeConfig, entity, href, label, ...extraProps },\n Component: path,\n importMap: payload.importMap,\n key,\n serverProps,\n })\n }\n\n return <NavItem badgeConfig={badgeConfig} entity={entity} href={href} id={id} key={key} />\n }\n\n /**\n * Renders a group with its entities (default NavGroup or custom).\n */\n const renderGroup = (group: ExtendedGroup, key: string): React.ReactNode => {\n const { entities, label } = group\n const isUngrouped = !label || (typeof label === 'string' && label === '')\n const translatedLabel = getTranslation(label || '', i18n)\n\n const items = entities.map((entity, i) => renderEntity(entity, `${key}-${i}`))\n\n if (isUngrouped) {\n return <Fragment key={key}>{items}</Fragment>\n }\n\n if (config.customComponents?.NavGroup) {\n const { clientProps: extraProps, path } = resolveSidebarComponent(\n config.customComponents.NavGroup,\n )\n return RenderServerComponent({\n clientProps: {\n children: items,\n isOpen: navPreferences?.groups?.[translatedLabel]?.open,\n label: translatedLabel,\n ...extraProps,\n },\n Component: path,\n importMap: payload.importMap,\n key,\n serverProps,\n })\n }\n\n return (\n <NavGroup\n isOpen={navPreferences?.groups?.[translatedLabel]?.open}\n key={key}\n label={translatedLabel}\n >\n {items}\n </NavGroup>\n )\n }\n\n // Pre-render content for every tab on the server (computed in parallel)\n const tabGroupResults = await Promise.all(\n tabs.map((tab) => computeGroupsForTab(tab, groups, currentLang, req)),\n )\n const tabsContent: Record<string, React.ReactNode> = {}\n for (let i = 0; i < tabs.length; i++) {\n const tab = tabs[i]\n const tabGroups = tabGroupResults[i]\n tabsContent[tab.id] = (\n <Fragment>{tabGroups.map((group, j) => renderGroup(group, `${tab.id}-${j}`))}</Fragment>\n )\n }\n\n // For the no-tabs fallback\n const allContent =\n tabs.length === 0 ? (\n <Fragment>{groups.map((group, i) => renderGroup(group, `all-${i}`))}</Fragment>\n ) : undefined\n\n // Build server-side icon and tab button rendering\n const allTabItems = visibleTabItems\n const hasCustomTabButton = !!config.customComponents?.TabButton\n const hasAnyIconComponent = allTabItems.some((t) => t.type !== 'custom' && t.iconComponent)\n\n // tabIcons: per-id icon node (only built when no custom TabButton, just iconComponent overrides)\n const tabIcons: Record<string, React.ReactNode> = {}\n // renderedTabItems: fully custom tab button nodes (built when customComponents.TabButton is set)\n const renderedTabItems: React.ReactNode[] = []\n // customTabComponents: server-rendered components for type:'custom' tab bar slots\n const customTabComponents: Record<string, React.ReactNode> = {}\n\n // Pre-render all type:'custom' items\n for (const item of allTabItems) {\n if (item.type === 'custom') {\n const { clientProps: extraProps, path } = resolveSidebarComponent(item.component)\n customTabComponents[item.id] = RenderServerComponent({\n clientProps: { id: item.id, ...extraProps },\n Component: path,\n importMap: payload.importMap,\n key: item.id,\n serverProps,\n })\n }\n }\n\n if (hasCustomTabButton || hasAnyIconComponent) {\n for (const item of allTabItems) {\n if (item.type === 'custom') {\n // Include pre-rendered custom slot in renderedTabItems when using custom TabButton\n if (hasCustomTabButton) {\n renderedTabItems.push(customTabComponents[item.id])\n }\n continue\n }\n\n const label = getTranslation(item.label, i18n)\n\n // Resolve icon: custom iconComponent > default Lucide\n let iconNode: React.ReactNode\n if (item.iconComponent) {\n const { clientProps: iconExtraProps, path: iconPath } = resolveSidebarComponent(\n item.iconComponent,\n )\n iconNode = RenderServerComponent({\n clientProps: { id: item.id, type: item.type, label, ...iconExtraProps },\n Component: iconPath,\n importMap: payload.importMap,\n serverProps,\n })\n } else {\n iconNode = item.icon ? <Icon name={item.icon} size={20} /> : null\n }\n\n if (hasCustomTabButton) {\n // Compute href for links\n let href: string | undefined\n if (item.type === 'link') {\n href = item.isExternal ? item.href : formatAdminURL({ adminRoute, path: item.href })\n }\n\n const { clientProps: tabBtnExtraProps, path: tabBtnPath } = resolveSidebarComponent(\n config.customComponents!.TabButton!,\n )\n renderedTabItems.push(\n RenderServerComponent({\n clientProps: {\n id: item.id,\n type: item.type,\n badge: item.badge,\n href,\n icon: iconNode,\n isExternal: item.type === 'link' ? item.isExternal : undefined,\n label,\n ...tabBtnExtraProps,\n },\n Component: tabBtnPath,\n importMap: payload.importMap,\n key: item.id,\n serverProps,\n }),\n )\n } else if (item.iconComponent) {\n tabIcons[item.id] = iconNode\n }\n }\n }\n\n const customNavContent = config.customComponents?.NavContent\n ? (() => {\n const { clientProps: extraProps, path } = resolveSidebarComponent(\n config.customComponents.NavContent,\n )\n return RenderServerComponent({\n clientProps: {\n afterNavLinks: afterNavLinksRendered,\n allContent,\n beforeNavLinks: beforeNavLinksRendered,\n tabs: tabs.map((t) => ({ id: t.id })),\n tabsContent,\n ...extraProps,\n },\n Component: path,\n importMap: payload.importMap,\n key: 'enhanced-sidebar-nav-content',\n serverProps,\n })\n })()\n : undefined\n\n // Strip access functions and use only visible tabs before passing to client component\n const clientSidebarConfig = sanitizeSidebarConfig({ ...config, tabs: visibleTabItems })\n\n return (\n <SidebarContent\n afterNavLinks={afterNavLinksRendered}\n allContent={allContent}\n beforeNavLinks={beforeNavLinksRendered}\n customNavContent={customNavContent}\n customTabComponents={Object.keys(customTabComponents).length > 0 ? customTabComponents : undefined}\n initialActiveTabId={initialActiveTabId}\n renderedTabItems={renderedTabItems.length > 0 ? renderedTabItems : undefined}\n settingsMenu={renderedSettingsMenu}\n sidebarConfig={clientSidebarConfig}\n tabIcons={Object.keys(tabIcons).length > 0 ? tabIcons : undefined}\n tabsContent={tabsContent}\n />\n )\n}\n\nexport default EnhancedSidebar\n"],"names":["getTranslation","NavGroup","RenderServerComponent","EntityType","groupNavItems","cookies","formatAdminURL","React","Fragment","COOKIE_KEY","extractLocalizedValue","resolveSidebarComponent","sanitizeSidebarConfig","getNavPrefs","Icon","NavItem","SidebarContent","computeGroupsForTab","tab","groups","currentLang","req","collections","tabCollections","customItems","globals","tabGlobals","showAll","allowedSlugs","Set","result","map","g","entities","size","group","filter","entity","has","slug","length","topAdditions","topUngrouped","bottomUngrouped","toEntity","item","type","href","isExternal","label","accessResults","Promise","all","access","visibleItems","_","i","itemGroupLabel","existingGroup","find","groupLabel","push","newGroup","position","unshift","EnhancedSidebar","props","documentSubViewType","i18n","locale","params","payload","permissions","searchParams","sidebarConfig","user","viewType","visibleEntities","config","admin","components","afterNavLinks","beforeNavLinks","settingsMenu","includes","collection","global","navPreferences","serverProps","clientProps","beforeNavLinksRendered","Component","importMap","afterNavLinksRendered","renderedSettingsMenu","Array","isArray","index","key","tabs","id","icon","allConfigTabs","tabAccessResults","t","visibleTabItems","cookieStore","storedTabId","get","value","defaultTabId","initialActiveTabId","some","adminRoute","routes","language","renderEntity","path","badgeConfig","badges","customComponents","extraProps","renderGroup","isUngrouped","translatedLabel","items","children","isOpen","open","tabGroupResults","tabsContent","tabGroups","j","allContent","undefined","allTabItems","hasCustomTabButton","TabButton","hasAnyIconComponent","iconComponent","tabIcons","renderedTabItems","customTabComponents","component","iconNode","iconExtraProps","iconPath","name","tabBtnExtraProps","tabBtnPath","badge","customNavContent","NavContent","clientSidebarConfig","Object","keys"],"mappings":";AAGA,SAASA,cAAc,QAAQ,2BAA0B;AACzD,SAASC,QAAQ,QAAQ,iBAAgB;AACzC,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAuB;AACjE,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAEvC,MAAMC,aAAa;AAWnB,SAASC,qBAAqB,EAAE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D,KAAKuD,EAAE;oBACZZ;gBACF;YAEJ,OAAO,IAAI3C,KAAK8F,aAAa,EAAE;gBAC7BC,QAAQ,CAAC/F,KAAKuD,EAAE,CAAC,GAAG4C;YACtB;QACF;IACF;IAEA,MAAMO,mBAAmBzE,OAAO0C,gBAAgB,EAAEgC,aAC9C,AAAC,CAAA;QACC,MAAM,EAAE/D,aAAagC,UAAU,EAAEJ,IAAI,EAAE,GAAG1G,wBACxCmE,OAAO0C,gBAAgB,CAACgC,UAAU;QAEpC,OAAOtJ,sBAAsB;YAC3BuF,aAAa;gBACXR,eAAeY;gBACfwC;gBACAnD,gBAAgBQ;gBAChBS,MAAMA,KAAKpE,GAAG,CAAC,CAACyE,IAAO,CAAA;wBAAEJ,IAAII,EAAEJ,EAAE;oBAAC,CAAA;gBAClC8B;gBACA,GAAGT,UAAU;YACf;YACA9B,WAAW0B;YACXzB,WAAWrB,QAAQqB,SAAS;YAC5BM,KAAK;YACLV;QACF;IACF,CAAA,MACA8C;IAEJ,sFAAsF;IACtF,MAAMmB,sBAAsB7I,sBAAsB;QAAE,GAAGkE,MAAM;QAAEqB,MAAMM;IAAgB;IAErF,qBACE,KAACzF;QACCiE,eAAeY;QACfwC,YAAYA;QACZnD,gBAAgBQ;QAChB6D,kBAAkBA;QAClBT,qBAAqBY,OAAOC,IAAI,CAACb,qBAAqBtG,MAAM,GAAG,IAAIsG,sBAAsBR;QACzFvB,oBAAoBA;QACpB8B,kBAAkBA,iBAAiBrG,MAAM,GAAG,IAAIqG,mBAAmBP;QACnEnD,cAAcW;QACdpB,eAAe+E;QACfb,UAAUc,OAAOC,IAAI,CAACf,UAAUpG,MAAM,GAAG,IAAIoG,WAAWN;QACxDJ,aAAaA;;AAGnB,EAAC;AAED,eAAejE,gBAAe"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { BadgeProvider, useBadgeContext, useBadgeValue, } from './components/Enh
|
|
|
5
5
|
export { useEnhancedSidebar } from './components/EnhancedSidebar/context';
|
|
6
6
|
export { useNavItemState } from './components/EnhancedSidebar/hooks/useNavItemState';
|
|
7
7
|
export { useTabState } from './components/EnhancedSidebar/hooks/useTabState';
|
|
8
|
-
export type { BadgeColor, BadgeConfig, BadgeConfigApi, BadgeConfigCollectionCount, BadgeConfigProvider, BadgeValues, CustomNavContentProps, CustomNavGroupProps, CustomNavItemProps, CustomTabButtonProps, CustomTabIconProps, EnhancedSidebarConfig, ItemAccessFunction, SidebarComponent, TabAccessFunction, } from './types';
|
|
8
|
+
export type { BadgeColor, BadgeConfig, BadgeConfigApi, BadgeConfigCollectionCount, BadgeConfigProvider, BadgeValues, CustomNavContentProps, CustomNavGroupProps, CustomNavItemProps, CustomTabButtonProps, CustomTabIconProps, CustomTabsBarComponentProps, EnhancedSidebarConfig, ItemAccessFunction, SidebarComponent, SidebarTabCustom, TabAccessFunction, } from './types';
|
package/dist/index.js
CHANGED
|
@@ -75,7 +75,13 @@ export const payloadEnhancedSidebar = (pluginOptions = {})=>(config)=>{
|
|
|
75
75
|
throw new Error(`[payload-enhanced-sidebar] Duplicate tab id "${tab.id}". Each tab must have a unique id.`);
|
|
76
76
|
}
|
|
77
77
|
seenTabIds.add(tab.id);
|
|
78
|
-
if (tab.
|
|
78
|
+
if (tab.type === 'custom') {
|
|
79
|
+
const { path } = resolveSidebarComponent(tab.component);
|
|
80
|
+
config.admin.dependencies[`enhanced-sidebar-custom-tab-${tab.id}`] = {
|
|
81
|
+
type: 'component',
|
|
82
|
+
path
|
|
83
|
+
};
|
|
84
|
+
} else if (tab.iconComponent) {
|
|
79
85
|
const { path } = resolveSidebarComponent(tab.iconComponent);
|
|
80
86
|
config.admin.dependencies[`enhanced-sidebar-icon-${tab.id}`] = {
|
|
81
87
|
type: 'component',
|
|
@@ -84,7 +90,7 @@ export const payloadEnhancedSidebar = (pluginOptions = {})=>(config)=>{
|
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
// Check if we have any badges to fetch (api or collection-count)
|
|
87
|
-
const hasBadgesToFetch = sidebarConfig.badges || sidebarConfig.tabs?.some((tab)=>tab.badge && tab.badge.type !== 'provider');
|
|
93
|
+
const hasBadgesToFetch = sidebarConfig.badges || sidebarConfig.tabs?.some((tab)=>tab.type !== 'custom' && tab.badge && tab.badge.type !== 'provider');
|
|
88
94
|
// Add InternalBadgeProvider if we have badges to fetch
|
|
89
95
|
if (hasBadgesToFetch) {
|
|
90
96
|
if (!config.admin.components.providers) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { type Config, deepMerge } from 'payload'\n\nimport type { EnhancedSidebarConfig } from './types'\n\nimport { sidebarTranslations } from './translations'\nimport { resolveSidebarComponent, sanitizeSidebarConfig } from './utils'\n\n/**\n * Default configuration for the enhanced sidebar\n */\nconst defaultConfig: EnhancedSidebarConfig = {\n showLogout: true,\n tabs: [\n {\n id: 'dashboard',\n type: 'link',\n href: '/',\n icon: 'House',\n label: { en: 'Dashboard', uk: 'Головна' },\n },\n {\n id: 'default',\n type: 'tab',\n icon: 'LayoutGrid',\n label: { en: 'Collections', uk: 'Колекції' },\n },\n ],\n}\n\nexport const payloadEnhancedSidebar =\n (pluginOptions: EnhancedSidebarConfig = {}) =>\n (config: Config): Config => {\n if (pluginOptions.disabled) {\n return config\n }\n\n const sidebarConfig: EnhancedSidebarConfig = {\n ...defaultConfig,\n ...pluginOptions,\n tabs: pluginOptions.tabs ?? defaultConfig.tabs,\n }\n\n if (!config.admin) {\n config.admin = {}\n }\n\n if (!config.admin.components) {\n config.admin.components = {}\n }\n\n // Always override Nav — user-defined Nav in config should use customComponents instead\n config.admin.components.Nav = {\n path: '@veiag/payload-enhanced-sidebar/rsc#EnhancedSidebar',\n serverProps: {\n sidebarConfig,\n },\n }\n\n // Register custom components and per-tab icons in the import map\n if (!config.admin.dependencies) {\n config.admin.dependencies = {}\n }\n\n const customComponentSlots = ['NavContent', 'NavGroup', 'NavItem', 'TabButton'] as const\n for (const slot of customComponentSlots) {\n const component = sidebarConfig.customComponents?.[slot]\n if (component) {\n const { path } = resolveSidebarComponent(component)\n config.admin.dependencies[`enhanced-sidebar-${slot.toLowerCase()}`] = {\n type: 'component',\n path,\n }\n }\n }\n\n const seenTabIds = new Set<string>()\n for (const tab of sidebarConfig.tabs ?? []) {\n if (seenTabIds.has(tab.id)) {\n throw new Error(\n `[payload-enhanced-sidebar] Duplicate tab id \"${tab.id}\". Each tab must have a unique id.`,\n )\n }\n seenTabIds.add(tab.id)\n\n if (tab.iconComponent) {\n const { path } = resolveSidebarComponent(tab.iconComponent)\n config.admin.dependencies[`enhanced-sidebar-icon-${tab.id}`] = {\n type: 'component',\n path,\n }\n }\n }\n\n // Check if we have any badges to fetch (api or collection-count)\n const hasBadgesToFetch =\n sidebarConfig.badges ||\n sidebarConfig.tabs?.some((tab) => tab.badge && tab.badge.type !== 'provider')\n\n // Add InternalBadgeProvider if we have badges to fetch\n if (hasBadgesToFetch) {\n if (!config.admin.components.providers) {\n config.admin.components.providers = []\n }\n\n // Add our internal provider at the beginning (so user providers can override)\n config.admin.components.providers.unshift({\n clientProps: {\n sidebarConfig: sanitizeSidebarConfig(sidebarConfig),\n },\n path: '@veiag/payload-enhanced-sidebar/client#InternalBadgeProvider',\n })\n }\n\n // Adding translations\n if (!config.i18n) {\n config.i18n = {}\n }\n if (!config.i18n.translations) {\n config.i18n.translations = {}\n }\n\n config.i18n.translations = deepMerge(config.i18n.translations, sidebarTranslations)\n\n return config\n }\n\nexport {\n BadgeProvider,\n useBadgeContext,\n useBadgeValue,\n} from './components/EnhancedSidebar/BadgeProvider'\n\nexport { useEnhancedSidebar } from './components/EnhancedSidebar/context'\nexport { useNavItemState } from './components/EnhancedSidebar/hooks/useNavItemState'\nexport { useTabState } from './components/EnhancedSidebar/hooks/useTabState'\n\nexport type {\n BadgeColor,\n BadgeConfig,\n BadgeConfigApi,\n BadgeConfigCollectionCount,\n BadgeConfigProvider,\n BadgeValues,\n CustomNavContentProps,\n CustomNavGroupProps,\n CustomNavItemProps,\n CustomTabButtonProps,\n CustomTabIconProps,\n EnhancedSidebarConfig,\n ItemAccessFunction,\n SidebarComponent,\n TabAccessFunction,\n} from './types'\n"],"names":["deepMerge","sidebarTranslations","resolveSidebarComponent","sanitizeSidebarConfig","defaultConfig","showLogout","tabs","id","type","href","icon","label","en","uk","payloadEnhancedSidebar","pluginOptions","config","disabled","sidebarConfig","admin","components","Nav","path","serverProps","dependencies","customComponentSlots","slot","component","customComponents","toLowerCase","seenTabIds","Set","tab","has","Error","add","iconComponent","hasBadgesToFetch","badges","some","badge","providers","unshift","clientProps","i18n","translations","BadgeProvider","useBadgeContext","useBadgeValue","useEnhancedSidebar","useNavItemState","useTabState"],"mappings":"AAAA,SAAsBA,SAAS,QAAQ,UAAS;AAIhD,SAASC,mBAAmB,QAAQ,iBAAgB;AACpD,SAASC,uBAAuB,EAAEC,qBAAqB,QAAQ,UAAS;AAExE;;CAEC,GACD,MAAMC,gBAAuC;IAC3CC,YAAY;IACZC,MAAM;QACJ;YACEC,IAAI;YACJC,MAAM;YACNC,MAAM;YACNC,MAAM;YACNC,OAAO;gBAAEC,IAAI;gBAAaC,IAAI;YAAU;QAC1C;QACA;YACEN,IAAI;YACJC,MAAM;YACNE,MAAM;YACNC,OAAO;gBAAEC,IAAI;gBAAeC,IAAI;YAAW;QAC7C;KACD;AACH;AAEA,OAAO,MAAMC,yBACX,CAACC,gBAAuC,CAAC,CAAC,GAC1C,CAACC;QACC,IAAID,cAAcE,QAAQ,EAAE;YAC1B,OAAOD;QACT;QAEA,MAAME,gBAAuC;YAC3C,GAAGd,aAAa;YAChB,GAAGW,aAAa;YAChBT,MAAMS,cAAcT,IAAI,IAAIF,cAAcE,IAAI;QAChD;QAEA,IAAI,CAACU,OAAOG,KAAK,EAAE;YACjBH,OAAOG,KAAK,GAAG,CAAC;QAClB;QAEA,IAAI,CAACH,OAAOG,KAAK,CAACC,UAAU,EAAE;YAC5BJ,OAAOG,KAAK,CAACC,UAAU,GAAG,CAAC;QAC7B;QAEA,uFAAuF;QACvFJ,OAAOG,KAAK,CAACC,UAAU,CAACC,GAAG,GAAG;YAC5BC,MAAM;YACNC,aAAa;gBACXL;YACF;QACF;QAEA,iEAAiE;QACjE,IAAI,CAACF,OAAOG,KAAK,CAACK,YAAY,EAAE;YAC9BR,OAAOG,KAAK,CAACK,YAAY,GAAG,CAAC;QAC/B;QAEA,MAAMC,uBAAuB;YAAC;YAAc;YAAY;YAAW;SAAY;QAC/E,KAAK,MAAMC,QAAQD,qBAAsB;YACvC,MAAME,YAAYT,cAAcU,gBAAgB,EAAE,CAACF,KAAK;YACxD,IAAIC,WAAW;gBACb,MAAM,EAAEL,IAAI,EAAE,GAAGpB,wBAAwByB;gBACzCX,OAAOG,KAAK,CAACK,YAAY,CAAC,CAAC,iBAAiB,EAAEE,KAAKG,WAAW,IAAI,CAAC,GAAG;oBACpErB,MAAM;oBACNc;gBACF;YACF;QACF;QAEA,MAAMQ,aAAa,IAAIC;QACvB,KAAK,MAAMC,OAAOd,cAAcZ,IAAI,IAAI,EAAE,CAAE;YAC1C,IAAIwB,WAAWG,GAAG,CAACD,IAAIzB,EAAE,GAAG;gBAC1B,MAAM,IAAI2B,MACR,CAAC,6CAA6C,EAAEF,IAAIzB,EAAE,CAAC,kCAAkC,CAAC;YAE9F;YACAuB,WAAWK,GAAG,CAACH,IAAIzB,EAAE;YAErB,IAAIyB,IAAII,aAAa,EAAE;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { type Config, deepMerge } from 'payload'\n\nimport type { EnhancedSidebarConfig } from './types'\n\nimport { sidebarTranslations } from './translations'\nimport { resolveSidebarComponent, sanitizeSidebarConfig } from './utils'\n\n/**\n * Default configuration for the enhanced sidebar\n */\nconst defaultConfig: EnhancedSidebarConfig = {\n showLogout: true,\n tabs: [\n {\n id: 'dashboard',\n type: 'link',\n href: '/',\n icon: 'House',\n label: { en: 'Dashboard', uk: 'Головна' },\n },\n {\n id: 'default',\n type: 'tab',\n icon: 'LayoutGrid',\n label: { en: 'Collections', uk: 'Колекції' },\n },\n ],\n}\n\nexport const payloadEnhancedSidebar =\n (pluginOptions: EnhancedSidebarConfig = {}) =>\n (config: Config): Config => {\n if (pluginOptions.disabled) {\n return config\n }\n\n const sidebarConfig: EnhancedSidebarConfig = {\n ...defaultConfig,\n ...pluginOptions,\n tabs: pluginOptions.tabs ?? defaultConfig.tabs,\n }\n\n if (!config.admin) {\n config.admin = {}\n }\n\n if (!config.admin.components) {\n config.admin.components = {}\n }\n\n // Always override Nav — user-defined Nav in config should use customComponents instead\n config.admin.components.Nav = {\n path: '@veiag/payload-enhanced-sidebar/rsc#EnhancedSidebar',\n serverProps: {\n sidebarConfig,\n },\n }\n\n // Register custom components and per-tab icons in the import map\n if (!config.admin.dependencies) {\n config.admin.dependencies = {}\n }\n\n const customComponentSlots = ['NavContent', 'NavGroup', 'NavItem', 'TabButton'] as const\n for (const slot of customComponentSlots) {\n const component = sidebarConfig.customComponents?.[slot]\n if (component) {\n const { path } = resolveSidebarComponent(component)\n config.admin.dependencies[`enhanced-sidebar-${slot.toLowerCase()}`] = {\n type: 'component',\n path,\n }\n }\n }\n\n const seenTabIds = new Set<string>()\n for (const tab of sidebarConfig.tabs ?? []) {\n if (seenTabIds.has(tab.id)) {\n throw new Error(\n `[payload-enhanced-sidebar] Duplicate tab id \"${tab.id}\". Each tab must have a unique id.`,\n )\n }\n seenTabIds.add(tab.id)\n\n if (tab.type === 'custom') {\n const { path } = resolveSidebarComponent(tab.component)\n config.admin.dependencies[`enhanced-sidebar-custom-tab-${tab.id}`] = {\n type: 'component',\n path,\n }\n } else if (tab.iconComponent) {\n const { path } = resolveSidebarComponent(tab.iconComponent)\n config.admin.dependencies[`enhanced-sidebar-icon-${tab.id}`] = {\n type: 'component',\n path,\n }\n }\n }\n\n // Check if we have any badges to fetch (api or collection-count)\n const hasBadgesToFetch =\n sidebarConfig.badges ||\n sidebarConfig.tabs?.some(\n (tab) => tab.type !== 'custom' && tab.badge && tab.badge.type !== 'provider',\n )\n\n // Add InternalBadgeProvider if we have badges to fetch\n if (hasBadgesToFetch) {\n if (!config.admin.components.providers) {\n config.admin.components.providers = []\n }\n\n // Add our internal provider at the beginning (so user providers can override)\n config.admin.components.providers.unshift({\n clientProps: {\n sidebarConfig: sanitizeSidebarConfig(sidebarConfig),\n },\n path: '@veiag/payload-enhanced-sidebar/client#InternalBadgeProvider',\n })\n }\n\n // Adding translations\n if (!config.i18n) {\n config.i18n = {}\n }\n if (!config.i18n.translations) {\n config.i18n.translations = {}\n }\n\n config.i18n.translations = deepMerge(config.i18n.translations, sidebarTranslations)\n\n return config\n }\n\nexport {\n BadgeProvider,\n useBadgeContext,\n useBadgeValue,\n} from './components/EnhancedSidebar/BadgeProvider'\n\nexport { useEnhancedSidebar } from './components/EnhancedSidebar/context'\nexport { useNavItemState } from './components/EnhancedSidebar/hooks/useNavItemState'\nexport { useTabState } from './components/EnhancedSidebar/hooks/useTabState'\n\nexport type {\n BadgeColor,\n BadgeConfig,\n BadgeConfigApi,\n BadgeConfigCollectionCount,\n BadgeConfigProvider,\n BadgeValues,\n CustomNavContentProps,\n CustomNavGroupProps,\n CustomNavItemProps,\n CustomTabButtonProps,\n CustomTabIconProps,\n CustomTabsBarComponentProps,\n EnhancedSidebarConfig,\n ItemAccessFunction,\n SidebarComponent,\n SidebarTabCustom,\n TabAccessFunction,\n} from './types'\n"],"names":["deepMerge","sidebarTranslations","resolveSidebarComponent","sanitizeSidebarConfig","defaultConfig","showLogout","tabs","id","type","href","icon","label","en","uk","payloadEnhancedSidebar","pluginOptions","config","disabled","sidebarConfig","admin","components","Nav","path","serverProps","dependencies","customComponentSlots","slot","component","customComponents","toLowerCase","seenTabIds","Set","tab","has","Error","add","iconComponent","hasBadgesToFetch","badges","some","badge","providers","unshift","clientProps","i18n","translations","BadgeProvider","useBadgeContext","useBadgeValue","useEnhancedSidebar","useNavItemState","useTabState"],"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xC;YAEA,8EAA8E;YAC9EzB,OAAOG,KAAK,CAACC,UAAU,CAACqB,SAAS,CAACC,OAAO,CAAC;gBACxCC,aAAa;oBACXzB,eAAef,sBAAsBe;gBACvC;gBACAI,MAAM;YACR;QACF;QAEA,sBAAsB;QACtB,IAAI,CAACN,OAAO4B,IAAI,EAAE;YAChB5B,OAAO4B,IAAI,GAAG,CAAC;QACjB;QACA,IAAI,CAAC5B,OAAO4B,IAAI,CAACC,YAAY,EAAE;YAC7B7B,OAAO4B,IAAI,CAACC,YAAY,GAAG,CAAC;QAC9B;QAEA7B,OAAO4B,IAAI,CAACC,YAAY,GAAG7C,UAAUgB,OAAO4B,IAAI,CAACC,YAAY,EAAE5C;QAE/D,OAAOe;IACT,EAAC;AAEH,SACE8B,aAAa,EACbC,eAAe,EACfC,aAAa,QACR,6CAA4C;AAEnD,SAASC,kBAAkB,QAAQ,uCAAsC;AACzE,SAASC,eAAe,QAAQ,qDAAoD;AACpF,SAASC,WAAW,QAAQ,iDAAgD"}
|
package/dist/types.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type InternalIcon = IconName | LucideIcon;
|
|
|
11
11
|
*/
|
|
12
12
|
export type BadgeColor = 'default' | 'error' | 'primary' | 'success' | 'warning';
|
|
13
13
|
/**
|
|
14
|
-
* Badge configuration
|
|
14
|
+
* Badge configuration For API-based fetching
|
|
15
15
|
*/
|
|
16
16
|
export interface BadgeConfigApi {
|
|
17
17
|
/**
|
|
@@ -208,9 +208,34 @@ type SidebarTabLinkInternal = {
|
|
|
208
208
|
*/
|
|
209
209
|
export type SidebarTabLink = SidebarTabLinkExternal | SidebarTabLinkInternal;
|
|
210
210
|
/**
|
|
211
|
-
* A
|
|
211
|
+
* A custom component rendered in the tabs bar (spacer, separator, badge, etc.).
|
|
212
|
+
* Does not open any content — it's purely a visual slot in the tabs column.
|
|
212
213
|
*/
|
|
213
|
-
export type
|
|
214
|
+
export type SidebarTabCustom = {
|
|
215
|
+
/**
|
|
216
|
+
* Access control function. Called server-side with the current request.
|
|
217
|
+
* Return `false` to hide this item entirely.
|
|
218
|
+
*/
|
|
219
|
+
access?: TabAccessFunction;
|
|
220
|
+
/**
|
|
221
|
+
* Component to render. Receives `{ id }` plus any `clientProps` you pass.
|
|
222
|
+
* Supports a plain string path or `{ path, clientProps }`.
|
|
223
|
+
*/
|
|
224
|
+
component: SidebarComponent;
|
|
225
|
+
/** Unique identifier */
|
|
226
|
+
id: string;
|
|
227
|
+
type: 'custom';
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Props passed to a custom tabs bar component (spacer, separator, etc.).
|
|
231
|
+
*/
|
|
232
|
+
export type CustomTabsBarComponentProps = {
|
|
233
|
+
id: string;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* A tab, link, or custom component in the sidebar tabs bar
|
|
237
|
+
*/
|
|
238
|
+
export type SidebarTab = SidebarTabContent | SidebarTabCustom | SidebarTabLink;
|
|
214
239
|
interface BaseSidebarTabItem {
|
|
215
240
|
/**
|
|
216
241
|
* Access control function. Called server-side with the current request.
|
|
@@ -463,13 +488,6 @@ export interface EnhancedSidebarConfig {
|
|
|
463
488
|
* @default false
|
|
464
489
|
*/
|
|
465
490
|
disabled?: boolean;
|
|
466
|
-
/**
|
|
467
|
-
* Custom icons for collections and globals in the default tab.
|
|
468
|
-
*/
|
|
469
|
-
icons?: {
|
|
470
|
-
collections?: Partial<Record<CollectionSlug, IconName>>;
|
|
471
|
-
globals?: Partial<Record<GlobalSlug, IconName>>;
|
|
472
|
-
};
|
|
473
491
|
/**
|
|
474
492
|
* Show logout button at the bottom of the tabs bar.
|
|
475
493
|
* @default true
|
|
@@ -494,7 +512,7 @@ export type GenericCollectionDocument = {
|
|
|
494
512
|
interface BaseExtendedEntity {
|
|
495
513
|
label: Record<string, string> | string;
|
|
496
514
|
slug: string;
|
|
497
|
-
type: '
|
|
515
|
+
type: 'collections' | 'custom' | 'globals';
|
|
498
516
|
}
|
|
499
517
|
interface InternalExtendedEntity extends BaseExtendedEntity {
|
|
500
518
|
href?: '' | `/${string}`;
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { icons, LucideIcon } from 'lucide-react'\nimport type { CollectionSlug, GlobalSlug, PayloadRequest, Where } from 'payload'\nimport type { ReactNode } from 'react'\n\nexport type IconName = keyof typeof icons\n\nexport type LocalizedString = { [locale: string]: string } | string\n\nexport type InternalIcon = IconName | LucideIcon\n\n// ============================================\n// Badge Types\n// ============================================\n\n/**\n * Available badge color variants\n */\nexport type BadgeColor = 'default' | 'error' | 'primary' | 'success' | 'warning'\n\n/**\n * Badge configuration Trr API-based fetching\n */\nexport interface BadgeConfigApi {\n /**\n * Badge color variant\n * @default 'default'\n */\n color?: BadgeColor\n /**\n * API endpoint to fetch badge data from.\n * Can be relative (to current origin) or absolute URL.\n */\n endpoint: string\n /**\n * HTTP method for the request\n * @default 'GET'\n */\n method?: 'GET' | 'POST'\n /**\n * Key in the response object to extract the count from\n * @default 'count'\n */\n responseKey?: string\n type: 'api'\n}\n\n/**\n * Badge configuration for provider-based values.\n * Values are provided via BadgeProvider context.\n */\nexport interface BadgeConfigProvider {\n /**\n * Badge color variant\n * @default 'default'\n */\n color?: BadgeColor\n /**\n * Slug to look up in the BadgeProvider values.\n * If not specified, defaults to the item's id/slug.\n */\n slug?: string\n type: 'provider'\n}\n\n/**\n * Badge configuration for automatic collection document count.\n * Fetches from /api/{collectionSlug}?limit=0 and uses totalDocs.\n */\nexport interface BadgeConfigCollectionCount {\n /**\n * Collection slug to count documents from.\n * If not specified, defaults to the item's slug.\n */\n collectionSlug?: CollectionSlug\n /**\n * Badge color variant\n * @default 'default'\n */\n color?: BadgeColor\n type: 'collection-count'\n /**\n * Optional where query to filter documents.\n * Will be serialized as query string.\n * @example { status: { equals: 'draft' } }\n */\n where?: Where\n}\n\n/**\n * Badge configuration - union of all badge types\n */\nexport type BadgeConfig = BadgeConfigApi | BadgeConfigCollectionCount | BadgeConfigProvider\n\n/**\n * Badge values provided via BadgeProvider context\n */\nexport type BadgeValues = Record<string, number | ReactNode>\n\n// ============================================\n// Access Control Types\n// ============================================\n\n/**\n * Access function for a tab or link in the tabs bar.\n * Return `false` to hide the item entirely (both the button and its content).\n */\nexport type TabAccessFunction = (args: {\n item: SidebarTab\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\n/**\n * Access function for a custom item inside a tab.\n * Return `false` to hide the item from the nav.\n */\nexport type ItemAccessFunction = (args: {\n item: SidebarTabItem\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\n// ============================================\n// Enhanced Sidebar Types\n// ============================================\n\n/**\n * Path to a component, either as a plain string or as an object with a path and\n * additional client props to forward to the component. Follows Payload's component format.\n *\n * @example\n * ```typescript\n * // Simple path\n * iconComponent: './components/Icons#TabIcon'\n *\n * // With client props — useful for a single component shared across all tabs\n * iconComponent: {\n * path: './components/Icons#TabIcon',\n * clientProps: { icon: 'house' },\n * }\n * ```\n */\nexport type SidebarComponent =\n | {\n /** Additional props forwarded to the component on the client */\n clientProps?: Record<string, unknown>\n /** Component path in Payload's format: `'./path/to/file#ExportName'` */\n path: string\n }\n | string\n\n/**\n * Mutually exclusive icon config: either a Lucide icon name OR a custom icon component path.\n */\ntype TabIconConfig =\n | {\n /** Icon name from lucide-react */\n icon: IconName\n iconComponent?: never\n }\n | {\n icon?: never\n /**\n * Path to a custom icon component. Receives `CustomTabIconProps`.\n * Supports a plain string path or `{ path, clientProps }` to forward extra props.\n * Registered automatically in the import map.\n */\n iconComponent: SidebarComponent\n }\n\n/**\n * Sidebar tab that shows content when selected\n */\nexport type SidebarTabContent = {\n /**\n * Access control function. Called server-side with the current request.\n * Return `false` to hide this tab (button + content) entirely.\n */\n access?: TabAccessFunction\n /**\n * Badge configuration for this tab.\n * Shows a badge on the tab icon in the tabs bar.\n */\n badge?: BadgeConfig\n /**\n * Collections to show in this tab.\n * If not specified, no collections are shown (unless items are specified).\n * Use collection slugs.\n */\n collections?: CollectionSlug[]\n /**\n * Custom items to add to this tab.\n * Items with `group` will be merged into matching collection groups.\n * Items without `group` will be shown at the bottom as a flat list.\n */\n customItems?: SidebarTabItem[]\n /**\n * Globals to show in this tab.\n * If not specified, no globals are shown.\n * Use global slugs.\n */\n globals?: GlobalSlug[]\n /** Unique identifier for the tab */\n id: string\n /** Tooltip/label for the tab */\n label: LocalizedString\n type: 'tab'\n} & TabIconConfig\n\ntype SidebarTabLinkBase = {\n /**\n * Access control function. Called server-side with the current request.\n * Return `false` to hide this link entirely.\n */\n access?: TabAccessFunction\n /**\n * Badge configuration for this link.\n * Shows a badge on the link icon in the tabs bar.\n */\n badge?: BadgeConfig\n /** Unique identifier */\n id: string\n /** Tooltip/label */\n label: LocalizedString\n type: 'link'\n} & TabIconConfig\ntype SidebarTabLinkExternal = {\n /** Link href (absolute URL) */\n href: string\n isExternal: true\n} & SidebarTabLinkBase\ntype SidebarTabLinkInternal = {\n /** Link href (relative to admin route) */\n href: '' | `/${string}`\n isExternal?: false\n} & SidebarTabLinkBase\n/**\n * Sidebar link that navigates to a URL (not a tab)\n */\nexport type SidebarTabLink = SidebarTabLinkExternal | SidebarTabLinkInternal\n/**\n * A tab or link in the sidebar tabs bar\n */\nexport type SidebarTab = SidebarTabContent | SidebarTabLink\n\ninterface BaseSidebarTabItem {\n /**\n * Access control function. Called server-side with the current request.\n * Return `false` to hide this item from the nav.\n */\n access?: ItemAccessFunction\n /**\n * Group to add this item to.\n * If matches an existing collection group label, item will be merged into that group.\n * If no match found, a new group will be created with this label.\n * If not specified, item will be shown as ungrouped (position controlled by `position`).\n */\n group?: LocalizedString\n /** Display label */\n label: LocalizedString\n /**\n * Where to place this item relative to collection groups in the tab.\n * - `'top'` — appears above all collection/global groups\n * - `'bottom'` — appears below all groups (default)\n *\n * Has no effect on items that are merged into an existing collection group via `group`.\n * For new custom groups (unmatched `group` label), controls whether the group appears\n * at the top or bottom of the nav.\n *\n * @default 'bottom'\n */\n position?: 'bottom' | 'top'\n /** Unique slug for the item */\n slug: string\n}\ninterface ExternalHrefItem extends BaseSidebarTabItem {\n /** Link href (absolute URL or relative to root) */\n href: string\n /** Whether the link is external, without admin route prefix. */\n isExternal: true\n}\n\ninterface InternalHrefItem extends BaseSidebarTabItem {\n /** Link href (relative to admin route) */\n href: '' | `/${string}`\n /** Whether the link is external, without admin route prefix. */\n isExternal?: false\n}\n/**\n * Custom item inside a sidebar tab\n */\nexport type SidebarTabItem = ExternalHrefItem | InternalHrefItem\n\n// ============================================\n// Custom Component Types\n// ============================================\n\n/**\n * Props received by a custom NavItem component registered via `customComponents.NavItem`.\n *\n * Use the `useNavItemState(href)` hook to get reactive `isActive` / `isCurrentPage` values.\n *\n * @example\n * ```tsx\n * 'use client'\n * import { useNavItemState } from '@veiag/payload-enhanced-sidebar'\n * import type { CustomNavItemProps } from '@veiag/payload-enhanced-sidebar'\n *\n * export const MyNavItem: React.FC<CustomNavItemProps> = ({ entity, href, id, label, badgeConfig }) => {\n * const { isActive, isCurrentPage } = useNavItemState(href)\n * return <a href={href}>{label}</a>\n * }\n * ```\n */\nexport type CustomNavItemProps = {\n /** Badge configuration as defined in the plugin config */\n badgeConfig?: BadgeConfig\n /** The entity (collection, global, or custom item) */\n entity: ExtendedEntity\n /** Computed href with admin route prefix applied */\n href: string\n /** DOM element id */\n id: string\n /** Pre-translated label string */\n label: string\n}\n\n/**\n * Props received by a custom NavGroup component registered via `customComponents.NavGroup`.\n *\n * @example\n * ```tsx\n * 'use client'\n * import type { CustomNavGroupProps } from '@veiag/payload-enhanced-sidebar'\n *\n * export const MyNavGroup: React.FC<CustomNavGroupProps> = ({ label, isOpen, children }) => {\n * return <div><strong>{label}</strong>{children}</div>\n * }\n * ```\n */\nexport type CustomNavGroupProps = {\n /** Nav items inside the group */\n children: ReactNode\n /** Initial open state from nav preferences */\n isOpen?: boolean\n /** Translated group label */\n label: string\n}\n\n/**\n * Props received by a custom tab icon component set via `iconComponent` on a tab or link.\n *\n * @example\n * ```tsx\n * 'use client'\n * import type { CustomTabIconProps } from '@veiag/payload-enhanced-sidebar'\n *\n * export const MyIcon: React.FC<CustomTabIconProps> = ({ id, label }) => (\n * <img alt={label} src={`/icons/${id}.svg`} width={20} height={20} />\n * )\n * ```\n */\nexport type CustomTabIconProps = {\n /** Tab/link id */\n id: string\n /** Pre-translated label */\n label: string\n /** Whether this item is a tab or a link */\n type: 'link' | 'tab'\n}\n\n/**\n * Props received by a custom TabButton component registered via `customComponents.TabButton`.\n * Used for both `tab` and `link` type items in the tabs bar.\n *\n * Use `useTabState(id)` for tab active state, or `usePathname()` for link active state.\n * Use `useEnhancedSidebar().onTabChange` to trigger tab switches.\n *\n * @example\n * ```tsx\n * 'use client'\n * import type { CustomTabButtonProps } from '@veiag/payload-enhanced-sidebar'\n * import { useTabState, useEnhancedSidebar } from '@veiag/payload-enhanced-sidebar'\n *\n * export const MyTabButton: React.FC<CustomTabButtonProps> = ({ id, type, icon, label, href }) => {\n * const { isActive } = useTabState(id)\n * const { onTabChange } = useEnhancedSidebar()\n * if (type === 'link') return <a href={href}>{icon}{label}</a>\n * return <button onClick={() => onTabChange(id)}>{icon}{label}</button>\n * }\n * ```\n */\nexport type CustomTabButtonProps = {\n /** Badge configuration as defined in the plugin config */\n badge?: BadgeConfig\n /** Computed href (for link type, with admin route prefix applied) */\n href?: string\n /** Pre-rendered icon — either from `iconComponent` or the default Lucide icon */\n icon: ReactNode\n /** Tab/link id */\n id: string\n /** Whether the link is external (only set for link type) */\n isExternal?: boolean\n /** Pre-translated label */\n label: string\n /** Item type — use to differentiate rendering */\n type: 'link' | 'tab'\n}\n\n/**\n * Props received by a custom NavContent component registered via `customComponents.NavContent`.\n *\n * Renders in place of the default `<nav>` content area. Use the `useTabState(id)` hook\n * to determine which tab is active and show/hide content accordingly.\n *\n * @example\n * ```tsx\n * 'use client'\n * import type { CustomNavContentProps } from '@veiag/payload-enhanced-sidebar'\n * import { useTabState } from '@veiag/payload-enhanced-sidebar'\n *\n * const TabPanel = ({ id, content }: { id: string; content: React.ReactNode }) => {\n * const { isActive } = useTabState(id)\n * return <div style={{ display: isActive ? undefined : 'none' }}>{content}</div>\n * }\n *\n * export const MyNavContent: React.FC<CustomNavContentProps> = ({\n * tabs, tabsContent, beforeNavLinks, afterNavLinks,\n * }) => {\n * return (\n * <nav>\n * {beforeNavLinks}\n * {tabs.map(tab => <TabPanel key={tab.id} id={tab.id} content={tabsContent[tab.id]} />)}\n * {afterNavLinks}\n * </nav>\n * )\n * }\n * ```\n */\nexport type CustomNavContentProps = {\n /** Rendered afterNavLinks from payload config */\n afterNavLinks?: ReactNode\n /** Content to show when no tabs are defined */\n allContent?: ReactNode\n /** Rendered beforeNavLinks from payload config */\n beforeNavLinks?: ReactNode\n /** Tab definitions (id only) for mapping over */\n tabs: Array<{ id: string }>\n /** Pre-rendered content per tab id */\n tabsContent: Record<string, ReactNode>\n}\n\n/**\n * Configuration for the enhanced sidebar\n */\nexport interface EnhancedSidebarConfig {\n /**\n * Badge configurations for sidebar items (collections, globals, custom items).\n * Key is the slug of the item.\n *\n * @example\n * ```typescript\n * badges: {\n * 'posts': { type: 'collection-count', color: 'primary' },\n * 'orders': { type: 'api', endpoint: '/api/orders/pending', responseKey: 'count' },\n * 'notifications': { type: 'provider', color: 'error' },\n * }\n * ```\n */\n badges?: Record<string, BadgeConfig>\n\n /**\n * Custom components to replace the default NavItem, NavGroup, and/or NavContent rendering.\n * Each field accepts a plain path string or a `SidebarComponent` object `{ path, clientProps }`\n * to forward additional props. The plugin registers them in the import map automatically.\n *\n * @example\n * ```typescript\n * customComponents: {\n * // Plain path\n * NavItem: './components/MySidebar#MyNavItem',\n * // With extra client props forwarded to the component\n * NavGroup: { path: './components/MySidebar#MyNavGroup', clientProps: { collapsible: true } },\n * }\n * ```\n */\n customComponents?: {\n /**\n * Custom NavContent component. Replaces the default `<nav>` content area.\n * Receives `CustomNavContentProps`. Use `useTabState(id)` to check if a tab is active.\n */\n NavContent?: SidebarComponent\n /** Custom NavGroup component. Receives `CustomNavGroupProps`. */\n NavGroup?: SidebarComponent\n /** Custom NavItem component. Receives `CustomNavItemProps`. */\n NavItem?: SidebarComponent\n /**\n * Custom tab button component. Used for both `tab` and `link` items in the tabs bar.\n * Receives `CustomTabButtonProps`. Use `useTabState(id)` and `useEnhancedSidebar()` for state.\n */\n TabButton?: SidebarComponent\n }\n\n /**\n * Disable the plugin\n * @default false\n */\n disabled?: boolean\n\n /**\n * Custom icons for collections and globals in the default tab.\n */\n icons?: {\n collections?: Partial<Record<CollectionSlug, IconName>>\n globals?: Partial<Record<GlobalSlug, IconName>>\n }\n\n /**\n * Show logout button at the bottom of the tabs bar.\n * @default true\n */\n showLogout?: boolean\n\n /**\n * Tabs and links to show in the sidebar tabs bar.\n * Order matters - items are rendered top to bottom.\n *\n * @default [{ type: 'tab', id: 'default', icon: 'LayoutGrid', label: 'Collections' }]\n */\n tabs?: SidebarTab[]\n}\n\n/**\n * Generic document type for collections, with dynamic keys.\n * We assume values are either string or number for simplicity, useAsTitle is making sure of that.\n */\nexport type GenericCollectionDocument = {\n [key: string]: number | string\n id: string\n}\n\ninterface BaseExtendedEntity {\n label: Record<string, string> | string\n slug: string\n type: 'collection' | 'custom' | 'global'\n}\n\ninterface InternalExtendedEntity extends BaseExtendedEntity {\n href?: '' | `/${string}`\n isExternal?: false\n}\n\ninterface ExternalExtendedEntity extends BaseExtendedEntity {\n href: string\n isExternal: true\n}\n\nexport type ExtendedEntity = ExternalExtendedEntity | InternalExtendedEntity\n\nexport type ExtendedGroup = {\n entities: ExtendedEntity[]\n label: Record<string, string> | string\n}\n"],"names":[],"mappings":"AA6iBA,WAGC"}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { icons, LucideIcon } from 'lucide-react'\nimport type { CollectionSlug, GlobalSlug, PayloadRequest, Where } from 'payload'\nimport type { ReactNode } from 'react'\n\nexport type IconName = keyof typeof icons\n\nexport type LocalizedString = { [locale: string]: string } | string\n\nexport type InternalIcon = IconName | LucideIcon\n\n// ============================================\n// Badge Types\n// ============================================\n\n/**\n * Available badge color variants\n */\nexport type BadgeColor = 'default' | 'error' | 'primary' | 'success' | 'warning'\n\n/**\n * Badge configuration For API-based fetching\n */\nexport interface BadgeConfigApi {\n /**\n * Badge color variant\n * @default 'default'\n */\n color?: BadgeColor\n /**\n * API endpoint to fetch badge data from.\n * Can be relative (to current origin) or absolute URL.\n */\n endpoint: string\n /**\n * HTTP method for the request\n * @default 'GET'\n */\n method?: 'GET' | 'POST'\n /**\n * Key in the response object to extract the count from\n * @default 'count'\n */\n responseKey?: string\n type: 'api'\n}\n\n/**\n * Badge configuration for provider-based values.\n * Values are provided via BadgeProvider context.\n */\nexport interface BadgeConfigProvider {\n /**\n * Badge color variant\n * @default 'default'\n */\n color?: BadgeColor\n /**\n * Slug to look up in the BadgeProvider values.\n * If not specified, defaults to the item's id/slug.\n */\n slug?: string\n type: 'provider'\n}\n\n/**\n * Badge configuration for automatic collection document count.\n * Fetches from /api/{collectionSlug}?limit=0 and uses totalDocs.\n */\nexport interface BadgeConfigCollectionCount {\n /**\n * Collection slug to count documents from.\n * If not specified, defaults to the item's slug.\n */\n collectionSlug?: CollectionSlug\n /**\n * Badge color variant\n * @default 'default'\n */\n color?: BadgeColor\n type: 'collection-count'\n /**\n * Optional where query to filter documents.\n * Will be serialized as query string.\n * @example { status: { equals: 'draft' } }\n */\n where?: Where\n}\n\n/**\n * Badge configuration - union of all badge types\n */\nexport type BadgeConfig = BadgeConfigApi | BadgeConfigCollectionCount | BadgeConfigProvider\n\n/**\n * Badge values provided via BadgeProvider context\n */\nexport type BadgeValues = Record<string, number | ReactNode>\n\n// ============================================\n// Access Control Types\n// ============================================\n\n/**\n * Access function for a tab or link in the tabs bar.\n * Return `false` to hide the item entirely (both the button and its content).\n */\nexport type TabAccessFunction = (args: {\n item: SidebarTab\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\n/**\n * Access function for a custom item inside a tab.\n * Return `false` to hide the item from the nav.\n */\nexport type ItemAccessFunction = (args: {\n item: SidebarTabItem\n req: PayloadRequest\n}) => boolean | Promise<boolean>\n\n// ============================================\n// Enhanced Sidebar Types\n// ============================================\n\n/**\n * Path to a component, either as a plain string or as an object with a path and\n * additional client props to forward to the component. Follows Payload's component format.\n *\n * @example\n * ```typescript\n * // Simple path\n * iconComponent: './components/Icons#TabIcon'\n *\n * // With client props — useful for a single component shared across all tabs\n * iconComponent: {\n * path: './components/Icons#TabIcon',\n * clientProps: { icon: 'house' },\n * }\n * ```\n */\nexport type SidebarComponent =\n | {\n /** Additional props forwarded to the component on the client */\n clientProps?: Record<string, unknown>\n /** Component path in Payload's format: `'./path/to/file#ExportName'` */\n path: string\n }\n | string\n\n/**\n * Mutually exclusive icon config: either a Lucide icon name OR a custom icon component path.\n */\ntype TabIconConfig =\n | {\n /** Icon name from lucide-react */\n icon: IconName\n iconComponent?: never\n }\n | {\n icon?: never\n /**\n * Path to a custom icon component. Receives `CustomTabIconProps`.\n * Supports a plain string path or `{ path, clientProps }` to forward extra props.\n * Registered automatically in the import map.\n */\n iconComponent: SidebarComponent\n }\n\n/**\n * Sidebar tab that shows content when selected\n */\nexport type SidebarTabContent = {\n /**\n * Access control function. Called server-side with the current request.\n * Return `false` to hide this tab (button + content) entirely.\n */\n access?: TabAccessFunction\n /**\n * Badge configuration for this tab.\n * Shows a badge on the tab icon in the tabs bar.\n */\n badge?: BadgeConfig\n /**\n * Collections to show in this tab.\n * If not specified, no collections are shown (unless items are specified).\n * Use collection slugs.\n */\n collections?: CollectionSlug[]\n /**\n * Custom items to add to this tab.\n * Items with `group` will be merged into matching collection groups.\n * Items without `group` will be shown at the bottom as a flat list.\n */\n customItems?: SidebarTabItem[]\n /**\n * Globals to show in this tab.\n * If not specified, no globals are shown.\n * Use global slugs.\n */\n globals?: GlobalSlug[]\n /** Unique identifier for the tab */\n id: string\n /** Tooltip/label for the tab */\n label: LocalizedString\n type: 'tab'\n} & TabIconConfig\n\ntype SidebarTabLinkBase = {\n /**\n * Access control function. Called server-side with the current request.\n * Return `false` to hide this link entirely.\n */\n access?: TabAccessFunction\n /**\n * Badge configuration for this link.\n * Shows a badge on the link icon in the tabs bar.\n */\n badge?: BadgeConfig\n /** Unique identifier */\n id: string\n /** Tooltip/label */\n label: LocalizedString\n type: 'link'\n} & TabIconConfig\ntype SidebarTabLinkExternal = {\n /** Link href (absolute URL) */\n href: string\n isExternal: true\n} & SidebarTabLinkBase\ntype SidebarTabLinkInternal = {\n /** Link href (relative to admin route) */\n href: '' | `/${string}`\n isExternal?: false\n} & SidebarTabLinkBase\n/**\n * Sidebar link that navigates to a URL (not a tab)\n */\nexport type SidebarTabLink = SidebarTabLinkExternal | SidebarTabLinkInternal\n/**\n * A custom component rendered in the tabs bar (spacer, separator, badge, etc.).\n * Does not open any content — it's purely a visual slot in the tabs column.\n */\nexport type SidebarTabCustom = {\n /**\n * Access control function. Called server-side with the current request.\n * Return `false` to hide this item entirely.\n */\n access?: TabAccessFunction\n /**\n * Component to render. Receives `{ id }` plus any `clientProps` you pass.\n * Supports a plain string path or `{ path, clientProps }`.\n */\n component: SidebarComponent\n /** Unique identifier */\n id: string\n type: 'custom'\n}\n\n/**\n * Props passed to a custom tabs bar component (spacer, separator, etc.).\n */\nexport type CustomTabsBarComponentProps = {\n id: string\n}\n\n/**\n * A tab, link, or custom component in the sidebar tabs bar\n */\nexport type SidebarTab = SidebarTabContent | SidebarTabCustom | SidebarTabLink\n\ninterface BaseSidebarTabItem {\n /**\n * Access control function. Called server-side with the current request.\n * Return `false` to hide this item from the nav.\n */\n access?: ItemAccessFunction\n /**\n * Group to add this item to.\n * If matches an existing collection group label, item will be merged into that group.\n * If no match found, a new group will be created with this label.\n * If not specified, item will be shown as ungrouped (position controlled by `position`).\n */\n group?: LocalizedString\n /** Display label */\n label: LocalizedString\n /**\n * Where to place this item relative to collection groups in the tab.\n * - `'top'` — appears above all collection/global groups\n * - `'bottom'` — appears below all groups (default)\n *\n * Has no effect on items that are merged into an existing collection group via `group`.\n * For new custom groups (unmatched `group` label), controls whether the group appears\n * at the top or bottom of the nav.\n *\n * @default 'bottom'\n */\n position?: 'bottom' | 'top'\n /** Unique slug for the item */\n slug: string\n}\ninterface ExternalHrefItem extends BaseSidebarTabItem {\n /** Link href (absolute URL or relative to root) */\n href: string\n /** Whether the link is external, without admin route prefix. */\n isExternal: true\n}\n\ninterface InternalHrefItem extends BaseSidebarTabItem {\n /** Link href (relative to admin route) */\n href: '' | `/${string}`\n /** Whether the link is external, without admin route prefix. */\n isExternal?: false\n}\n/**\n * Custom item inside a sidebar tab\n */\nexport type SidebarTabItem = ExternalHrefItem | InternalHrefItem\n\n// ============================================\n// Custom Component Types\n// ============================================\n\n/**\n * Props received by a custom NavItem component registered via `customComponents.NavItem`.\n *\n * Use the `useNavItemState(href)` hook to get reactive `isActive` / `isCurrentPage` values.\n *\n * @example\n * ```tsx\n * 'use client'\n * import { useNavItemState } from '@veiag/payload-enhanced-sidebar'\n * import type { CustomNavItemProps } from '@veiag/payload-enhanced-sidebar'\n *\n * export const MyNavItem: React.FC<CustomNavItemProps> = ({ entity, href, id, label, badgeConfig }) => {\n * const { isActive, isCurrentPage } = useNavItemState(href)\n * return <a href={href}>{label}</a>\n * }\n * ```\n */\nexport type CustomNavItemProps = {\n /** Badge configuration as defined in the plugin config */\n badgeConfig?: BadgeConfig\n /** The entity (collection, global, or custom item) */\n entity: ExtendedEntity\n /** Computed href with admin route prefix applied */\n href: string\n /** DOM element id */\n id: string\n /** Pre-translated label string */\n label: string\n}\n\n/**\n * Props received by a custom NavGroup component registered via `customComponents.NavGroup`.\n *\n * @example\n * ```tsx\n * 'use client'\n * import type { CustomNavGroupProps } from '@veiag/payload-enhanced-sidebar'\n *\n * export const MyNavGroup: React.FC<CustomNavGroupProps> = ({ label, isOpen, children }) => {\n * return <div><strong>{label}</strong>{children}</div>\n * }\n * ```\n */\nexport type CustomNavGroupProps = {\n /** Nav items inside the group */\n children: ReactNode\n /** Initial open state from nav preferences */\n isOpen?: boolean\n /** Translated group label */\n label: string\n}\n\n/**\n * Props received by a custom tab icon component set via `iconComponent` on a tab or link.\n *\n * @example\n * ```tsx\n * 'use client'\n * import type { CustomTabIconProps } from '@veiag/payload-enhanced-sidebar'\n *\n * export const MyIcon: React.FC<CustomTabIconProps> = ({ id, label }) => (\n * <img alt={label} src={`/icons/${id}.svg`} width={20} height={20} />\n * )\n * ```\n */\nexport type CustomTabIconProps = {\n /** Tab/link id */\n id: string\n /** Pre-translated label */\n label: string\n /** Whether this item is a tab or a link */\n type: 'link' | 'tab'\n}\n\n/**\n * Props received by a custom TabButton component registered via `customComponents.TabButton`.\n * Used for both `tab` and `link` type items in the tabs bar.\n *\n * Use `useTabState(id)` for tab active state, or `usePathname()` for link active state.\n * Use `useEnhancedSidebar().onTabChange` to trigger tab switches.\n *\n * @example\n * ```tsx\n * 'use client'\n * import type { CustomTabButtonProps } from '@veiag/payload-enhanced-sidebar'\n * import { useTabState, useEnhancedSidebar } from '@veiag/payload-enhanced-sidebar'\n *\n * export const MyTabButton: React.FC<CustomTabButtonProps> = ({ id, type, icon, label, href }) => {\n * const { isActive } = useTabState(id)\n * const { onTabChange } = useEnhancedSidebar()\n * if (type === 'link') return <a href={href}>{icon}{label}</a>\n * return <button onClick={() => onTabChange(id)}>{icon}{label}</button>\n * }\n * ```\n */\nexport type CustomTabButtonProps = {\n /** Badge configuration as defined in the plugin config */\n badge?: BadgeConfig\n /** Computed href (for link type, with admin route prefix applied) */\n href?: string\n /** Pre-rendered icon — either from `iconComponent` or the default Lucide icon */\n icon: ReactNode\n /** Tab/link id */\n id: string\n /** Whether the link is external (only set for link type) */\n isExternal?: boolean\n /** Pre-translated label */\n label: string\n /** Item type — use to differentiate rendering */\n type: 'link' | 'tab'\n}\n\n/**\n * Props received by a custom NavContent component registered via `customComponents.NavContent`.\n *\n * Renders in place of the default `<nav>` content area. Use the `useTabState(id)` hook\n * to determine which tab is active and show/hide content accordingly.\n *\n * @example\n * ```tsx\n * 'use client'\n * import type { CustomNavContentProps } from '@veiag/payload-enhanced-sidebar'\n * import { useTabState } from '@veiag/payload-enhanced-sidebar'\n *\n * const TabPanel = ({ id, content }: { id: string; content: React.ReactNode }) => {\n * const { isActive } = useTabState(id)\n * return <div style={{ display: isActive ? undefined : 'none' }}>{content}</div>\n * }\n *\n * export const MyNavContent: React.FC<CustomNavContentProps> = ({\n * tabs, tabsContent, beforeNavLinks, afterNavLinks,\n * }) => {\n * return (\n * <nav>\n * {beforeNavLinks}\n * {tabs.map(tab => <TabPanel key={tab.id} id={tab.id} content={tabsContent[tab.id]} />)}\n * {afterNavLinks}\n * </nav>\n * )\n * }\n * ```\n */\nexport type CustomNavContentProps = {\n /** Rendered afterNavLinks from payload config */\n afterNavLinks?: ReactNode\n /** Content to show when no tabs are defined */\n allContent?: ReactNode\n /** Rendered beforeNavLinks from payload config */\n beforeNavLinks?: ReactNode\n /** Tab definitions (id only) for mapping over */\n tabs: Array<{ id: string }>\n /** Pre-rendered content per tab id */\n tabsContent: Record<string, ReactNode>\n}\n\n/**\n * Configuration for the enhanced sidebar\n */\nexport interface EnhancedSidebarConfig {\n /**\n * Badge configurations for sidebar items (collections, globals, custom items).\n * Key is the slug of the item.\n *\n * @example\n * ```typescript\n * badges: {\n * 'posts': { type: 'collection-count', color: 'primary' },\n * 'orders': { type: 'api', endpoint: '/api/orders/pending', responseKey: 'count' },\n * 'notifications': { type: 'provider', color: 'error' },\n * }\n * ```\n */\n badges?: Record<string, BadgeConfig>\n\n /**\n * Custom components to replace the default NavItem, NavGroup, and/or NavContent rendering.\n * Each field accepts a plain path string or a `SidebarComponent` object `{ path, clientProps }`\n * to forward additional props. The plugin registers them in the import map automatically.\n *\n * @example\n * ```typescript\n * customComponents: {\n * // Plain path\n * NavItem: './components/MySidebar#MyNavItem',\n * // With extra client props forwarded to the component\n * NavGroup: { path: './components/MySidebar#MyNavGroup', clientProps: { collapsible: true } },\n * }\n * ```\n */\n customComponents?: {\n /**\n * Custom NavContent component. Replaces the default `<nav>` content area.\n * Receives `CustomNavContentProps`. Use `useTabState(id)` to check if a tab is active.\n */\n NavContent?: SidebarComponent\n /** Custom NavGroup component. Receives `CustomNavGroupProps`. */\n NavGroup?: SidebarComponent\n /** Custom NavItem component. Receives `CustomNavItemProps`. */\n NavItem?: SidebarComponent\n /**\n * Custom tab button component. Used for both `tab` and `link` items in the tabs bar.\n * Receives `CustomTabButtonProps`. Use `useTabState(id)` and `useEnhancedSidebar()` for state.\n */\n TabButton?: SidebarComponent\n }\n\n /**\n * Disable the plugin\n * @default false\n */\n disabled?: boolean\n\n /**\n * Show logout button at the bottom of the tabs bar.\n * @default true\n */\n showLogout?: boolean\n\n /**\n * Tabs and links to show in the sidebar tabs bar.\n * Order matters - items are rendered top to bottom.\n *\n * @default [{ type: 'tab', id: 'default', icon: 'LayoutGrid', label: 'Collections' }]\n */\n tabs?: SidebarTab[]\n}\n\n/**\n * Generic document type for collections, with dynamic keys.\n * We assume values are either string or number for simplicity, useAsTitle is making sure of that.\n */\nexport type GenericCollectionDocument = {\n [key: string]: number | string\n id: string\n}\n\ninterface BaseExtendedEntity {\n label: Record<string, string> | string\n slug: string\n // 'collections' | 'globals' are EntityType enum values from groupNavItems output; 'custom' is ours\n type: 'collections' | 'custom' | 'globals'\n}\n\ninterface InternalExtendedEntity extends BaseExtendedEntity {\n href?: '' | `/${string}`\n isExternal?: false\n}\n\ninterface ExternalExtendedEntity extends BaseExtendedEntity {\n href: string\n isExternal: true\n}\n\nexport type ExtendedEntity = ExternalExtendedEntity | InternalExtendedEntity\n\nexport type ExtendedGroup = {\n entities: ExtendedEntity[]\n label: Record<string, string> | string\n}\n"],"names":[],"mappings":"AAikBA,WAGC"}
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["import type { EnhancedSidebarConfig, LocalizedString, SidebarComponent } from '../types'\n\nexport const convertSlugToTitle = (slug: string): string => {\n return slug.replace(/-/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())\n}\n\n/**\n * Extracts path and clientProps from a SidebarComponent (string or object).\n */\nexport const resolveSidebarComponent = (\n component: SidebarComponent,\n): { clientProps: Record<string, unknown>; path: string } => {\n if (typeof component === 'string') {\n return { clientProps: {}, path: component }\n }\n return { clientProps: component.clientProps ?? {}, path: component.path }\n}\n\n/**\n * Strips all non-serializable values (functions) from the sidebar config\n * before passing it to client components.\n */\nexport const sanitizeSidebarConfig = (config: EnhancedSidebarConfig): EnhancedSidebarConfig => ({\n ...config,\n tabs: config.tabs?.map((tab) => {\n const { access: _, ...tabRest } = tab\n if (tabRest.type === 'tab' && tabRest.customItems) {\n return {\n ...tabRest,\n customItems: tabRest.customItems.map(({ access: __, ...item }) => item),\n }\n }\n return tabRest\n }),\n})\n\nexport const extractLocalizedValue = (\n value: LocalizedString | undefined,\n locale: string,\n fallbackSlug?: string,\n): string => {\n if (!value) {\n return fallbackSlug ? convertSlugToTitle(fallbackSlug) : ''\n }\n if (typeof value === 'string') {\n return value\n }\n return value[locale] || Object.values(value)[0] || (fallbackSlug ? convertSlugToTitle(fallbackSlug) : '')\n}\n"],"names":["convertSlugToTitle","slug","replace","char","toUpperCase","resolveSidebarComponent","component","clientProps","path","sanitizeSidebarConfig","config","tabs","map","tab","access","_","tabRest","type","customItems","__","item","extractLocalizedValue","value","locale","fallbackSlug","Object","values"],"mappings":"AAEA,OAAO,MAAMA,qBAAqB,CAACC;IACjC,OAAOA,KAAKC,OAAO,CAAC,MAAM,KAAKA,OAAO,CAAC,SAAS,CAACC,OAASA,KAAKC,WAAW;AAC5E,EAAC;AAED;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CACrCC;IAEA,IAAI,OAAOA,cAAc,UAAU;QACjC,OAAO;YAAEC,aAAa,CAAC;YAAGC,MAAMF;QAAU;IAC5C;IACA,OAAO;QAAEC,aAAaD,UAAUC,WAAW,IAAI,CAAC;QAAGC,MAAMF,UAAUE,IAAI;IAAC;AAC1E,EAAC;AAED;;;CAGC,GACD,OAAO,MAAMC,wBAAwB,CAACC,SAA0D,CAAA;QAC9F,GAAGA,MAAM;QACTC,MAAMD,OAAOC,IAAI,EAAEC,IAAI,CAACC;YACtB,MAAM,EAAEC,QAAQC,CAAC,EAAE,GAAGC,SAAS,GAAGH;YAClC,IAAIG,QAAQC,IAAI,KAAK,SAASD,QAAQE,WAAW,EAAE;gBACjD,OAAO;oBACL,GAAGF,OAAO;oBACVE,aAAaF,QAAQE,WAAW,CAACN,GAAG,CAAC,CAAC,EAAEE,QAAQK,EAAE,EAAE,GAAGC,MAAM,GAAKA;gBACpE;YACF;YACA,OAAOJ;QACT;IACF,CAAA,EAAE;
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["import type { EnhancedSidebarConfig, LocalizedString, SidebarComponent } from '../types'\n\nexport const convertSlugToTitle = (slug: string): string => {\n return slug.replace(/-/g, ' ').replace(/\\b\\w/g, (char) => char.toUpperCase())\n}\n\n/**\n * Extracts path and clientProps from a SidebarComponent (string or object).\n */\nexport const resolveSidebarComponent = (\n component: SidebarComponent,\n): { clientProps: Record<string, unknown>; path: string } => {\n if (typeof component === 'string') {\n return { clientProps: {}, path: component }\n }\n return { clientProps: component.clientProps ?? {}, path: component.path }\n}\n\n/**\n * Strips all non-serializable values (functions) from the sidebar config\n * before passing it to client components.\n */\nexport const sanitizeSidebarConfig = (config: EnhancedSidebarConfig): EnhancedSidebarConfig => ({\n ...config,\n tabs: config.tabs?.map((tab) => {\n const { access: _, ...tabRest } = tab\n if (tabRest.type === 'tab' && tabRest.customItems) {\n return {\n ...tabRest,\n customItems: tabRest.customItems.map(({ access: __, ...item }) => item),\n }\n }\n return tabRest\n }),\n})\n\n\nexport const extractLocalizedValue = (\n value: LocalizedString | undefined,\n locale: string,\n fallbackSlug?: string,\n): string => {\n if (!value) {\n return fallbackSlug ? convertSlugToTitle(fallbackSlug) : ''\n }\n if (typeof value === 'string') {\n return value\n }\n return value[locale] || Object.values(value)[0] || (fallbackSlug ? convertSlugToTitle(fallbackSlug) : '')\n}\n"],"names":["convertSlugToTitle","slug","replace","char","toUpperCase","resolveSidebarComponent","component","clientProps","path","sanitizeSidebarConfig","config","tabs","map","tab","access","_","tabRest","type","customItems","__","item","extractLocalizedValue","value","locale","fallbackSlug","Object","values"],"mappings":"AAEA,OAAO,MAAMA,qBAAqB,CAACC;IACjC,OAAOA,KAAKC,OAAO,CAAC,MAAM,KAAKA,OAAO,CAAC,SAAS,CAACC,OAASA,KAAKC,WAAW;AAC5E,EAAC;AAED;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CACrCC;IAEA,IAAI,OAAOA,cAAc,UAAU;QACjC,OAAO;YAAEC,aAAa,CAAC;YAAGC,MAAMF;QAAU;IAC5C;IACA,OAAO;QAAEC,aAAaD,UAAUC,WAAW,IAAI,CAAC;QAAGC,MAAMF,UAAUE,IAAI;IAAC;AAC1E,EAAC;AAED;;;CAGC,GACD,OAAO,MAAMC,wBAAwB,CAACC,SAA0D,CAAA;QAC9F,GAAGA,MAAM;QACTC,MAAMD,OAAOC,IAAI,EAAEC,IAAI,CAACC;YACtB,MAAM,EAAEC,QAAQC,CAAC,EAAE,GAAGC,SAAS,GAAGH;YAClC,IAAIG,QAAQC,IAAI,KAAK,SAASD,QAAQE,WAAW,EAAE;gBACjD,OAAO;oBACL,GAAGF,OAAO;oBACVE,aAAaF,QAAQE,WAAW,CAACN,GAAG,CAAC,CAAC,EAAEE,QAAQK,EAAE,EAAE,GAAGC,MAAM,GAAKA;gBACpE;YACF;YACA,OAAOJ;QACT;IACF,CAAA,EAAE;AAGF,OAAO,MAAMK,wBAAwB,CACnCC,OACAC,QACAC;IAEA,IAAI,CAACF,OAAO;QACV,OAAOE,eAAexB,mBAAmBwB,gBAAgB;IAC3D;IACA,IAAI,OAAOF,UAAU,UAAU;QAC7B,OAAOA;IACT;IACA,OAAOA,KAAK,CAACC,OAAO,IAAIE,OAAOC,MAAM,CAACJ,MAAM,CAAC,EAAE,IAAKE,CAAAA,eAAexB,mBAAmBwB,gBAAgB,EAAC;AACzG,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veiag/payload-enhanced-sidebar",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.4",
|
|
4
4
|
"description": "An enhanced sidebar plugin for Payload CMS with tabbed navigation to organize collections and globals.",
|
|
5
5
|
"author": "VeiaG",
|
|
6
6
|
"license": "MIT",
|