@foundrykit/menu-plugin 0.4.2 → 0.5.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/dist/collections/Menus.d.ts +3 -2
- package/dist/collections/Menus.js +10 -1
- package/dist/collections/Menus.js.map +1 -1
- package/dist/components/MegaEntryRowLabel.d.ts +1 -0
- package/dist/components/MegaEntryRowLabel.js +12 -0
- package/dist/components/MegaEntryRowLabel.js.map +1 -0
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/fields/MenuItem.d.ts +2 -0
- package/dist/fields/MenuItem.js +309 -219
- package/dist/fields/MenuItem.js.map +1 -1
- package/dist/hooks/resolveDynamicMenu.d.ts +13 -0
- package/dist/hooks/resolveDynamicMenu.js +221 -0
- package/dist/hooks/resolveDynamicMenu.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/migrations/megaColumnsToEntries.d.ts +19 -0
- package/dist/migrations/megaColumnsToEntries.js +142 -0
- package/dist/migrations/megaColumnsToEntries.js.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -1
package/dist/fields/MenuItem.js
CHANGED
|
@@ -107,10 +107,14 @@ const buildFeaturedFields = (options)=>{
|
|
|
107
107
|
label: 'CTA Link Type',
|
|
108
108
|
options: LINK_TYPE_OPTIONS
|
|
109
109
|
},
|
|
110
|
+
{
|
|
111
|
+
name: 'ctaLabel',
|
|
112
|
+
type: 'text',
|
|
113
|
+
label: 'CTA Label'
|
|
114
|
+
},
|
|
110
115
|
{
|
|
111
116
|
name: 'ctaUrl',
|
|
112
117
|
type: 'text',
|
|
113
|
-
label: 'CTA URL',
|
|
114
118
|
admin: {
|
|
115
119
|
...options?.disabled ? {} : {
|
|
116
120
|
components: {
|
|
@@ -122,6 +126,7 @@ const buildFeaturedFields = (options)=>{
|
|
|
122
126
|
baseUrl
|
|
123
127
|
}
|
|
124
128
|
},
|
|
129
|
+
label: 'CTA URL',
|
|
125
130
|
validate: validateUrl
|
|
126
131
|
},
|
|
127
132
|
{
|
|
@@ -163,166 +168,14 @@ const buildFeaturedFields = (options)=>{
|
|
|
163
168
|
}
|
|
164
169
|
return fields;
|
|
165
170
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
dbName: 'mcols',
|
|
172
|
-
label: 'Mega Menu Columns',
|
|
173
|
-
admin: {
|
|
174
|
-
condition: (_data, siblingData)=>siblingData?.itemType === 'mega',
|
|
175
|
-
...options?.disabled ? {} : {
|
|
176
|
-
components: {
|
|
177
|
-
RowLabel: '@foundrykit/menu-plugin/client#MegaColumnRowLabel'
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
fields: [
|
|
182
|
-
{
|
|
183
|
-
name: 'columnTitle',
|
|
184
|
-
type: 'text',
|
|
185
|
-
label: 'Column Title',
|
|
186
|
-
admin: {
|
|
187
|
-
description: 'Optional heading displayed above this column.'
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: 'columnLinks',
|
|
192
|
-
type: 'array',
|
|
193
|
-
dbName: 'clinks',
|
|
194
|
-
label: 'Column Links',
|
|
195
|
-
admin: {
|
|
196
|
-
...options?.disabled ? {} : {
|
|
197
|
-
components: {
|
|
198
|
-
RowLabel: '@foundrykit/menu-plugin/client#ColumnLinkRowLabel'
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
fields: [
|
|
203
|
-
// leaf-level basicFields (canNest = false since currentDepth === maxDepth)
|
|
204
|
-
...createMenuItemFields(options, maxDepth),
|
|
205
|
-
{
|
|
206
|
-
name: 'subLinks',
|
|
207
|
-
type: 'array',
|
|
208
|
-
dbName: 'slinks',
|
|
209
|
-
label: 'Sub Links',
|
|
210
|
-
admin: {
|
|
211
|
-
description: 'Items revealed in the secondary panel when this link is hovered or selected.',
|
|
212
|
-
...options?.disabled ? {} : {
|
|
213
|
-
components: {
|
|
214
|
-
RowLabel: '@foundrykit/menu-plugin/client#SubMenuItemRowLabel'
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
fields: createMenuItemFields(options, maxDepth)
|
|
219
|
-
}
|
|
220
|
-
]
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
name: 'featured',
|
|
224
|
-
type: 'group',
|
|
225
|
-
label: 'Featured Panel',
|
|
226
|
-
admin: {
|
|
227
|
-
description: 'Optional right-hand panel with image, title, description, and CTA.'
|
|
228
|
-
},
|
|
229
|
-
fields: buildFeaturedFields(options)
|
|
230
|
-
}
|
|
231
|
-
]
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
export const createMenuItemFields = (options, currentDepth = 0)=>{
|
|
171
|
+
/**
|
|
172
|
+
* The simple-by-default link field set shared by every item that behaves like a
|
|
173
|
+
* link: `label`, `type`, `reference`/`url`, plus the "Options" and "Advanced"
|
|
174
|
+
* collapsible groups. No `itemType` and no nesting fields are included here.
|
|
175
|
+
*/ const buildLeafLinkFields = (options)=>{
|
|
235
176
|
const baseUrl = options?.baseUrl ?? '';
|
|
236
|
-
const maxDepth = options?.maxDepth ?? 1;
|
|
237
177
|
const relationTo = options?.relationTo ?? 'pages';
|
|
238
|
-
|
|
239
|
-
{
|
|
240
|
-
type: 'row',
|
|
241
|
-
fields: [
|
|
242
|
-
{
|
|
243
|
-
name: 'advancedOptions',
|
|
244
|
-
type: 'radio',
|
|
245
|
-
admin: {
|
|
246
|
-
width: '33%'
|
|
247
|
-
},
|
|
248
|
-
defaultValue: 'default',
|
|
249
|
-
options: [
|
|
250
|
-
{
|
|
251
|
-
label: 'Default',
|
|
252
|
-
value: 'default'
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
label: 'Advanced',
|
|
256
|
-
value: 'advanced'
|
|
257
|
-
}
|
|
258
|
-
],
|
|
259
|
-
required: true
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
name: 'target',
|
|
263
|
-
type: 'radio',
|
|
264
|
-
admin: {
|
|
265
|
-
width: '33%'
|
|
266
|
-
},
|
|
267
|
-
defaultValue: '_self',
|
|
268
|
-
label: 'Open in new tab',
|
|
269
|
-
options: [
|
|
270
|
-
{
|
|
271
|
-
label: 'Same Tab',
|
|
272
|
-
value: '_self'
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
label: 'New Tab',
|
|
276
|
-
value: '_blank'
|
|
277
|
-
}
|
|
278
|
-
]
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
name: 'visibility',
|
|
282
|
-
type: 'radio',
|
|
283
|
-
admin: {
|
|
284
|
-
condition: (_data, siblingData)=>{
|
|
285
|
-
return siblingData?.advancedOptions !== 'default';
|
|
286
|
-
},
|
|
287
|
-
width: '33%'
|
|
288
|
-
},
|
|
289
|
-
defaultValue: 'visible',
|
|
290
|
-
options: [
|
|
291
|
-
{
|
|
292
|
-
label: 'Visible',
|
|
293
|
-
value: 'visible'
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
label: 'Invisible',
|
|
297
|
-
value: 'invisible'
|
|
298
|
-
}
|
|
299
|
-
]
|
|
300
|
-
}
|
|
301
|
-
]
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
name: 'displaySurface',
|
|
305
|
-
type: 'select',
|
|
306
|
-
defaultValue: 'both',
|
|
307
|
-
label: 'Display Surface',
|
|
308
|
-
admin: {
|
|
309
|
-
description: 'Controls which navigation surfaces render this item.'
|
|
310
|
-
},
|
|
311
|
-
options: [
|
|
312
|
-
{
|
|
313
|
-
label: 'Navbar + Drawer (default)',
|
|
314
|
-
value: 'both'
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
label: 'Navbar Only',
|
|
318
|
-
value: 'navbar'
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
label: 'Drawer Only',
|
|
322
|
-
value: 'drawer'
|
|
323
|
-
}
|
|
324
|
-
]
|
|
325
|
-
},
|
|
178
|
+
return [
|
|
326
179
|
{
|
|
327
180
|
name: 'type',
|
|
328
181
|
type: 'select',
|
|
@@ -383,81 +236,319 @@ export const createMenuItemFields = (options, currentDepth = 0)=>{
|
|
|
383
236
|
]
|
|
384
237
|
},
|
|
385
238
|
{
|
|
386
|
-
|
|
387
|
-
type: 'text',
|
|
239
|
+
type: 'collapsible',
|
|
388
240
|
admin: {
|
|
389
|
-
|
|
390
|
-
|
|
241
|
+
initCollapsed: true
|
|
242
|
+
},
|
|
243
|
+
fields: [
|
|
244
|
+
{
|
|
245
|
+
name: 'target',
|
|
246
|
+
type: 'radio',
|
|
247
|
+
defaultValue: '_self',
|
|
248
|
+
label: 'Open in new tab',
|
|
249
|
+
options: [
|
|
250
|
+
{
|
|
251
|
+
label: 'Same Tab',
|
|
252
|
+
value: '_self'
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
label: 'New Tab',
|
|
256
|
+
value: '_blank'
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: 'displaySurface',
|
|
262
|
+
type: 'select',
|
|
263
|
+
admin: {
|
|
264
|
+
description: 'Controls which navigation surfaces render this item.'
|
|
265
|
+
},
|
|
266
|
+
defaultValue: 'both',
|
|
267
|
+
label: 'Display Surface',
|
|
268
|
+
options: [
|
|
269
|
+
{
|
|
270
|
+
label: 'Navbar + Drawer (default)',
|
|
271
|
+
value: 'both'
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
label: 'Navbar Only',
|
|
275
|
+
value: 'navbar'
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
label: 'Drawer Only',
|
|
279
|
+
value: 'drawer'
|
|
280
|
+
}
|
|
281
|
+
]
|
|
391
282
|
}
|
|
392
|
-
|
|
283
|
+
],
|
|
284
|
+
label: 'Options'
|
|
393
285
|
},
|
|
394
286
|
{
|
|
395
|
-
|
|
396
|
-
type: 'array',
|
|
287
|
+
type: 'collapsible',
|
|
397
288
|
admin: {
|
|
398
|
-
|
|
399
|
-
return siblingData?.advancedOptions !== 'default';
|
|
400
|
-
}
|
|
289
|
+
initCollapsed: true
|
|
401
290
|
},
|
|
402
291
|
fields: [
|
|
403
292
|
{
|
|
404
|
-
name: '
|
|
293
|
+
name: 'visibility',
|
|
294
|
+
type: 'radio',
|
|
295
|
+
defaultValue: 'visible',
|
|
296
|
+
options: [
|
|
297
|
+
{
|
|
298
|
+
label: 'Visible',
|
|
299
|
+
value: 'visible'
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
label: 'Invisible',
|
|
303
|
+
value: 'invisible'
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
name: 'rel',
|
|
405
309
|
type: 'text'
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: 'roles',
|
|
313
|
+
type: 'array',
|
|
314
|
+
fields: [
|
|
315
|
+
{
|
|
316
|
+
name: 'role',
|
|
317
|
+
type: 'text'
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: 'attrs',
|
|
323
|
+
type: 'textarea'
|
|
324
|
+
}
|
|
325
|
+
],
|
|
326
|
+
label: 'Advanced'
|
|
327
|
+
}
|
|
328
|
+
];
|
|
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
|
+
const buildMegaConfigFields = (options, currentDepth = 0)=>{
|
|
365
|
+
const dynamicSources = options?.dynamicSources ?? [];
|
|
366
|
+
const relationTo = options?.relationTo ?? 'pages';
|
|
367
|
+
const parentCollections = [
|
|
368
|
+
...new Set(dynamicSources.map((source)=>source.parentCollection))
|
|
369
|
+
];
|
|
370
|
+
const singleSource = dynamicSources.length === 1;
|
|
371
|
+
// Parent relationship: collapse to a single relationTo string when exactly one
|
|
372
|
+
// source is configured, union when many, fall back to the link relationTo when
|
|
373
|
+
// no dynamic sources are configured.
|
|
374
|
+
const parentRelationTo = parentCollections.length === 1 ? parentCollections[0] : parentCollections.length > 1 ? parentCollections : relationTo;
|
|
375
|
+
const dynamicSourceOptions = dynamicSources.map((source)=>({
|
|
376
|
+
label: source.label,
|
|
377
|
+
value: source.name
|
|
378
|
+
}));
|
|
379
|
+
const isMega = (_data, siblingData)=>siblingData?.itemType === 'mega';
|
|
380
|
+
return [
|
|
381
|
+
{
|
|
382
|
+
name: 'megaLayout',
|
|
383
|
+
type: 'select',
|
|
384
|
+
admin: {
|
|
385
|
+
condition: isMega,
|
|
386
|
+
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.'
|
|
387
|
+
},
|
|
388
|
+
defaultValue: 'reveal',
|
|
389
|
+
label: 'Mega Menu Layout',
|
|
390
|
+
options: [
|
|
391
|
+
{
|
|
392
|
+
label: 'Reveal (rows)',
|
|
393
|
+
value: 'reveal'
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
label: 'Columns',
|
|
397
|
+
value: 'columns'
|
|
406
398
|
}
|
|
407
399
|
]
|
|
408
400
|
},
|
|
409
401
|
{
|
|
410
|
-
name: '
|
|
411
|
-
type: '
|
|
402
|
+
name: 'defaultFeatured',
|
|
403
|
+
type: 'group',
|
|
412
404
|
admin: {
|
|
413
|
-
condition:
|
|
414
|
-
|
|
405
|
+
condition: isMega,
|
|
406
|
+
description: 'Fallback featured panel shown when an entry does not provide its own.'
|
|
407
|
+
},
|
|
408
|
+
fields: buildFeaturedFields(options),
|
|
409
|
+
label: 'Default Featured Panel'
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
name: 'megaEntries',
|
|
413
|
+
type: 'array',
|
|
414
|
+
admin: {
|
|
415
|
+
condition: isMega,
|
|
416
|
+
description: 'A flat list of entries. Each entry is itself a link and can reveal children in a secondary panel.',
|
|
417
|
+
...options?.disabled ? {} : {
|
|
418
|
+
components: {
|
|
419
|
+
RowLabel: '@foundrykit/menu-plugin/client#MegaEntryRowLabel'
|
|
420
|
+
}
|
|
415
421
|
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
422
|
+
},
|
|
423
|
+
// Depth-aware, short dbName so the generated Postgres table/relation names
|
|
424
|
+
// stay unique across nesting levels and well under the 63-char identifier
|
|
425
|
+
// limit even when consumers raise `maxDepth`.
|
|
426
|
+
dbName: `me${currentDepth}`,
|
|
427
|
+
fields: [
|
|
428
|
+
...buildLeafLinkFields(options).map(gateLinkField),
|
|
429
|
+
{
|
|
430
|
+
name: 'source',
|
|
431
|
+
type: 'select',
|
|
432
|
+
admin: {
|
|
433
|
+
description: 'Where this entry\'s children come from.'
|
|
434
|
+
},
|
|
435
|
+
defaultValue: 'manual',
|
|
436
|
+
options: [
|
|
437
|
+
{
|
|
438
|
+
label: 'Manual',
|
|
439
|
+
value: 'manual'
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
label: 'Dynamic (from a related collection)',
|
|
443
|
+
value: 'dynamic'
|
|
444
|
+
}
|
|
445
|
+
],
|
|
446
|
+
required: true
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
name: 'children',
|
|
450
|
+
type: 'array',
|
|
451
|
+
admin: {
|
|
452
|
+
condition: (_data, siblingData)=>siblingData?.source !== 'dynamic',
|
|
453
|
+
description: 'Items revealed in the secondary panel when this entry is hovered or selected.',
|
|
454
|
+
...options?.disabled ? {} : {
|
|
455
|
+
components: {
|
|
456
|
+
RowLabel: '@foundrykit/menu-plugin/client#SubMenuItemRowLabel'
|
|
435
457
|
}
|
|
436
458
|
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
459
|
+
},
|
|
460
|
+
dbName: `mc${currentDepth}`,
|
|
461
|
+
fields: buildLeafLinkFields(options).map(gateLinkField),
|
|
462
|
+
label: 'Children'
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
name: 'dynamicSource',
|
|
466
|
+
type: 'select',
|
|
467
|
+
admin: {
|
|
468
|
+
condition: (_data, siblingData)=>siblingData?.source === 'dynamic',
|
|
469
|
+
// Hidden and auto-set when exactly one source is configured.
|
|
470
|
+
hidden: singleSource
|
|
471
|
+
},
|
|
472
|
+
...singleSource ? {
|
|
473
|
+
defaultValue: dynamicSources[0]?.name
|
|
474
|
+
} : {},
|
|
475
|
+
label: 'Dynamic Source',
|
|
476
|
+
options: dynamicSourceOptions
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: 'parent',
|
|
480
|
+
type: 'relationship',
|
|
481
|
+
admin: {
|
|
482
|
+
condition: (_data, siblingData)=>siblingData?.source === 'dynamic',
|
|
483
|
+
description: 'The parent document whose related children populate this entry.'
|
|
484
|
+
},
|
|
485
|
+
...Array.isArray(parentRelationTo) ? {
|
|
486
|
+
hasMany: false,
|
|
487
|
+
relationTo: parentRelationTo
|
|
488
|
+
} : {
|
|
489
|
+
relationTo: parentRelationTo
|
|
453
490
|
}
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
name: 'featured',
|
|
494
|
+
type: 'group',
|
|
495
|
+
admin: {
|
|
496
|
+
description: 'The featured panel shown alongside this entry\'s children.'
|
|
497
|
+
},
|
|
498
|
+
fields: [
|
|
499
|
+
{
|
|
500
|
+
name: 'mode',
|
|
501
|
+
type: 'select',
|
|
502
|
+
defaultValue: 'inherit',
|
|
503
|
+
options: [
|
|
504
|
+
{
|
|
505
|
+
label: 'Inherit (use default featured)',
|
|
506
|
+
value: 'inherit'
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
label: 'Manual',
|
|
510
|
+
value: 'manual'
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
label: 'Dynamic (from the related source)',
|
|
514
|
+
value: 'dynamic'
|
|
515
|
+
}
|
|
516
|
+
]
|
|
517
|
+
},
|
|
518
|
+
...buildFeaturedFields(options).map((field)=>{
|
|
519
|
+
if (!('name' in field)) {
|
|
520
|
+
return field;
|
|
521
|
+
}
|
|
522
|
+
const existingCondition = field.admin?.condition;
|
|
523
|
+
return {
|
|
524
|
+
...field,
|
|
525
|
+
admin: {
|
|
526
|
+
...field.admin,
|
|
527
|
+
condition: (_data, siblingData, extra)=>{
|
|
528
|
+
if (siblingData?.mode !== 'manual') {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
return existingCondition ? existingCondition(_data, siblingData, extra) : true;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
})
|
|
536
|
+
],
|
|
537
|
+
label: 'Featured Panel'
|
|
454
538
|
}
|
|
455
|
-
|
|
539
|
+
],
|
|
540
|
+
label: 'Mega Menu Entries'
|
|
456
541
|
}
|
|
457
|
-
|
|
458
|
-
|
|
542
|
+
];
|
|
543
|
+
};
|
|
544
|
+
export const createMenuItemFields = (options, currentDepth = 0)=>{
|
|
545
|
+
const maxDepth = options?.maxDepth ?? 1;
|
|
546
|
+
const leafLinkFields = buildLeafLinkFields(options).map(gateLinkField);
|
|
459
547
|
const canNest = currentDepth < maxDepth;
|
|
460
|
-
|
|
548
|
+
if (!canNest) {
|
|
549
|
+
return leafLinkFields;
|
|
550
|
+
}
|
|
551
|
+
return [
|
|
461
552
|
{
|
|
462
553
|
name: 'itemType',
|
|
463
554
|
type: 'select',
|
|
@@ -478,11 +569,10 @@ export const createMenuItemFields = (options, currentDepth = 0)=>{
|
|
|
478
569
|
],
|
|
479
570
|
required: true
|
|
480
571
|
},
|
|
481
|
-
...
|
|
572
|
+
...leafLinkFields,
|
|
482
573
|
{
|
|
483
574
|
name: currentDepth === 0 ? 'children' : `children_${currentDepth + 1}`,
|
|
484
575
|
type: 'array',
|
|
485
|
-
label: 'Children',
|
|
486
576
|
admin: {
|
|
487
577
|
...options?.disabled ? {} : {
|
|
488
578
|
components: {
|
|
@@ -493,11 +583,11 @@ export const createMenuItemFields = (options, currentDepth = 0)=>{
|
|
|
493
583
|
return siblingData?.itemType === 'dropdown';
|
|
494
584
|
}
|
|
495
585
|
},
|
|
496
|
-
fields: createMenuItemFields(options, currentDepth + 1)
|
|
586
|
+
fields: createMenuItemFields(options, currentDepth + 1),
|
|
587
|
+
label: 'Children'
|
|
497
588
|
},
|
|
498
|
-
|
|
499
|
-
]
|
|
500
|
-
return fields;
|
|
589
|
+
...buildMegaConfigFields(options, currentDepth)
|
|
590
|
+
];
|
|
501
591
|
};
|
|
502
592
|
export const menuItemFields = createMenuItemFields();
|
|
503
593
|
export default menuItemFields;
|