@foundrykit/menu-plugin 0.5.0 → 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 +87 -2
- package/dist/fields/MenuItem.js +4 -38
- package/dist/fields/MenuItem.js.map +1 -1
- package/package.json +25 -32
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,
|
|
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` | `
|
|
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
|
package/dist/fields/MenuItem.js
CHANGED
|
@@ -180,7 +180,7 @@ const buildFeaturedFields = (options)=>{
|
|
|
180
180
|
name: 'type',
|
|
181
181
|
type: 'select',
|
|
182
182
|
admin: {
|
|
183
|
-
description: 'Select the type of link for this menu item.'
|
|
183
|
+
description: 'Select the type of link for this menu item. On a mega menu or dropdown this is where the top-level label links to, and is optional.'
|
|
184
184
|
},
|
|
185
185
|
defaultValue: 'reference',
|
|
186
186
|
options: LINK_TYPE_OPTIONS,
|
|
@@ -327,40 +327,6 @@ const buildFeaturedFields = (options)=>{
|
|
|
327
327
|
}
|
|
328
328
|
];
|
|
329
329
|
};
|
|
330
|
-
const isLink = (_data, siblingData)=>siblingData?.itemType !== 'dropdown' && siblingData?.itemType !== 'mega';
|
|
331
|
-
/**
|
|
332
|
-
* Recursively gate a leaf link field so it only renders when the item behaves
|
|
333
|
-
* like a link (i.e. `itemType` is not `dropdown`/`mega`). `label` always shows
|
|
334
|
-
* (a dropdown/mega still needs a label) and `displaySurface` is always visible
|
|
335
|
-
* regardless of `itemType`. Where there is no `itemType` sibling (e.g. mega
|
|
336
|
-
* entries / children) `isLink` resolves to `true`, so gating is a no-op.
|
|
337
|
-
*/ const gateLinkField = (field)=>{
|
|
338
|
-
if ('fields' in field && (field.type === 'row' || field.type === 'collapsible')) {
|
|
339
|
-
return {
|
|
340
|
-
...field,
|
|
341
|
-
fields: field.fields.map(gateLinkField)
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
if ('name' in field) {
|
|
345
|
-
if (field.name === 'label' || field.name === 'displaySurface') {
|
|
346
|
-
return field;
|
|
347
|
-
}
|
|
348
|
-
const existingCondition = field.admin?.condition;
|
|
349
|
-
return {
|
|
350
|
-
...field,
|
|
351
|
-
admin: {
|
|
352
|
-
...field.admin,
|
|
353
|
-
condition: (_data, siblingData, extra)=>{
|
|
354
|
-
if (!isLink(_data, siblingData)) {
|
|
355
|
-
return false;
|
|
356
|
-
}
|
|
357
|
-
return existingCondition ? existingCondition(_data, siblingData, extra) : true;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
return field;
|
|
363
|
-
};
|
|
364
330
|
const buildMegaConfigFields = (options, currentDepth = 0)=>{
|
|
365
331
|
const dynamicSources = options?.dynamicSources ?? [];
|
|
366
332
|
const relationTo = options?.relationTo ?? 'pages';
|
|
@@ -425,7 +391,7 @@ const buildMegaConfigFields = (options, currentDepth = 0)=>{
|
|
|
425
391
|
// limit even when consumers raise `maxDepth`.
|
|
426
392
|
dbName: `me${currentDepth}`,
|
|
427
393
|
fields: [
|
|
428
|
-
...buildLeafLinkFields(options)
|
|
394
|
+
...buildLeafLinkFields(options),
|
|
429
395
|
{
|
|
430
396
|
name: 'source',
|
|
431
397
|
type: 'select',
|
|
@@ -458,7 +424,7 @@ const buildMegaConfigFields = (options, currentDepth = 0)=>{
|
|
|
458
424
|
}
|
|
459
425
|
},
|
|
460
426
|
dbName: `mc${currentDepth}`,
|
|
461
|
-
fields: buildLeafLinkFields(options)
|
|
427
|
+
fields: buildLeafLinkFields(options),
|
|
462
428
|
label: 'Children'
|
|
463
429
|
},
|
|
464
430
|
{
|
|
@@ -543,7 +509,7 @@ const buildMegaConfigFields = (options, currentDepth = 0)=>{
|
|
|
543
509
|
};
|
|
544
510
|
export const createMenuItemFields = (options, currentDepth = 0)=>{
|
|
545
511
|
const maxDepth = options?.maxDepth ?? 1;
|
|
546
|
-
const leafLinkFields = buildLeafLinkFields(options)
|
|
512
|
+
const leafLinkFields = buildLeafLinkFields(options);
|
|
547
513
|
const canNest = currentDepth < maxDepth;
|
|
548
514
|
if (!canNest) {
|
|
549
515
|
return leafLinkFields;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fields/MenuItem.ts"],"sourcesContent":["import type { CollectionSlug, Field, Validate } from 'payload'\n\nimport type { DynamicSource } from '../types.js'\n\nexport type MenuItemFieldOptions = {\n baseUrl?: string\n disabled?: boolean\n dynamicSources?: DynamicSource[]\n maxDepth?: number\n mediaCollection?: CollectionSlug\n relationTo?: CollectionSlug | CollectionSlug[]\n}\n\nconst validateUrl: Validate = (value, { siblingData }) => {\n const type = (siblingData as any)?.type\n if (!value) {\n if (['anchor', 'custom', 'external', 'internal', 'mailto', 'tel'].includes(type)) {\n return 'URL is required for this link type'\n }\n return true\n }\n\n switch (type) {\n case 'anchor': {\n if (!/^#[\\w-]+$/.test(value as string)) {\n return 'Please enter a valid anchor (e.g. #section-name)'\n }\n break\n }\n case 'external': {\n try {\n new URL(value as string)\n } catch {\n return 'Please enter a valid URL (e.g. https://example.co.uk)'\n }\n break\n }\n case 'internal': {\n const path = (value as string).replace(/^https?:\\/\\/[^/]+/, '')\n if (!path.startsWith('/')) {\n return 'Internal paths must start with /'\n }\n break\n }\n case 'mailto': {\n const email = (value as string).replace(/^mailto:/, '')\n const [local, domain] = email.split('@')\n if (!local || !domain || domain.indexOf('.') < 1 || email.split('@').length !== 2) {\n return 'Please enter a valid email address'\n }\n break\n }\n case 'tel': {\n const raw = (value as string).replace(/^tel:/, '')\n if (!/^\\+?\\d[\\d\\s\\-()]{4,}$/.test(raw)) {\n return 'Please enter a valid phone number'\n }\n break\n }\n }\n\n return true\n}\n\nconst LINK_TYPE_OPTIONS = [\n { label: 'Internal', value: 'internal' },\n { label: 'External', value: 'external' },\n { label: 'Reference', value: 'reference' },\n { label: 'Anchor', value: 'anchor' },\n { label: 'Mail To', value: 'mailto' },\n { label: 'TEL', value: 'tel' },\n { label: 'Custom', value: 'custom' },\n]\n\nconst buildFeaturedFields = (options?: MenuItemFieldOptions): Field[] => {\n const baseUrl = options?.baseUrl ?? ''\n const relationTo = options?.relationTo ?? ('pages' as CollectionSlug)\n const fields: Field[] = [\n {\n name: 'heading',\n type: 'text',\n },\n {\n name: 'description',\n type: 'textarea',\n },\n {\n name: 'ctaType',\n type: 'select',\n defaultValue: 'reference',\n label: 'CTA Link Type',\n options: LINK_TYPE_OPTIONS,\n },\n {\n name: 'ctaLabel',\n type: 'text',\n label: 'CTA Label',\n },\n {\n name: 'ctaUrl',\n type: 'text',\n admin: {\n ...(options?.disabled\n ? {}\n : {\n components: {\n Field: '@foundrykit/menu-plugin/client#UrlField',\n },\n }),\n condition: (_data, siblingData) => siblingData?.ctaType !== 'reference',\n custom: { baseUrl },\n },\n label: 'CTA URL',\n validate: validateUrl,\n },\n {\n name: 'ctaReference',\n type: 'relationship',\n admin: {\n condition: (_data, siblingData) => siblingData?.ctaType === 'reference',\n },\n ...(Array.isArray(relationTo) ? { hasMany: false, relationTo } : { relationTo }),\n } as Field,\n {\n name: 'ctaTarget',\n type: 'radio',\n defaultValue: '_self',\n label: 'CTA Open in',\n options: [\n { label: 'Same Tab', value: '_self' },\n { label: 'New Tab', value: '_blank' },\n ],\n },\n ]\n if (options?.mediaCollection) {\n fields.unshift({\n name: 'image',\n type: 'upload',\n relationTo: options.mediaCollection,\n } as Field)\n }\n return fields\n}\n\n/**\n * The simple-by-default link field set shared by every item that behaves like a\n * link: `label`, `type`, `reference`/`url`, plus the \"Options\" and \"Advanced\"\n * collapsible groups. No `itemType` and no nesting fields are included here.\n */\nconst buildLeafLinkFields = (options?: MenuItemFieldOptions): Field[] => {\n const baseUrl = options?.baseUrl ?? ''\n const relationTo = options?.relationTo ?? ('pages' as CollectionSlug)\n\n return [\n {\n name: 'type',\n type: 'select',\n admin: {\n description: 'Select the type of link for this menu item.',\n },\n defaultValue: 'reference',\n options: LINK_TYPE_OPTIONS,\n required: true,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n required: true,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n ...(options?.disabled\n ? {}\n : {\n components: {\n Field: '@foundrykit/menu-plugin/client#UrlField',\n },\n }),\n condition: (_data, siblingData) => {\n return siblingData?.type !== 'reference'\n },\n custom: { baseUrl },\n width: '50%',\n },\n label: 'URL',\n validate: validateUrl,\n },\n {\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_data, siblingData) => {\n return siblingData?.type === 'reference'\n },\n width: '50%',\n },\n ...(Array.isArray(relationTo) ? { hasMany: false, relationTo } : { relationTo }),\n } as Field,\n ],\n },\n {\n type: 'collapsible',\n admin: {\n initCollapsed: true,\n },\n fields: [\n {\n name: 'target',\n type: 'radio',\n defaultValue: '_self',\n label: 'Open in new tab',\n options: [\n { label: 'Same Tab', value: '_self' },\n { label: 'New Tab', value: '_blank' },\n ],\n },\n {\n name: 'displaySurface',\n type: 'select',\n admin: {\n description: 'Controls which navigation surfaces render this item.',\n },\n defaultValue: 'both',\n label: 'Display Surface',\n options: [\n { label: 'Navbar + Drawer (default)', value: 'both' },\n { label: 'Navbar Only', value: 'navbar' },\n { label: 'Drawer Only', value: 'drawer' },\n ],\n },\n ],\n label: 'Options',\n },\n {\n type: 'collapsible',\n admin: {\n initCollapsed: true,\n },\n fields: [\n {\n name: 'visibility',\n type: 'radio',\n defaultValue: 'visible',\n options: [\n { label: 'Visible', value: 'visible' },\n { label: 'Invisible', value: 'invisible' },\n ],\n },\n {\n name: 'rel',\n type: 'text',\n },\n {\n name: 'roles',\n type: 'array',\n fields: [{ name: 'role', type: 'text' }],\n },\n {\n name: 'attrs',\n type: 'textarea',\n },\n ],\n label: 'Advanced',\n },\n ]\n}\n\nconst isLink = (_data: any, siblingData: any) =>\n siblingData?.itemType !== 'dropdown' && siblingData?.itemType !== 'mega'\n\n/**\n * Recursively gate a leaf link field so it only renders when the item behaves\n * like a link (i.e. `itemType` is not `dropdown`/`mega`). `label` always shows\n * (a dropdown/mega still needs a label) and `displaySurface` is always visible\n * regardless of `itemType`. Where there is no `itemType` sibling (e.g. mega\n * entries / children) `isLink` resolves to `true`, so gating is a no-op.\n */\nconst gateLinkField = (field: Field): Field => {\n if ('fields' in field && (field.type === 'row' || field.type === 'collapsible')) {\n return { ...field, fields: field.fields.map(gateLinkField) } as Field\n }\n\n if ('name' in field) {\n if (field.name === 'label' || field.name === 'displaySurface') {return field}\n const existingCondition = (field as any).admin?.condition\n return {\n ...field,\n admin: {\n ...(field as any).admin,\n condition: (_data: any, siblingData: any, extra: any) => {\n if (!isLink(_data, siblingData)) {return false}\n return existingCondition ? existingCondition(_data, siblingData, extra) : true\n },\n },\n } as Field\n }\n\n return field\n}\n\nconst buildMegaConfigFields = (options?: MenuItemFieldOptions, currentDepth = 0): Field[] => {\n const dynamicSources = options?.dynamicSources ?? []\n const relationTo = options?.relationTo ?? ('pages' as CollectionSlug)\n\n const parentCollections = [...new Set(dynamicSources.map((source) => source.parentCollection))]\n const singleSource = dynamicSources.length === 1\n\n // Parent relationship: collapse to a single relationTo string when exactly one\n // source is configured, union when many, fall back to the link relationTo when\n // no dynamic sources are configured.\n const parentRelationTo: CollectionSlug | CollectionSlug[] =\n parentCollections.length === 1\n ? parentCollections[0]\n : parentCollections.length > 1\n ? parentCollections\n : relationTo\n\n const dynamicSourceOptions = dynamicSources.map((source) => ({\n label: source.label,\n value: source.name,\n }))\n\n const isMega = (_data: any, siblingData: any) => siblingData?.itemType === 'mega'\n\n return [\n {\n name: 'megaLayout',\n type: 'select',\n admin: {\n condition: isMega,\n description: 'How the mega menu is laid out. \"Reveal\" shows a flat list of rows that reveal their children in a second panel; \"Columns\" renders classic multi-column layout.',\n },\n defaultValue: 'reveal',\n label: 'Mega Menu Layout',\n options: [\n { label: 'Reveal (rows)', value: 'reveal' },\n { label: 'Columns', value: 'columns' },\n ],\n },\n {\n name: 'defaultFeatured',\n type: 'group',\n admin: {\n condition: isMega,\n description: 'Fallback featured panel shown when an entry does not provide its own.',\n },\n fields: buildFeaturedFields(options),\n label: 'Default Featured Panel',\n },\n {\n name: 'megaEntries',\n type: 'array',\n admin: {\n condition: isMega,\n description: 'A flat list of entries. Each entry is itself a link and can reveal children in a secondary panel.',\n ...(options?.disabled\n ? {}\n : {\n components: {\n RowLabel: '@foundrykit/menu-plugin/client#MegaEntryRowLabel',\n },\n }),\n },\n // Depth-aware, short dbName so the generated Postgres table/relation names\n // stay unique across nesting levels and well under the 63-char identifier\n // limit even when consumers raise `maxDepth`.\n dbName: `me${currentDepth}`,\n fields: [\n ...buildLeafLinkFields(options).map(gateLinkField),\n {\n name: 'source',\n type: 'select',\n admin: {\n description: 'Where this entry\\'s children come from.',\n },\n defaultValue: 'manual',\n options: [\n { label: 'Manual', value: 'manual' },\n { label: 'Dynamic (from a related collection)', value: 'dynamic' },\n ],\n required: true,\n },\n {\n name: 'children',\n type: 'array',\n admin: {\n condition: (_data, siblingData) => siblingData?.source !== 'dynamic',\n description: 'Items revealed in the secondary panel when this entry is hovered or selected.',\n ...(options?.disabled\n ? {}\n : {\n components: {\n RowLabel: '@foundrykit/menu-plugin/client#SubMenuItemRowLabel',\n },\n }),\n },\n dbName: `mc${currentDepth}`,\n fields: buildLeafLinkFields(options).map(gateLinkField),\n label: 'Children',\n },\n {\n name: 'dynamicSource',\n type: 'select',\n admin: {\n condition: (_data, siblingData) => siblingData?.source === 'dynamic',\n // Hidden and auto-set when exactly one source is configured.\n hidden: singleSource,\n },\n ...(singleSource ? { defaultValue: dynamicSources[0]?.name } : {}),\n label: 'Dynamic Source',\n options: dynamicSourceOptions,\n },\n {\n name: 'parent',\n type: 'relationship',\n admin: {\n condition: (_data, siblingData) => siblingData?.source === 'dynamic',\n description: 'The parent document whose related children populate this entry.',\n },\n ...(Array.isArray(parentRelationTo)\n ? { hasMany: false, relationTo: parentRelationTo }\n : { relationTo: parentRelationTo }),\n } as Field,\n {\n name: 'featured',\n type: 'group',\n admin: {\n description: 'The featured panel shown alongside this entry\\'s children.',\n },\n fields: [\n {\n name: 'mode',\n type: 'select',\n defaultValue: 'inherit',\n options: [\n { label: 'Inherit (use default featured)', value: 'inherit' },\n { label: 'Manual', value: 'manual' },\n { label: 'Dynamic (from the related source)', value: 'dynamic' },\n ],\n },\n ...buildFeaturedFields(options).map((field) => {\n if (!('name' in field)) {return field}\n const existingCondition = (field as any).admin?.condition\n return {\n ...field,\n admin: {\n ...(field as any).admin,\n condition: (_data: any, siblingData: any, extra: any) => {\n if (siblingData?.mode !== 'manual') {return false}\n return existingCondition ? existingCondition(_data, siblingData, extra) : true\n },\n },\n } as Field\n }),\n ],\n label: 'Featured Panel',\n },\n ],\n label: 'Mega Menu Entries',\n },\n ]\n}\n\nexport const createMenuItemFields = (options?: MenuItemFieldOptions, currentDepth = 0): Field[] => {\n const maxDepth = options?.maxDepth ?? 1\n const leafLinkFields = buildLeafLinkFields(options).map(gateLinkField)\n\n const canNest = currentDepth < maxDepth\n\n if (!canNest) {\n return leafLinkFields\n }\n\n return [\n {\n name: 'itemType',\n type: 'select',\n defaultValue: 'link',\n options: [\n { label: 'Link', value: 'link' },\n { label: 'Dropdown', value: 'dropdown' },\n { label: 'Mega Menu', value: 'mega' },\n ],\n required: true,\n },\n ...leafLinkFields,\n {\n name: currentDepth === 0 ? 'children' : `children_${currentDepth + 1}`,\n type: 'array',\n admin: {\n ...(options?.disabled\n ? {}\n : {\n components: {\n RowLabel: '@foundrykit/menu-plugin/client#SubMenuItemRowLabel',\n },\n }),\n condition: (_data, siblingData) => {\n return siblingData?.itemType === 'dropdown'\n },\n },\n fields: createMenuItemFields(options, currentDepth + 1),\n label: 'Children',\n },\n ...buildMegaConfigFields(options, currentDepth),\n ]\n}\n\nexport const menuItemFields = createMenuItemFields()\n\nexport default menuItemFields\n"],"names":["validateUrl","value","siblingData","type","includes","test","URL","path","replace","startsWith","email","local","domain","split","indexOf","length","raw","LINK_TYPE_OPTIONS","label","buildFeaturedFields","options","baseUrl","relationTo","fields","name","defaultValue","admin","disabled","components","Field","condition","_data","ctaType","custom","validate","Array","isArray","hasMany","mediaCollection","unshift","buildLeafLinkFields","description","required","width","initCollapsed","isLink","itemType","gateLinkField","field","map","existingCondition","extra","buildMegaConfigFields","currentDepth","dynamicSources","parentCollections","Set","source","parentCollection","singleSource","parentRelationTo","dynamicSourceOptions","isMega","RowLabel","dbName","hidden","mode","createMenuItemFields","maxDepth","leafLinkFields","canNest","menuItemFields"],"mappings":"AAaA,MAAMA,cAAwB,CAACC,OAAO,EAAEC,WAAW,EAAE;IACnD,MAAMC,OAAQD,aAAqBC;IACnC,IAAI,CAACF,OAAO;QACV,IAAI;YAAC;YAAU;YAAU;YAAY;YAAY;YAAU;SAAM,CAACG,QAAQ,CAACD,OAAO;YAChF,OAAO;QACT;QACA,OAAO;IACT;IAEA,OAAQA;QACN,KAAK;YAAU;gBACb,IAAI,CAAC,YAAYE,IAAI,CAACJ,QAAkB;oBACtC,OAAO;gBACT;gBACA;YACF;QACA,KAAK;YAAY;gBACf,IAAI;oBACF,IAAIK,IAAIL;gBACV,EAAE,OAAM;oBACN,OAAO;gBACT;gBACA;YACF;QACA,KAAK;YAAY;gBACf,MAAMM,OAAO,AAACN,MAAiBO,OAAO,CAAC,qBAAqB;gBAC5D,IAAI,CAACD,KAAKE,UAAU,CAAC,MAAM;oBACzB,OAAO;gBACT;gBACA;YACF;QACA,KAAK;YAAU;gBACb,MAAMC,QAAQ,AAACT,MAAiBO,OAAO,CAAC,YAAY;gBACpD,MAAM,CAACG,OAAOC,OAAO,GAAGF,MAAMG,KAAK,CAAC;gBACpC,IAAI,CA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QACT;KACD;AACH;AAEA,OAAO,MAAMiD,uBAAuB,CAAC/C,SAAgCiC,eAAe,CAAC;IACnF,MAAMe,WAAWhD,SAASgD,YAAY;IACtC,MAAMC,iBAAiB7B,oBAAoBpB,SAAS6B,GAAG,CAACF;IAExD,MAAMuB,UAAUjB,eAAee;IAE/B,IAAI,CAACE,SAAS;QACZ,OAAOD;IACT;IAEA,OAAO;QACL;YACE7C,MAAM;YACNrB,MAAM;YACNsB,cAAc;YACdL,SAAS;gBACP;oBAAEF,OAAO;oBAAQjB,OAAO;gBAAO;gBAC/B;oBAAEiB,OAAO;oBAAYjB,OAAO;gBAAW;gBACvC;oBAAEiB,OAAO;oBAAajB,OAAO;gBAAO;aACrC;YACDyC,UAAU;QACZ;WACG2B;QACH;YACE7C,MAAM6B,iBAAiB,IAAI,aAAa,CAAC,SAAS,EAAEA,eAAe,GAAG;YACtElD,MAAM;YACNuB,OAAO;gBACL,GAAIN,SAASO,WACT,CAAC,IACD;oBACEC,YAAY;wBACVmC,UAAU;oBACZ;gBACF,CAAC;gBACLjC,WAAW,CAACC,OAAO7B;oBACjB,OAAOA,aAAa4C,aAAa;gBACnC;YACF;YACAvB,QAAQ4C,qBAAqB/C,SAASiC,eAAe;YACrDnC,OAAO;QACT;WACGkC,sBAAsBhC,SAASiC;KACnC;AACH,EAAC;AAED,OAAO,MAAMkB,iBAAiBJ,uBAAsB;AAEpD,eAAeI,eAAc"}
|
|
1
|
+
{"version":3,"sources":["../../src/fields/MenuItem.ts"],"sourcesContent":["import type { CollectionSlug, Field, Validate } from 'payload'\n\nimport type { DynamicSource } from '../types.js'\n\nexport type MenuItemFieldOptions = {\n baseUrl?: string\n disabled?: boolean\n dynamicSources?: DynamicSource[]\n maxDepth?: number\n mediaCollection?: CollectionSlug\n relationTo?: CollectionSlug | CollectionSlug[]\n}\n\nconst validateUrl: Validate = (value, { siblingData }) => {\n const type = (siblingData as any)?.type\n if (!value) {\n if (['anchor', 'custom', 'external', 'internal', 'mailto', 'tel'].includes(type)) {\n return 'URL is required for this link type'\n }\n return true\n }\n\n switch (type) {\n case 'anchor': {\n if (!/^#[\\w-]+$/.test(value as string)) {\n return 'Please enter a valid anchor (e.g. #section-name)'\n }\n break\n }\n case 'external': {\n try {\n new URL(value as string)\n } catch {\n return 'Please enter a valid URL (e.g. https://example.co.uk)'\n }\n break\n }\n case 'internal': {\n const path = (value as string).replace(/^https?:\\/\\/[^/]+/, '')\n if (!path.startsWith('/')) {\n return 'Internal paths must start with /'\n }\n break\n }\n case 'mailto': {\n const email = (value as string).replace(/^mailto:/, '')\n const [local, domain] = email.split('@')\n if (!local || !domain || domain.indexOf('.') < 1 || email.split('@').length !== 2) {\n return 'Please enter a valid email address'\n }\n break\n }\n case 'tel': {\n const raw = (value as string).replace(/^tel:/, '')\n if (!/^\\+?\\d[\\d\\s\\-()]{4,}$/.test(raw)) {\n return 'Please enter a valid phone number'\n }\n break\n }\n }\n\n return true\n}\n\nconst LINK_TYPE_OPTIONS = [\n { label: 'Internal', value: 'internal' },\n { label: 'External', value: 'external' },\n { label: 'Reference', value: 'reference' },\n { label: 'Anchor', value: 'anchor' },\n { label: 'Mail To', value: 'mailto' },\n { label: 'TEL', value: 'tel' },\n { label: 'Custom', value: 'custom' },\n]\n\nconst buildFeaturedFields = (options?: MenuItemFieldOptions): Field[] => {\n const baseUrl = options?.baseUrl ?? ''\n const relationTo = options?.relationTo ?? ('pages' as CollectionSlug)\n const fields: Field[] = [\n {\n name: 'heading',\n type: 'text',\n },\n {\n name: 'description',\n type: 'textarea',\n },\n {\n name: 'ctaType',\n type: 'select',\n defaultValue: 'reference',\n label: 'CTA Link Type',\n options: LINK_TYPE_OPTIONS,\n },\n {\n name: 'ctaLabel',\n type: 'text',\n label: 'CTA Label',\n },\n {\n name: 'ctaUrl',\n type: 'text',\n admin: {\n ...(options?.disabled\n ? {}\n : {\n components: {\n Field: '@foundrykit/menu-plugin/client#UrlField',\n },\n }),\n condition: (_data, siblingData) => siblingData?.ctaType !== 'reference',\n custom: { baseUrl },\n },\n label: 'CTA URL',\n validate: validateUrl,\n },\n {\n name: 'ctaReference',\n type: 'relationship',\n admin: {\n condition: (_data, siblingData) => siblingData?.ctaType === 'reference',\n },\n ...(Array.isArray(relationTo) ? { hasMany: false, relationTo } : { relationTo }),\n } as Field,\n {\n name: 'ctaTarget',\n type: 'radio',\n defaultValue: '_self',\n label: 'CTA Open in',\n options: [\n { label: 'Same Tab', value: '_self' },\n { label: 'New Tab', value: '_blank' },\n ],\n },\n ]\n if (options?.mediaCollection) {\n fields.unshift({\n name: 'image',\n type: 'upload',\n relationTo: options.mediaCollection,\n } as Field)\n }\n return fields\n}\n\n/**\n * The simple-by-default link field set shared by every item that behaves like a\n * link: `label`, `type`, `reference`/`url`, plus the \"Options\" and \"Advanced\"\n * collapsible groups. No `itemType` and no nesting fields are included here.\n */\nconst buildLeafLinkFields = (options?: MenuItemFieldOptions): Field[] => {\n const baseUrl = options?.baseUrl ?? ''\n const relationTo = options?.relationTo ?? ('pages' as CollectionSlug)\n\n return [\n {\n name: 'type',\n type: 'select',\n admin: {\n description:\n 'Select the type of link for this menu item. On a mega menu or dropdown this is where the top-level label links to, and is optional.',\n },\n defaultValue: 'reference',\n options: LINK_TYPE_OPTIONS,\n required: true,\n },\n {\n type: 'row',\n fields: [\n {\n name: 'label',\n type: 'text',\n admin: {\n width: '50%',\n },\n required: true,\n },\n {\n name: 'url',\n type: 'text',\n admin: {\n ...(options?.disabled\n ? {}\n : {\n components: {\n Field: '@foundrykit/menu-plugin/client#UrlField',\n },\n }),\n condition: (_data, siblingData) => {\n return siblingData?.type !== 'reference'\n },\n custom: { baseUrl },\n width: '50%',\n },\n label: 'URL',\n validate: validateUrl,\n },\n {\n name: 'reference',\n type: 'relationship',\n admin: {\n condition: (_data, siblingData) => {\n return siblingData?.type === 'reference'\n },\n width: '50%',\n },\n ...(Array.isArray(relationTo) ? { hasMany: false, relationTo } : { relationTo }),\n } as Field,\n ],\n },\n {\n type: 'collapsible',\n admin: {\n initCollapsed: true,\n },\n fields: [\n {\n name: 'target',\n type: 'radio',\n defaultValue: '_self',\n label: 'Open in new tab',\n options: [\n { label: 'Same Tab', value: '_self' },\n { label: 'New Tab', value: '_blank' },\n ],\n },\n {\n name: 'displaySurface',\n type: 'select',\n admin: {\n description: 'Controls which navigation surfaces render this item.',\n },\n defaultValue: 'both',\n label: 'Display Surface',\n options: [\n { label: 'Navbar + Drawer (default)', value: 'both' },\n { label: 'Navbar Only', value: 'navbar' },\n { label: 'Drawer Only', value: 'drawer' },\n ],\n },\n ],\n label: 'Options',\n },\n {\n type: 'collapsible',\n admin: {\n initCollapsed: true,\n },\n fields: [\n {\n name: 'visibility',\n type: 'radio',\n defaultValue: 'visible',\n options: [\n { label: 'Visible', value: 'visible' },\n { label: 'Invisible', value: 'invisible' },\n ],\n },\n {\n name: 'rel',\n type: 'text',\n },\n {\n name: 'roles',\n type: 'array',\n fields: [{ name: 'role', type: 'text' }],\n },\n {\n name: 'attrs',\n type: 'textarea',\n },\n ],\n label: 'Advanced',\n },\n ]\n}\n\nconst buildMegaConfigFields = (options?: MenuItemFieldOptions, currentDepth = 0): Field[] => {\n const dynamicSources = options?.dynamicSources ?? []\n const relationTo = options?.relationTo ?? ('pages' as CollectionSlug)\n\n const parentCollections = [...new Set(dynamicSources.map((source) => source.parentCollection))]\n const singleSource = dynamicSources.length === 1\n\n // Parent relationship: collapse to a single relationTo string when exactly one\n // source is configured, union when many, fall back to the link relationTo when\n // no dynamic sources are configured.\n const parentRelationTo: CollectionSlug | CollectionSlug[] =\n parentCollections.length === 1\n ? parentCollections[0]\n : parentCollections.length > 1\n ? parentCollections\n : relationTo\n\n const dynamicSourceOptions = dynamicSources.map((source) => ({\n label: source.label,\n value: source.name,\n }))\n\n const isMega = (_data: any, siblingData: any) => siblingData?.itemType === 'mega'\n\n return [\n {\n name: 'megaLayout',\n type: 'select',\n admin: {\n condition: isMega,\n description: 'How the mega menu is laid out. \"Reveal\" shows a flat list of rows that reveal their children in a second panel; \"Columns\" renders classic multi-column layout.',\n },\n defaultValue: 'reveal',\n label: 'Mega Menu Layout',\n options: [\n { label: 'Reveal (rows)', value: 'reveal' },\n { label: 'Columns', value: 'columns' },\n ],\n },\n {\n name: 'defaultFeatured',\n type: 'group',\n admin: {\n condition: isMega,\n description: 'Fallback featured panel shown when an entry does not provide its own.',\n },\n fields: buildFeaturedFields(options),\n label: 'Default Featured Panel',\n },\n {\n name: 'megaEntries',\n type: 'array',\n admin: {\n condition: isMega,\n description: 'A flat list of entries. Each entry is itself a link and can reveal children in a secondary panel.',\n ...(options?.disabled\n ? {}\n : {\n components: {\n RowLabel: '@foundrykit/menu-plugin/client#MegaEntryRowLabel',\n },\n }),\n },\n // Depth-aware, short dbName so the generated Postgres table/relation names\n // stay unique across nesting levels and well under the 63-char identifier\n // limit even when consumers raise `maxDepth`.\n dbName: `me${currentDepth}`,\n fields: [\n ...buildLeafLinkFields(options),\n {\n name: 'source',\n type: 'select',\n admin: {\n description: 'Where this entry\\'s children come from.',\n },\n defaultValue: 'manual',\n options: [\n { label: 'Manual', value: 'manual' },\n { label: 'Dynamic (from a related collection)', value: 'dynamic' },\n ],\n required: true,\n },\n {\n name: 'children',\n type: 'array',\n admin: {\n condition: (_data, siblingData) => siblingData?.source !== 'dynamic',\n description: 'Items revealed in the secondary panel when this entry is hovered or selected.',\n ...(options?.disabled\n ? {}\n : {\n components: {\n RowLabel: '@foundrykit/menu-plugin/client#SubMenuItemRowLabel',\n },\n }),\n },\n dbName: `mc${currentDepth}`,\n fields: buildLeafLinkFields(options),\n label: 'Children',\n },\n {\n name: 'dynamicSource',\n type: 'select',\n admin: {\n condition: (_data, siblingData) => siblingData?.source === 'dynamic',\n // Hidden and auto-set when exactly one source is configured.\n hidden: singleSource,\n },\n ...(singleSource ? { defaultValue: dynamicSources[0]?.name } : {}),\n label: 'Dynamic Source',\n options: dynamicSourceOptions,\n },\n {\n name: 'parent',\n type: 'relationship',\n admin: {\n condition: (_data, siblingData) => siblingData?.source === 'dynamic',\n description: 'The parent document whose related children populate this entry.',\n },\n ...(Array.isArray(parentRelationTo)\n ? { hasMany: false, relationTo: parentRelationTo }\n : { relationTo: parentRelationTo }),\n } as Field,\n {\n name: 'featured',\n type: 'group',\n admin: {\n description: 'The featured panel shown alongside this entry\\'s children.',\n },\n fields: [\n {\n name: 'mode',\n type: 'select',\n defaultValue: 'inherit',\n options: [\n { label: 'Inherit (use default featured)', value: 'inherit' },\n { label: 'Manual', value: 'manual' },\n { label: 'Dynamic (from the related source)', value: 'dynamic' },\n ],\n },\n ...buildFeaturedFields(options).map((field) => {\n if (!('name' in field)) {return field}\n const existingCondition = (field as any).admin?.condition\n return {\n ...field,\n admin: {\n ...(field as any).admin,\n condition: (_data: any, siblingData: any, extra: any) => {\n if (siblingData?.mode !== 'manual') {return false}\n return existingCondition ? existingCondition(_data, siblingData, extra) : true\n },\n },\n } as Field\n }),\n ],\n label: 'Featured Panel',\n },\n ],\n label: 'Mega Menu Entries',\n },\n ]\n}\n\nexport const createMenuItemFields = (options?: MenuItemFieldOptions, currentDepth = 0): Field[] => {\n const maxDepth = options?.maxDepth ?? 1\n const leafLinkFields = buildLeafLinkFields(options)\n\n const canNest = currentDepth < maxDepth\n\n if (!canNest) {\n return leafLinkFields\n }\n\n return [\n {\n name: 'itemType',\n type: 'select',\n defaultValue: 'link',\n options: [\n { label: 'Link', value: 'link' },\n { label: 'Dropdown', value: 'dropdown' },\n { label: 'Mega Menu', value: 'mega' },\n ],\n required: true,\n },\n ...leafLinkFields,\n {\n name: currentDepth === 0 ? 'children' : `children_${currentDepth + 1}`,\n type: 'array',\n admin: {\n ...(options?.disabled\n ? {}\n : {\n components: {\n RowLabel: '@foundrykit/menu-plugin/client#SubMenuItemRowLabel',\n },\n }),\n condition: (_data, siblingData) => {\n return siblingData?.itemType === 'dropdown'\n },\n },\n fields: createMenuItemFields(options, currentDepth + 1),\n label: 'Children',\n },\n ...buildMegaConfigFields(options, currentDepth),\n ]\n}\n\nexport const menuItemFields = createMenuItemFields()\n\nexport default menuItemFields\n"],"names":["validateUrl","value","siblingData","type","includes","test","URL","path","replace","startsWith","email","local","domain","split","indexOf","length","raw","LINK_TYPE_OPTIONS","label","buildFeaturedFields","options","baseUrl","relationTo","fields","name","defaultValue","admin","disabled","components","Field","condition","_data","ctaType","custom","validate","Array","isArray","hasMany","mediaCollection","unshift","buildLeafLinkFields","description","required","width","initCollapsed","buildMegaConfigFields","currentDepth","dynamicSources","parentCollections","Set","map","source","parentCollection","singleSource","parentRelationTo","dynamicSourceOptions","isMega","itemType","RowLabel","dbName","hidden","field","existingCondition","extra","mode","createMenuItemFields","maxDepth","leafLinkFields","canNest","menuItemFields"],"mappings":"AAaA,MAAMA,cAAwB,CAACC,OAAO,EAAEC,WAAW,EAAE;IACnD,MAAMC,OAAQD,aAAqBC;IACnC,IAAI,CAACF,OAAO;QACV,IAAI;YAAC;YAAU;YAAU;YAAY;YAAY;YAAU;SAAM,CAACG,QAAQ,CAACD,OAAO;YAChF,OAAO;QACT;QACA,OAAO;IACT;IAEA,OAAQA;QACN,KAAK;YAAU;gBACb,IAAI,CAAC,YAAYE,IAAI,CAACJ,QAAkB;oBACtC,OAAO;gBACT;gBACA;YACF;QACA,KAAK;YAAY;gBACf,IAAI;oBACF,IAAIK,IAAIL;gBACV,EAAE,OAAM;oBACN,OAAO;gBACT;gBACA;YACF;QACA,KAAK;YAAY;gBACf,MAAMM,OAAO,AAACN,MAAiBO,OAAO,CAAC,qBAAqB;gBAC5D,IAAI,CAACD,KAAKE,UAAU,CAAC,MAAM;oBACzB,OAAO;gBACT;gBACA;YACF;QACA,KAAK;YAAU;gBACb,MAAMC,QAAQ,AAACT,MAAiBO,OAAO,CAAC,YAAY;gBACpD,MAAM,CAACG,OAAOC,OAAO,GAAGF,MAAMG,KAAK,CAAC;gBACpC,IAAI,CAACF,SAAS,CAACC,UAAUA,OAAOE,OAAO,CAAC,OAAO,KAAKJ,MAAMG,KAAK,CAAC,KAA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.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foundrykit/menu-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A plugin for Payload CMS that provides a flexible and customisable menu system.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -37,28 +37,6 @@
|
|
|
37
37
|
"files": [
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
|
-
"scripts": {
|
|
41
|
-
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
42
|
-
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
43
|
-
"build:types": "tsc --outDir dist --rootDir ./src",
|
|
44
|
-
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
45
|
-
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
46
|
-
"dev": "next dev dev --turbo",
|
|
47
|
-
"dev:db:up": "docker-compose -f dev/docker-compose.yml up -d",
|
|
48
|
-
"dev:db:down": "docker-compose -f dev/docker-compose.yml down",
|
|
49
|
-
"dev:with-db": "docker-compose -f dev/docker-compose.yml up -d && pnpm dev && docker-compose -f dev/docker-compose.yml down",
|
|
50
|
-
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
|
|
51
|
-
"dev:generate-types": "pnpm dev:payload generate:types",
|
|
52
|
-
"dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
|
|
53
|
-
"generate:importmap": "pnpm dev:generate-importmap",
|
|
54
|
-
"generate:types": "pnpm dev:generate-types",
|
|
55
|
-
"lint": "eslint",
|
|
56
|
-
"lint:fix": "eslint ./src --fix",
|
|
57
|
-
"test": "pnpm test:int && pnpm test:e2e",
|
|
58
|
-
"test:e2e": "playwright test",
|
|
59
|
-
"test:int": "vitest",
|
|
60
|
-
"release": "release-it"
|
|
61
|
-
},
|
|
62
40
|
"devDependencies": {
|
|
63
41
|
"@eslint/eslintrc": "^3.2.0",
|
|
64
42
|
"@payloadcms/db-mongodb": "3.37.0",
|
|
@@ -106,13 +84,6 @@
|
|
|
106
84
|
"publishConfig": {
|
|
107
85
|
"access": "public"
|
|
108
86
|
},
|
|
109
|
-
"pnpm": {
|
|
110
|
-
"onlyBuiltDependencies": [
|
|
111
|
-
"sharp",
|
|
112
|
-
"esbuild",
|
|
113
|
-
"unrs-resolver"
|
|
114
|
-
]
|
|
115
|
-
},
|
|
116
87
|
"repository": {
|
|
117
88
|
"type": "git",
|
|
118
89
|
"url": "https://github.com/umi-labs/menu-plugin"
|
|
@@ -120,5 +91,27 @@
|
|
|
120
91
|
"bugs": {
|
|
121
92
|
"url": "https://github.com/umi-labs/menu-plugin/issues"
|
|
122
93
|
},
|
|
123
|
-
"homepage": "https://github.com/umi-labs/menu-plugin#readme"
|
|
124
|
-
|
|
94
|
+
"homepage": "https://github.com/umi-labs/menu-plugin#readme",
|
|
95
|
+
"scripts": {
|
|
96
|
+
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
97
|
+
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
98
|
+
"build:types": "tsc --outDir dist --rootDir ./src",
|
|
99
|
+
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
100
|
+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
101
|
+
"dev": "next dev dev --turbo",
|
|
102
|
+
"dev:db:up": "docker-compose -f dev/docker-compose.yml up -d",
|
|
103
|
+
"dev:db:down": "docker-compose -f dev/docker-compose.yml down",
|
|
104
|
+
"dev:with-db": "docker-compose -f dev/docker-compose.yml up -d && pnpm dev && docker-compose -f dev/docker-compose.yml down",
|
|
105
|
+
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
|
|
106
|
+
"dev:generate-types": "pnpm dev:payload generate:types",
|
|
107
|
+
"dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
|
|
108
|
+
"generate:importmap": "pnpm dev:generate-importmap",
|
|
109
|
+
"generate:types": "pnpm dev:generate-types",
|
|
110
|
+
"lint": "eslint",
|
|
111
|
+
"lint:fix": "eslint ./src --fix",
|
|
112
|
+
"test": "pnpm test:int && pnpm test:e2e",
|
|
113
|
+
"test:e2e": "playwright test",
|
|
114
|
+
"test:int": "vitest",
|
|
115
|
+
"release": "release-it"
|
|
116
|
+
}
|
|
117
|
+
}
|