@foundrykit/menu-plugin 0.4.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,14 +5,22 @@ A [Payload CMS](https://payloadcms.com) v3 plugin that adds a configurable menu
5
5
  ## Features
6
6
 
7
7
  - Multiple item types: internal, external, reference, anchor, mailto, tel, custom
8
+ - Three item kinds: simple link, nested dropdown, and mega menu
9
+ - Mega menus with a flat rows-with-reveal model (`reveal` layout) or classic
10
+ multi-column layout (`columns`), each with a featured panel
11
+ - Dynamic mega entries that auto-populate their children (and featured content)
12
+ from a related collection, resolved server-side via an `afterRead` hook
8
13
  - Nested dropdown menus with configurable depth
9
14
  - Admin URL field UI for internal paths, phone numbers, anchors, and email links
10
15
  - Public `GET /api/menus/:slug` endpoint with locale and depth support
11
16
  - Optional import/export endpoints with admin-only access by default
12
17
  - Server-side menu caching with automatic invalidation
13
18
  - Frontend-safe `fetchMenu` helper plus a `useMenu` hook built on top of it
14
- - Per-item visibility, target, rel, roles, and custom attributes
19
+ - Per-item display surface (navbar / drawer / both), visibility, target, rel,
20
+ roles, and custom attributes
15
21
  - Localized menu identity using `slug + locale`
22
+ - Migration helper to convert legacy `megaColumns` data to the new `megaEntries`
23
+ shape
16
24
 
17
25
  ## Installation
18
26
 
@@ -44,9 +52,12 @@ This registers a `menus` collection in Payload.
44
52
  |---|---|---|---|
45
53
  | `baseUrl` | `string` | `''` | Base URL prefix shown for internal links in the admin |
46
54
  | `cacheTTL` | `number` | `60000` | Server cache TTL in milliseconds |
55
+ | `childrenDepth` | `number` | `1` | Relationship `depth` used when resolving dynamic mega entry children |
47
56
  | `disabled` | `boolean` | `false` | Keep the collection schema, but disable plugin runtime endpoints, hooks, and admin helper UI |
57
+ | `dynamicSources` | `DynamicSource[]` | `[]` | Sources used to auto-populate dynamic mega entries from related collections (see below) |
48
58
  | `enableImportExport` | `boolean` | `true` | Register the import/export endpoints |
49
- | `maxDepth` | `number` | `2` | Maximum nesting depth for dropdown items |
59
+ | `maxDepth` | `number` | `1` | Maximum nesting depth for dropdown items |
60
+ | `mediaCollection` | `string` | `undefined` | Upload collection used for mega menu featured images |
50
61
  | `relationTo` | `string \| string[]` | `'pages'` | Collection(s) available for reference links |
51
62
  | `requireAdminForImportExport` | `boolean` | `true` | Require an authenticated admin user for import/export endpoints |
52
63
 
@@ -69,6 +80,80 @@ Menus are uniquely identified by `slug + locale`.
69
80
  - locale values are normalized to lowercase
70
81
  - a menu with no locale is treated as a separate default variant
71
82
 
83
+ ## Mega Menus
84
+
85
+ Each menu item has a kind (`itemType`): `link`, `dropdown`, or `mega`. A mega item
86
+ exposes:
87
+
88
+ - `megaLayout`: `reveal` (default — a flat list of rows that reveal their
89
+ children in a second panel) or `columns` (classic multi-column layout)
90
+ - `defaultFeatured`: a fallback featured panel (image, heading, description, CTA)
91
+ - `megaEntries`: a flat list of entries. Each entry is itself a link and can
92
+ reveal `children` in a secondary panel, plus an optional per-entry `featured`
93
+ panel whose `mode` is `inherit` (use `defaultFeatured`), `manual`, or `dynamic`.
94
+
95
+ Featured images use the `mediaCollection` option as their upload `relationTo`.
96
+
97
+ ### Dynamic mega entries
98
+
99
+ An entry's `source` can be `manual` (children typed by hand) or `dynamic`
100
+ (children pulled from a related collection). Dynamic entries are resolved
101
+ server-side by an `afterRead` hook on the `menus` collection, so they work
102
+ through every read path — the `/api/menus/:slug` endpoint, `payload.find`, and
103
+ `menus` populated as a relationship on another global/collection — with no extra
104
+ wiring. Resolution is read-only, idempotent, locale-aware, and degrades to empty
105
+ children on misconfiguration (never throws).
106
+
107
+ Configure the available sources via `dynamicSources`:
108
+
109
+ ```ts
110
+ import { menuPlugin, type DynamicSource } from '@foundrykit/menu-plugin'
111
+
112
+ const destinations: DynamicSource = {
113
+ name: 'destinations',
114
+ label: 'Destinations',
115
+ collection: 'destinations', // queried for children
116
+ parentCollection: 'regions', // editor picks a parent from here
117
+ parentField: 'region', // field on a child relating it to its parent
118
+ labelField: 'title', // child field used as the label
119
+ hrefBuilder: (doc) => `/destinations/${doc.slug as string}`,
120
+ sort: 'title',
121
+ limit: 0, // optional; defaults to 0 (return all)
122
+ featured: {
123
+ imageField: 'heroImage', // dot-path to an upload/media field
124
+ headingField: 'title',
125
+ descriptionField: 'excerpt',
126
+ ctaHrefBuilder: (doc) => `/destinations/${doc.slug as string}`,
127
+ ctaLabel: 'Explore',
128
+ },
129
+ }
130
+
131
+ menuPlugin({
132
+ relationTo: ['pages'],
133
+ mediaCollection: 'media',
134
+ dynamicSources: [destinations],
135
+ })
136
+ ```
137
+
138
+ When exactly one source is configured, the entry's `dynamicSource` select is
139
+ hidden and auto-set, and the `parent` relationship collapses to that single
140
+ collection. With multiple sources, the editor chooses a source and the `parent`
141
+ relationship spans the union of all configured `parentCollection`s.
142
+
143
+ ### Migrating legacy `megaColumns` data
144
+
145
+ Earlier versions modelled mega menus as `megaColumns`. Convert existing data to
146
+ the new `megaEntries` shape with the exported helper. It is safe to run multiple
147
+ times — already-migrated documents are skipped.
148
+
149
+ ```ts
150
+ import { migrateMegaColumnsToEntries } from '@foundrykit/menu-plugin'
151
+
152
+ // `payload` is an initialised Payload instance
153
+ const { migrated, scanned } = await migrateMegaColumnsToEntries(payload)
154
+ console.log(`Migrated ${migrated} of ${scanned} menus`)
155
+ ```
156
+
72
157
  ## REST API
73
158
 
74
159
  ### Get a menu by slug
@@ -1,6 +1,7 @@
1
1
  import type { CollectionConfig } from 'payload';
2
2
  import { type MenuItemFieldOptions } from '../fields/MenuItem.js';
3
- export type MenusCollectionOptions = MenuItemFieldOptions & {
3
+ export type MenusCollectionOptions = {
4
+ childrenDepth?: number;
4
5
  disabled?: boolean;
5
- };
6
+ } & MenuItemFieldOptions;
6
7
  export declare const createMenusCollection: (options?: MenusCollectionOptions) => CollectionConfig;
@@ -1,5 +1,6 @@
1
1
  import { menuCache } from '../cache.js';
2
2
  import { createMenuItemFields } from '../fields/MenuItem.js';
3
+ import { createResolveDynamicMenuHook } from '../hooks/resolveDynamicMenu.js';
3
4
  import { buildMenuIdentityKey, normalizeMenuLocale } from '../utilities/menuIdentity.js';
4
5
  export const createMenusCollection = (options)=>({
5
6
  slug: 'menus',
@@ -86,7 +87,9 @@ export const createMenusCollection = (options)=>({
86
87
  hooks: {
87
88
  beforeValidate: [
88
89
  ({ data })=>{
89
- if (!data) return data;
90
+ if (!data) {
91
+ return data;
92
+ }
90
93
  const normalizedLocale = normalizeMenuLocale(data.locale);
91
94
  return {
92
95
  ...data,
@@ -114,6 +117,12 @@ export const createMenusCollection = (options)=>({
114
117
  }
115
118
  return doc;
116
119
  }
120
+ ],
121
+ afterRead: [
122
+ createResolveDynamicMenuHook({
123
+ childrenDepth: options?.childrenDepth,
124
+ dynamicSources: options?.dynamicSources
125
+ })
117
126
  ]
118
127
  }
119
128
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/collections/Menus.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport { menuCache } from '../cache.js'\nimport { createMenuItemFields, type MenuItemFieldOptions } from '../fields/MenuItem.js'\nimport { buildMenuIdentityKey, normalizeMenuLocale } from '../utilities/menuIdentity.js'\n\nexport type MenusCollectionOptions = MenuItemFieldOptions & {\n disabled?: boolean\n}\n\nexport const createMenusCollection = (options?: MenusCollectionOptions): CollectionConfig => ({\n slug: 'menus',\n access: {\n read: () => true,\n },\n admin: {\n defaultColumns: ['title', 'slug', 'locale', 'items'],\n useAsTitle: 'title',\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n admin: {\n description: 'The name of the menu. E.g. \"Main Menu\", \"Footer Menu\", etc.',\n },\n required: true,\n },\n {\n name: 'slug',\n type: 'text',\n admin: {\n description:\n 'Unique identifier for the menu, used in API requests. E.g. \"main-menu\", \"footer-menu\", etc.',\n },\n index: true,\n required: true,\n },\n {\n name: 'description',\n type: 'textarea',\n admin: {\n description: 'Optional description for the menu.',\n position: 'sidebar',\n },\n },\n {\n name: 'locale',\n type: 'text',\n admin: {\n description: 'Used for localisation. E.g. \"en\", \"fr\", etc.',\n position: 'sidebar',\n },\n },\n ...(options?.disabled\n ? []\n : [\n {\n name: 'menuPreview',\n type: 'ui',\n admin: {\n components: {\n Field: '@foundrykit/menu-plugin/client#MenuPreview',\n },\n position: 'sidebar',\n },\n } as const,\n ]),\n {\n name: 'slugLocaleKey',\n type: 'text',\n admin: {\n hidden: true,\n },\n index: true,\n unique: true,\n },\n {\n name: 'items',\n type: 'array',\n admin: {\n ...(options?.disabled\n ? {}\n : {\n components: {\n RowLabel: '@foundrykit/menu-plugin/client#MenuItemRowLabel',\n },\n }),\n },\n fields: createMenuItemFields(options),\n },\n ],\n hooks: {\n beforeValidate: [\n ({ data }) => {\n if (!data) return data\n\n const normalizedLocale = normalizeMenuLocale(data.locale)\n\n return {\n ...data,\n locale: normalizedLocale,\n slugLocaleKey: data.slug ? buildMenuIdentityKey(data.slug, normalizedLocale) : data.slugLocaleKey,\n }\n },\n ],\n ...(options?.disabled\n ? {}\n : {\n afterChange: [\n ({ doc, previousDoc }) => {\n if (previousDoc?.slug) {\n menuCache.invalidate(previousDoc.slug)\n }\n if (doc.slug) {\n menuCache.invalidate(doc.slug)\n }\n return doc\n },\n ],\n afterDelete: [\n ({ doc }) => {\n if (doc.slug) {\n menuCache.invalidate(doc.slug)\n }\n return doc\n },\n ],\n }),\n },\n labels: {\n plural: 'Menus',\n singular: 'Menu',\n },\n timestamps: true,\n})\n"],"names":["menuCache","createMenuItemFields","buildMenuIdentityKey","normalizeMenuLocale","createMenusCollection","options","slug","access","read","admin","defaultColumns","useAsTitle","fields","name","type","description","required","index","position","disabled","components","Field","hidden","unique","RowLabel","hooks","beforeValidate","data","normalizedLocale","locale","slugLocaleKey","afterChange","doc","previousDoc","invalidate","afterDelete","labels","plural","singular","timestamps"],"mappings":"AAEA,SAASA,SAAS,QAAQ,cAAa;AACvC,SAASC,oBAAoB,QAAmC,wBAAuB;AACvF,SAASC,oBAAoB,EAAEC,mBAAmB,QAAQ,+BAA8B;AAMxF,OAAO,MAAMC,wBAAwB,CAACC,UAAwD,CAAA;QAC5FC,MAAM;QACNC,QAAQ;YACNC,MAAM,IAAM;QACd;QACAC,OAAO;YACLC,gBAAgB;gBAAC;gBAAS;gBAAQ;gBAAU;aAAQ;YACpDC,YAAY;QACd;QACAC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,aAAa;gBACf;gBACAC,UAAU;YACZ;YACA;gBACEH,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,aACE;gBACJ;gBACAE,OAAO;gBACPD,UAAU;YACZ;YACA;gBACEH,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,aAAa;oBACbG,UAAU;gBACZ;YACF;YACA;gBACEL,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,aAAa;oBACbG,UAAU;gBACZ;YACF;eACIb,SAASc,WACT,EAAE,GACF;gBACE;oBACEN,MAAM;oBACNC,MAAM;oBACNL,OAAO;wBACLW,YAAY;4BACVC,OAAO;wBACT;wBACAH,UAAU;oBACZ;gBACF;aACD;YACL;gBACEL,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLa,QAAQ;gBACV;gBACAL,OAAO;gBACPM,QAAQ;YACV;YACA;gBACEV,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACL,GAAIJ,SAASc,WACT,CAAC,IACD;wBACEC,YAAY;4BACVI,UAAU;wBACZ;oBACF,CAAC;gBACP;gBACAZ,QAAQX,qBAAqBI;YAC/B;SACD;QACDoB,OAAO;YACLC,gBAAgB;gBACd,CAAC,EAAEC,IAAI,EAAE;oBACP,IAAI,CAACA,MAAM,OAAOA;oBAElB,MAAMC,mBAAmBzB,oBAAoBwB,KAAKE,MAAM;oBAExD,OAAO;wBACL,GAAGF,IAAI;wBACPE,QAAQD;wBACRE,eAAeH,KAAKrB,IAAI,GAAGJ,qBAAqByB,KAAKrB,IAAI,EAAEsB,oBAAoBD,KAAKG,aAAa;oBACnG;gBACF;aACD;YACD,GAAIzB,SAASc,WACT,CAAC,IACD;gBACEY,aAAa;oBACX,CAAC,EAAEC,GAAG,EAAEC,WAAW,EAAE;wBACnB,IAAIA,aAAa3B,MAAM;4BACrBN,UAAUkC,UAAU,CAACD,YAAY3B,IAAI;wBACvC;wBACA,IAAI0B,IAAI1B,IAAI,EAAE;4BACZN,UAAUkC,UAAU,CAACF,IAAI1B,IAAI;wBAC/B;wBACA,OAAO0B;oBACT;iBACD;gBACDG,aAAa;oBACX,CAAC,EAAEH,GAAG,EAAE;wBACN,IAAIA,IAAI1B,IAAI,EAAE;4BACZN,UAAUkC,UAAU,CAACF,IAAI1B,IAAI;wBAC/B;wBACA,OAAO0B;oBACT;iBACD;YACH,CAAC;QACP;QACAI,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;QACAC,YAAY;IACd,CAAA,EAAE"}
1
+ {"version":3,"sources":["../../src/collections/Menus.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport { menuCache } from '../cache.js'\nimport { createMenuItemFields, type MenuItemFieldOptions } from '../fields/MenuItem.js'\nimport { createResolveDynamicMenuHook } from '../hooks/resolveDynamicMenu.js'\nimport { buildMenuIdentityKey, normalizeMenuLocale } from '../utilities/menuIdentity.js'\n\nexport type MenusCollectionOptions = {\n childrenDepth?: number\n disabled?: boolean\n} & MenuItemFieldOptions\n\nexport const createMenusCollection = (options?: MenusCollectionOptions): CollectionConfig => ({\n slug: 'menus',\n access: {\n read: () => true,\n },\n admin: {\n defaultColumns: ['title', 'slug', 'locale', 'items'],\n useAsTitle: 'title',\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n admin: {\n description: 'The name of the menu. E.g. \"Main Menu\", \"Footer Menu\", etc.',\n },\n required: true,\n },\n {\n name: 'slug',\n type: 'text',\n admin: {\n description:\n 'Unique identifier for the menu, used in API requests. E.g. \"main-menu\", \"footer-menu\", etc.',\n },\n index: true,\n required: true,\n },\n {\n name: 'description',\n type: 'textarea',\n admin: {\n description: 'Optional description for the menu.',\n position: 'sidebar',\n },\n },\n {\n name: 'locale',\n type: 'text',\n admin: {\n description: 'Used for localisation. E.g. \"en\", \"fr\", etc.',\n position: 'sidebar',\n },\n },\n ...(options?.disabled\n ? []\n : [\n {\n name: 'menuPreview',\n type: 'ui',\n admin: {\n components: {\n Field: '@foundrykit/menu-plugin/client#MenuPreview',\n },\n position: 'sidebar',\n },\n } as const,\n ]),\n {\n name: 'slugLocaleKey',\n type: 'text',\n admin: {\n hidden: true,\n },\n index: true,\n unique: true,\n },\n {\n name: 'items',\n type: 'array',\n admin: {\n ...(options?.disabled\n ? {}\n : {\n components: {\n RowLabel: '@foundrykit/menu-plugin/client#MenuItemRowLabel',\n },\n }),\n },\n fields: createMenuItemFields(options),\n },\n ],\n hooks: {\n beforeValidate: [\n ({ data }) => {\n if (!data) {return data}\n\n const normalizedLocale = normalizeMenuLocale(data.locale)\n\n return {\n ...data,\n locale: normalizedLocale,\n slugLocaleKey: data.slug ? buildMenuIdentityKey(data.slug, normalizedLocale) : data.slugLocaleKey,\n }\n },\n ],\n ...(options?.disabled\n ? {}\n : {\n afterChange: [\n ({ doc, previousDoc }) => {\n if (previousDoc?.slug) {\n menuCache.invalidate(previousDoc.slug)\n }\n if (doc.slug) {\n menuCache.invalidate(doc.slug)\n }\n return doc\n },\n ],\n afterDelete: [\n ({ doc }) => {\n if (doc.slug) {\n menuCache.invalidate(doc.slug)\n }\n return doc\n },\n ],\n afterRead: [\n createResolveDynamicMenuHook({\n childrenDepth: options?.childrenDepth,\n dynamicSources: options?.dynamicSources,\n }),\n ],\n }),\n },\n labels: {\n plural: 'Menus',\n singular: 'Menu',\n },\n timestamps: true,\n})\n"],"names":["menuCache","createMenuItemFields","createResolveDynamicMenuHook","buildMenuIdentityKey","normalizeMenuLocale","createMenusCollection","options","slug","access","read","admin","defaultColumns","useAsTitle","fields","name","type","description","required","index","position","disabled","components","Field","hidden","unique","RowLabel","hooks","beforeValidate","data","normalizedLocale","locale","slugLocaleKey","afterChange","doc","previousDoc","invalidate","afterDelete","afterRead","childrenDepth","dynamicSources","labels","plural","singular","timestamps"],"mappings":"AAEA,SAASA,SAAS,QAAQ,cAAa;AACvC,SAASC,oBAAoB,QAAmC,wBAAuB;AACvF,SAASC,4BAA4B,QAAQ,iCAAgC;AAC7E,SAASC,oBAAoB,EAAEC,mBAAmB,QAAQ,+BAA8B;AAOxF,OAAO,MAAMC,wBAAwB,CAACC,UAAwD,CAAA;QAC5FC,MAAM;QACNC,QAAQ;YACNC,MAAM,IAAM;QACd;QACAC,OAAO;YACLC,gBAAgB;gBAAC;gBAAS;gBAAQ;gBAAU;aAAQ;YACpDC,YAAY;QACd;QACAC,QAAQ;YACN;gBACEC,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,aAAa;gBACf;gBACAC,UAAU;YACZ;YACA;gBACEH,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,aACE;gBACJ;gBACAE,OAAO;gBACPD,UAAU;YACZ;YACA;gBACEH,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,aAAa;oBACbG,UAAU;gBACZ;YACF;YACA;gBACEL,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLM,aAAa;oBACbG,UAAU;gBACZ;YACF;eACIb,SAASc,WACT,EAAE,GACF;gBACE;oBACEN,MAAM;oBACNC,MAAM;oBACNL,OAAO;wBACLW,YAAY;4BACVC,OAAO;wBACT;wBACAH,UAAU;oBACZ;gBACF;aACD;YACL;gBACEL,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACLa,QAAQ;gBACV;gBACAL,OAAO;gBACPM,QAAQ;YACV;YACA;gBACEV,MAAM;gBACNC,MAAM;gBACNL,OAAO;oBACL,GAAIJ,SAASc,WACT,CAAC,IACD;wBACEC,YAAY;4BACVI,UAAU;wBACZ;oBACF,CAAC;gBACP;gBACAZ,QAAQZ,qBAAqBK;YAC/B;SACD;QACDoB,OAAO;YACLC,gBAAgB;gBACd,CAAC,EAAEC,IAAI,EAAE;oBACP,IAAI,CAACA,MAAM;wBAAC,OAAOA;oBAAI;oBAEvB,MAAMC,mBAAmBzB,oBAAoBwB,KAAKE,MAAM;oBAExD,OAAO;wBACL,GAAGF,IAAI;wBACPE,QAAQD;wBACRE,eAAeH,KAAKrB,IAAI,GAAGJ,qBAAqByB,KAAKrB,IAAI,EAAEsB,oBAAoBD,KAAKG,aAAa;oBACnG;gBACF;aACD;YACD,GAAIzB,SAASc,WACT,CAAC,IACD;gBACEY,aAAa;oBACX,CAAC,EAAEC,GAAG,EAAEC,WAAW,EAAE;wBACnB,IAAIA,aAAa3B,MAAM;4BACrBP,UAAUmC,UAAU,CAACD,YAAY3B,IAAI;wBACvC;wBACA,IAAI0B,IAAI1B,IAAI,EAAE;4BACZP,UAAUmC,UAAU,CAACF,IAAI1B,IAAI;wBAC/B;wBACA,OAAO0B;oBACT;iBACD;gBACDG,aAAa;oBACX,CAAC,EAAEH,GAAG,EAAE;wBACN,IAAIA,IAAI1B,IAAI,EAAE;4BACZP,UAAUmC,UAAU,CAACF,IAAI1B,IAAI;wBAC/B;wBACA,OAAO0B;oBACT;iBACD;gBACDI,WAAW;oBACTnC,6BAA6B;wBAC3BoC,eAAehC,SAASgC;wBACxBC,gBAAgBjC,SAASiC;oBAC3B;iBACD;YACH,CAAC;QACP;QACAC,QAAQ;YACNC,QAAQ;YACRC,UAAU;QACZ;QACAC,YAAY;IACd,CAAA,EAAE"}
@@ -0,0 +1 @@
1
+ export declare const MegaEntryRowLabel: () => import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useRowLabel } from '@payloadcms/ui';
4
+ export const MegaEntryRowLabel = ()=>{
5
+ const { data, rowNumber } = useRowLabel();
6
+ const suffix = data.source === 'dynamic' ? ' (dynamic)' : '';
7
+ return /*#__PURE__*/ _jsx("div", {
8
+ children: `Entry: ${data.label || String(rowNumber).padStart(2, '0')}${suffix}`
9
+ });
10
+ };
11
+
12
+ //# sourceMappingURL=MegaEntryRowLabel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/MegaEntryRowLabel.tsx"],"sourcesContent":["'use client'\n\nimport { useRowLabel } from '@payloadcms/ui'\n\nexport const MegaEntryRowLabel = () => {\n const { data, rowNumber } = useRowLabel<{ label?: string; source?: string }>()\n\n const suffix = data.source === 'dynamic' ? ' (dynamic)' : ''\n\n return <div>{`Entry: ${data.label || String(rowNumber).padStart(2, '0')}${suffix}`}</div>\n}\n"],"names":["useRowLabel","MegaEntryRowLabel","data","rowNumber","suffix","source","div","label","String","padStart"],"mappings":"AAAA;;AAEA,SAASA,WAAW,QAAQ,iBAAgB;AAE5C,OAAO,MAAMC,oBAAoB;IAC/B,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAE,GAAGH;IAE5B,MAAMI,SAASF,KAAKG,MAAM,KAAK,YAAY,eAAe;IAE1D,qBAAO,KAACC;kBAAK,CAAC,OAAO,EAAEJ,KAAKK,KAAK,IAAIC,OAAOL,WAAWM,QAAQ,CAAC,GAAG,OAAOL,QAAQ;;AACpF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  export { ColumnLinkRowLabel } from '../components/ColumnLinkRowLabel.js';
2
- export { MegaColumnRowLabel } from '../components/MegaColumnRowLabel.js';
2
+ export { MegaEntryRowLabel } from '../components/MegaEntryRowLabel.js';
3
3
  export { MenuItemRowLabel } from '../components/MenuItemRowLabel.js';
4
4
  export { MenuPreview } from '../components/MenuPreview.js';
5
5
  export { SubMenuItemRowLabel } from '../components/SubMenuItemRowLabel.js';
@@ -1,5 +1,5 @@
1
1
  export { ColumnLinkRowLabel } from '../components/ColumnLinkRowLabel.js';
2
- export { MegaColumnRowLabel } from '../components/MegaColumnRowLabel.js';
2
+ export { MegaEntryRowLabel } from '../components/MegaEntryRowLabel.js';
3
3
  export { MenuItemRowLabel } from '../components/MenuItemRowLabel.js';
4
4
  export { MenuPreview } from '../components/MenuPreview.js';
5
5
  export { SubMenuItemRowLabel } from '../components/SubMenuItemRowLabel.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { ColumnLinkRowLabel } from '../components/ColumnLinkRowLabel.js'\nexport { MegaColumnRowLabel } from '../components/MegaColumnRowLabel.js'\nexport { MenuItemRowLabel } from '../components/MenuItemRowLabel.js'\nexport { MenuPreview } from '../components/MenuPreview.js'\nexport { SubMenuItemRowLabel } from '../components/SubMenuItemRowLabel.js'\nexport { fetchMenu } from '../fetchMenu.js'\nexport { UrlField } from '../components/UrlField/index.js'\nexport { useMenu } from '../hooks/useMenu.js'\n"],"names":["ColumnLinkRowLabel","MegaColumnRowLabel","MenuItemRowLabel","MenuPreview","SubMenuItemRowLabel","fetchMenu","UrlField","useMenu"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,gBAAgB,QAAQ,oCAAmC;AACpE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,SAASC,QAAQ,QAAQ,kCAAiC;AAC1D,SAASC,OAAO,QAAQ,sBAAqB"}
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { ColumnLinkRowLabel } from '../components/ColumnLinkRowLabel.js'\nexport { MegaEntryRowLabel } from '../components/MegaEntryRowLabel.js'\nexport { MenuItemRowLabel } from '../components/MenuItemRowLabel.js'\nexport { MenuPreview } from '../components/MenuPreview.js'\nexport { SubMenuItemRowLabel } from '../components/SubMenuItemRowLabel.js'\nexport { fetchMenu } from '../fetchMenu.js'\nexport { UrlField } from '../components/UrlField/index.js'\nexport { useMenu } from '../hooks/useMenu.js'\n"],"names":["ColumnLinkRowLabel","MegaEntryRowLabel","MenuItemRowLabel","MenuPreview","SubMenuItemRowLabel","fetchMenu","UrlField","useMenu"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,iBAAiB,QAAQ,qCAAoC;AACtE,SAASC,gBAAgB,QAAQ,oCAAmC;AACpE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,SAASC,QAAQ,QAAQ,kCAAiC;AAC1D,SAASC,OAAO,QAAQ,sBAAqB"}
@@ -1,7 +1,9 @@
1
1
  import type { CollectionSlug, Field } from 'payload';
2
+ import type { DynamicSource } from '../types.js';
2
3
  export type MenuItemFieldOptions = {
3
4
  baseUrl?: string;
4
5
  disabled?: boolean;
6
+ dynamicSources?: DynamicSource[];
5
7
  maxDepth?: number;
6
8
  mediaCollection?: CollectionSlug;
7
9
  relationTo?: CollectionSlug | CollectionSlug[];