@woodylab/payload 0.0.9 → 0.0.11

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.
@@ -0,0 +1,1115 @@
1
+ 'use strict';
2
+
3
+ var fieldRoles = require('./fieldRoles-CVvtwYrZ.js');
4
+
5
+ const fieldTextArea = (override) => ({
6
+ name: 'textarea',
7
+ label: 'Textarea',
8
+ type: 'textarea',
9
+ required: false,
10
+ ...override,
11
+ });
12
+
13
+ const fieldBlocks = (override) => ({
14
+ name: 'blocks',
15
+ label: 'Blocks',
16
+ type: 'blocks',
17
+ blocks: [],
18
+ required: false,
19
+ ...override,
20
+ });
21
+
22
+ const fieldCheckbox = (override) => ({
23
+ name: 'checkbox',
24
+ label: 'Checkbox',
25
+ type: 'checkbox',
26
+ required: false,
27
+ admin: {
28
+ description: 'Enable or disable the checkbox',
29
+ },
30
+ ...override,
31
+ });
32
+
33
+ const fieldCode = (override) => ({
34
+ name: 'code',
35
+ label: 'Code',
36
+ type: 'code',
37
+ required: false,
38
+ ...override,
39
+ });
40
+
41
+ const fieldDate = (override) => ({
42
+ name: 'date',
43
+ label: 'Date',
44
+ type: 'date',
45
+ required: false,
46
+ admin: {
47
+ description: 'Select a date',
48
+ date: {
49
+ pickerAppearance: 'dayOnly',
50
+ displayFormat: 'yyyy-MM-dd',
51
+ },
52
+ },
53
+ ...override,
54
+ });
55
+
56
+ const fieldEmail = (override) => ({
57
+ name: 'email',
58
+ label: 'Email',
59
+ type: 'email',
60
+ required: false,
61
+ ...override,
62
+ });
63
+
64
+ const fieldJoin = (collection, on, override) => ({
65
+ name: 'join',
66
+ label: 'join',
67
+ type: 'join',
68
+ collection,
69
+ on,
70
+ ...override,
71
+ });
72
+
73
+ const fieldNumber = (override) => ({
74
+ name: 'number',
75
+ label: 'Number',
76
+ type: 'number',
77
+ required: false,
78
+ ...override,
79
+ });
80
+
81
+ const fieldPoint = (override) => ({
82
+ name: 'point',
83
+ label: 'Point',
84
+ type: 'point',
85
+ required: false,
86
+ ...override,
87
+ });
88
+
89
+ const fieldRadioGroup = (override) => ({
90
+ name: 'radio',
91
+ label: 'Radio',
92
+ type: 'boolean',
93
+ required: false,
94
+ options: [
95
+ {
96
+ label: 'true',
97
+ value: true
98
+ },
99
+ {
100
+ label: 'true',
101
+ value: false
102
+ }
103
+ ],
104
+ ...override,
105
+ });
106
+
107
+ const fieldRelationship = (relationTo, override) => ({
108
+ name: 'relationship',
109
+ label: 'Relationship',
110
+ type: 'relationship',
111
+ relationTo,
112
+ required: false,
113
+ ...override,
114
+ });
115
+
116
+ const fieldRichText = (override) => ({
117
+ name: 'richText',
118
+ label: 'Rich Text',
119
+ type: 'richText',
120
+ required: false,
121
+ admin: {
122
+ placeholder: 'Insert text here',
123
+ rows: 5,
124
+ },
125
+ ...override,
126
+ });
127
+
128
+ const fieldContainerProps = (customFields = []) => {
129
+ return {
130
+ name: 'ctrP',
131
+ label: 'Proprietà container',
132
+ type: 'group',
133
+ fields: [
134
+ ...customFields,
135
+ fieldRichText({ name: 'body', label: 'Contenuto', required: false }),
136
+ fieldContainerWidths(),
137
+ {
138
+ type: 'tabs',
139
+ tabs: [
140
+ {
141
+ label: 'Stile',
142
+ fields: [
143
+ fieldRoles.fieldUpload('media', { name: 'bgi', label: 'Immagine di sfondo' }),
144
+ //WFieldColor({name:'bgc', label:'Colore di sfondo', required:false}),
145
+ {
146
+ name: 'borderRadius',
147
+ type: 'select',
148
+ label: 'Angoli arrotondati',
149
+ defaultValue: 'rounded-none',
150
+ options: [
151
+ { label: 'Nessuno', value: 'rounded-none' },
152
+ { label: 'Piccolo', value: 'rounded-sm' },
153
+ { label: 'Medio', value: 'rounded-md' },
154
+ { label: 'Grande', value: 'rounded-lg' },
155
+ { label: 'Extra Grande', value: 'rounded-xl' },
156
+ { label: 'Massimo', value: 'rounded-full' },
157
+ ],
158
+ admin: {
159
+ width: '50%',
160
+ description: 'Imposta lo stile degli angoli arrotondati del contenitore.',
161
+ },
162
+ },
163
+ {
164
+ name: 'boxShadow',
165
+ type: 'select',
166
+ label: 'Ombra contenitore',
167
+ defaultValue: 'shadow-none', // Default: nessuna ombra
168
+ options: [
169
+ { label: 'Nessuna', value: 'shadow-none' },
170
+ { label: 'Piccola', value: 'shadow-sm' },
171
+ { label: 'Normale', value: 'shadow' },
172
+ { label: 'Media', value: 'shadow-md' },
173
+ { label: 'Grande', value: 'shadow-lg' },
174
+ { label: 'Extra Grande', value: 'shadow-xl' },
175
+ { label: 'Massima', value: 'shadow-2xl' },
176
+ ],
177
+ admin: {
178
+ width: '50%',
179
+ description: 'Imposta lo stile dell\'ombra per il contenitore.',
180
+ },
181
+ }
182
+ ]
183
+ },
184
+ {
185
+ label: 'Dimensioni',
186
+ fields: [
187
+ fieldHeights(),
188
+ {
189
+ type: 'tabs',
190
+ tabs: [
191
+ {
192
+ label: 'Margini',
193
+ fields: [
194
+ fieldMargins()
195
+ ]
196
+ },
197
+ {
198
+ label: 'Paddings',
199
+ fields: [
200
+ fieldPaddings()
201
+ ]
202
+ }
203
+ ]
204
+ }
205
+ ]
206
+ }
207
+ ]
208
+ },
209
+ ]
210
+ };
211
+ };
212
+
213
+ const fieldThemeColor = (override) => ({
214
+ name: override?.name || 'color',
215
+ label: override?.label || 'Colore',
216
+ type: 'select',
217
+ required: override?.required ?? false,
218
+ options: [
219
+ { label: 'Default', value: '' },
220
+ { label: 'Foreground', value: 'foreground' },
221
+ { label: 'Primary', value: 'primary' },
222
+ { label: 'Secondary', value: 'secondary' },
223
+ { label: 'Accent', value: 'accent' },
224
+ { label: 'Dark', value: 'dark' },
225
+ { label: 'Light', value: 'light' },
226
+ { label: 'White', value: 'white' },
227
+ { label: 'Black', value: 'black' },
228
+ ],
229
+ admin: {
230
+ ...override?.admin,
231
+ },
232
+ });
233
+
234
+ const iconsList = [
235
+ { label: 'Academic Cap', value: 'AcademicCapIcon' },
236
+ { label: 'Adjustments Horizontal', value: 'AdjustmentsHorizontalIcon' },
237
+ { label: 'Adjustments Vertical', value: 'AdjustmentsVerticalIcon' },
238
+ { label: 'Archive Box Arrow Down', value: 'ArchiveBoxArrowDownIcon' },
239
+ { label: 'Archive Box X Mark', value: 'ArchiveBoxXMarkIcon' },
240
+ { label: 'Archive Box', value: 'ArchiveBoxIcon' },
241
+ { label: 'Arrow Down Circle', value: 'ArrowDownCircleIcon' },
242
+ { label: 'Arrow Down', value: 'ArrowDownIcon' },
243
+ { label: 'Arrow Left Circle', value: 'ArrowLeftCircleIcon' },
244
+ { label: 'Arrow Left', value: 'ArrowLeftIcon' },
245
+ { label: 'Arrow Right Circle', value: 'ArrowRightCircleIcon' },
246
+ { label: 'Arrow Right', value: 'ArrowRightIcon' },
247
+ { label: 'Arrow Up Circle', value: 'ArrowUpCircleIcon' },
248
+ { label: 'Arrow Up', value: 'ArrowUpIcon' },
249
+ { label: 'Bell Alert', value: 'BellAlertIcon' },
250
+ { label: 'Bell', value: 'BellIcon' },
251
+ { label: 'Bookmark Square', value: 'BookmarkSquareIcon' },
252
+ { label: 'Bookmark', value: 'BookmarkIcon' },
253
+ { label: 'Building Office', value: 'BuildingOfficeIcon' },
254
+ { label: 'Calendar', value: 'CalendarIcon' },
255
+ { label: 'Camera', value: 'CameraIcon' },
256
+ { label: 'Chart Bar', value: 'ChartBarIcon' },
257
+ { label: 'Chat Bubble Left Right', value: 'ChatBubbleLeftRightIcon' },
258
+ { label: 'Chat Bubble Left', value: 'ChatBubbleLeftIcon' },
259
+ { label: 'Check Circle', value: 'CheckCircleIcon' },
260
+ { label: 'Check', value: 'CheckIcon' },
261
+ { label: 'Chevron Down', value: 'ChevronDownIcon' },
262
+ { label: 'Chevron Left', value: 'ChevronLeftIcon' },
263
+ { label: 'Chevron Right', value: 'ChevronRightIcon' },
264
+ { label: 'Chevron Up', value: 'ChevronUpIcon' },
265
+ { label: 'Clock', value: 'ClockIcon' },
266
+ { label: 'Cloud Arrow Up', value: 'CloudArrowUpIcon' },
267
+ { label: 'Cloud', value: 'CloudIcon' },
268
+ { label: 'Code Bracket', value: 'CodeBracketIcon' },
269
+ { label: 'Cog', value: 'CogIcon' },
270
+ { label: 'Command Line', value: 'CommandLineIcon' },
271
+ { label: 'Computer Desktop', value: 'ComputerDesktopIcon' },
272
+ { label: 'Credit Card', value: 'CreditCardIcon' },
273
+ { label: 'Document', value: 'DocumentIcon' },
274
+ { label: 'Envelope', value: 'EnvelopeIcon' },
275
+ { label: 'Exclamation Circle', value: 'ExclamationCircleIcon' },
276
+ { label: 'Exclamation Triangle', value: 'ExclamationTriangleIcon' },
277
+ { label: 'Eye', value: 'EyeIcon' },
278
+ { label: 'Face Smile', value: 'FaceSmileIcon' },
279
+ { label: 'Film', value: 'FilmIcon' },
280
+ { label: 'Finger Print', value: 'FingerPrintIcon' },
281
+ { label: 'Fire', value: 'FireIcon' },
282
+ { label: 'Flag', value: 'FlagIcon' },
283
+ { label: 'Folder Open', value: 'FolderOpenIcon' },
284
+ { label: 'Folder', value: 'FolderIcon' },
285
+ { label: 'Gift', value: 'GiftIcon' },
286
+ { label: 'Globe Alt', value: 'GlobeAltIcon' },
287
+ { label: 'Globe Europe Africa', value: 'GlobeEuropeAfricaIcon' },
288
+ { label: 'Hand Raised', value: 'HandRaisedIcon' },
289
+ { label: 'Heart', value: 'HeartIcon' },
290
+ { label: 'Home', value: 'HomeIcon' },
291
+ { label: 'Identification', value: 'IdentificationIcon' },
292
+ { label: 'Information Circle', value: 'InformationCircleIcon' },
293
+ { label: 'Key', value: 'KeyIcon' },
294
+ { label: 'Link', value: 'LinkIcon' },
295
+ { label: 'List Bullet', value: 'ListBulletIcon' },
296
+ { label: 'Lock Closed', value: 'LockClosedIcon' },
297
+ { label: 'Lock Open', value: 'LockOpenIcon' },
298
+ { label: 'Magnifying Glass Circle', value: 'MagnifyingGlassCircleIcon' },
299
+ { label: 'Magnifying Glass', value: 'MagnifyingGlassIcon' },
300
+ { label: 'Map Pin', value: 'MapPinIcon' },
301
+ { label: 'Map', value: 'MapIcon' },
302
+ { label: 'Moon', value: 'MoonIcon' },
303
+ { label: 'Paper Airplane', value: 'PaperAirplaneIcon' },
304
+ { label: 'Paper Clip', value: 'PaperClipIcon' },
305
+ { label: 'Pause Circle', value: 'PauseCircleIcon' },
306
+ { label: 'Pencil Square', value: 'PencilSquareIcon' },
307
+ { label: 'Pencil', value: 'PencilIcon' },
308
+ { label: 'Phone Arrow Up Right', value: 'PhoneArrowUpRightIcon' },
309
+ { label: 'Phone X Mark', value: 'PhoneXMarkIcon' },
310
+ { label: 'Phone', value: 'PhoneIcon' },
311
+ { label: 'Photo', value: 'PhotoIcon' },
312
+ { label: 'Play Circle', value: 'PlayCircleIcon' },
313
+ { label: 'Play', value: 'PlayIcon' },
314
+ { label: 'Plus Circle', value: 'PlusCircleIcon' },
315
+ { label: 'Plus', value: 'PlusIcon' },
316
+ { label: 'Power', value: 'PowerIcon' },
317
+ { label: 'Question Mark Circle', value: 'QuestionMarkCircleIcon' },
318
+ { label: 'Rocket Launch', value: 'RocketLaunchIcon' },
319
+ { label: 'Rss', value: 'RssIcon' },
320
+ { label: 'Scale', value: 'ScaleIcon' },
321
+ { label: 'Server', value: 'ServerIcon' },
322
+ { label: 'Share', value: 'ShareIcon' },
323
+ { label: 'Shield Check', value: 'ShieldCheckIcon' },
324
+ { label: 'Shield Exclamation', value: 'ShieldExclamationIcon' },
325
+ { label: 'Shopping Bag', value: 'ShoppingBagIcon' },
326
+ { label: 'Shopping Cart', value: 'ShoppingCartIcon' },
327
+ { label: 'Star', value: 'StarIcon' },
328
+ { label: 'Stop Circle', value: 'StopCircleIcon' },
329
+ { label: 'Sun', value: 'SunIcon' },
330
+ { label: 'Tag', value: 'TagIcon' },
331
+ { label: 'Trash', value: 'TrashIcon' },
332
+ { label: 'Trophy', value: 'TrophyIcon' },
333
+ { label: 'User Circle', value: 'UserCircleIcon' },
334
+ { label: 'User Group', value: 'UserGroupIcon' },
335
+ { label: 'User', value: 'UserIcon' },
336
+ { label: 'Users', value: 'UsersIcon' },
337
+ { label: 'Video Camera', value: 'VideoCameraIcon' },
338
+ { label: 'Wifi', value: 'WifiIcon' },
339
+ { label: 'Window', value: 'WindowIcon' },
340
+ { label: 'Wrench Screwdriver', value: 'WrenchScrewdriverIcon' },
341
+ { label: 'Wrench', value: 'WrenchIcon' },
342
+ { label: 'X Circle', value: 'XCircleIcon' },
343
+ { label: 'X Mark', value: 'XMarkIcon' },
344
+ ];
345
+
346
+ const fieldAction = () => ({
347
+ type: 'group',
348
+ label: 'Azione',
349
+ name: 'action',
350
+ fields: [
351
+ fieldCheckbox({ name: 'show', label: 'Mostra azione', defaultValue: false, admin: {
352
+ width: '50%', // TODO CAMBIARE LAYOUT ADMIN
353
+ } }),
354
+ fieldRoles.fieldText({
355
+ name: 'label',
356
+ type: 'text',
357
+ label: 'Testo da visualizzare',
358
+ defaultValue: 'Action',
359
+ admin: {
360
+ width: '50%',
361
+ }
362
+ }),
363
+ fieldRoles.fieldSelect({
364
+ name: 'actionType',
365
+ label: 'Tipo di azione',
366
+ defaultValue: 'internalLink',
367
+ admin: {
368
+ width: '33%',
369
+ },
370
+ options: [
371
+ {
372
+ label: 'Interno',
373
+ value: 'internalLink',
374
+ },
375
+ {
376
+ label: 'Esterno',
377
+ value: 'externalLink',
378
+ },
379
+ /*
380
+ {
381
+ label: 'Azione',
382
+ value: 'customAction',
383
+ },
384
+ */
385
+ ],
386
+ }),
387
+ {
388
+ name: 'internalLink',
389
+ type: 'relationship',
390
+ label: 'Seleziona una pagina interna',
391
+ admin: {
392
+ condition: (data, siblingData) => {
393
+ return siblingData?.actionType === 'internalLink';
394
+ },
395
+ },
396
+ relationTo: ['pages', 'posts', 'destinations'],
397
+ },
398
+ {
399
+ name: 'externalLink',
400
+ type: 'text',
401
+ label: 'URL esterno',
402
+ admin: {
403
+ condition: (data, siblingData) => {
404
+ return siblingData?.actionType === 'externalLink';
405
+ },
406
+ },
407
+ },
408
+ {
409
+ type: 'collapsible',
410
+ label: 'Stile',
411
+ fields: [
412
+ {
413
+ type: 'row',
414
+ fields: [
415
+ {
416
+ name: 'buttonStyle',
417
+ type: 'select',
418
+ label: 'Stile bottone',
419
+ defaultValue: 'solid',
420
+ admin: {
421
+ width: '33%',
422
+ },
423
+ options: [
424
+ { label: 'Solido', value: 'solid' },
425
+ { label: 'Outline', value: 'outline' },
426
+ { label: 'Ghost', value: 'ghost' },
427
+ { label: 'Link', value: 'link' },
428
+ ],
429
+ },
430
+ {
431
+ name: 'buttonColor',
432
+ type: 'select',
433
+ label: 'Colore bottone',
434
+ defaultValue: 'primary',
435
+ admin: {
436
+ width: '33%',
437
+ },
438
+ options: [
439
+ { label: 'Primary', value: 'primary' },
440
+ { label: 'Secondary', value: 'secondary' },
441
+ { label: 'Accent', value: 'accent' },
442
+ { label: 'Dark', value: 'dark' },
443
+ { label: 'Light', value: 'light' },
444
+ ],
445
+ },
446
+ {
447
+ name: 'buttonSize',
448
+ type: 'select',
449
+ label: 'Dimensione bottone',
450
+ defaultValue: 'default',
451
+ admin: {
452
+ width: '33%',
453
+ },
454
+ options: [
455
+ { label: 'Small', value: 'small' },
456
+ { label: 'Default', value: 'default' },
457
+ { label: 'Medium', value: 'medium' },
458
+ { label: 'Large', value: 'large' },
459
+ { label: 'Extra Large', value: 'xl' },
460
+ ],
461
+ },
462
+ {
463
+ name: 'buttonRounded',
464
+ type: 'select',
465
+ label: 'Arrotondamento',
466
+ defaultValue: 'default',
467
+ admin: {
468
+ width: '33%',
469
+ },
470
+ options: [
471
+ { label: 'Nessuno', value: 'none' },
472
+ { label: 'Piccolo', value: 'sm' },
473
+ { label: 'Standard', value: 'default' },
474
+ { label: 'Grande', value: 'lg' },
475
+ { label: 'Completo', value: 'full' },
476
+ ],
477
+ },
478
+ {
479
+ name: 'alignment',
480
+ type: 'select',
481
+ label: 'Allineamento del Bottone',
482
+ defaultValue: 'left',
483
+ options: [
484
+ {
485
+ label: 'Sinistra',
486
+ value: 'left',
487
+ },
488
+ {
489
+ label: 'Centro',
490
+ value: 'center',
491
+ },
492
+ {
493
+ label: 'Destra',
494
+ value: 'right',
495
+ }
496
+ ],
497
+ admin: {
498
+ width: '33%',
499
+ condition: (data) => true, // Puoi modificare questa condizione se il campo deve essere mostrato solo in determinate circostanze
500
+ }
501
+ },
502
+ fieldThemeColor({
503
+ name: 'textColor',
504
+ label: 'Colore del testo',
505
+ admin: {
506
+ width: '33%',
507
+ }
508
+ }),
509
+ {
510
+ name: 'additionalEffects',
511
+ type: 'select',
512
+ label: 'Effetti aggiuntivi',
513
+ hasMany: true,
514
+ admin: {
515
+ width: '33%',
516
+ },
517
+ options: [
518
+ { label: 'Ombra', value: 'shadow' },
519
+ { label: 'Transizione', value: 'transition' },
520
+ { label: 'Animazione scala', value: 'scale' },
521
+ ],
522
+ }
523
+ ],
524
+ },
525
+ {
526
+ type: 'row',
527
+ fields: [
528
+ {
529
+ name: 'useIcon',
530
+ type: 'checkbox',
531
+ label: 'Usa icona',
532
+ defaultValue: false,
533
+ admin: {
534
+ width: '33%',
535
+ },
536
+ },
537
+ {
538
+ name: 'iconPosition',
539
+ type: 'select',
540
+ label: 'Posizione icona',
541
+ defaultValue: 'left',
542
+ admin: {
543
+ width: '33%',
544
+ condition: (_, siblingData) => siblingData?.useIcon === true,
545
+ },
546
+ options: [
547
+ { label: 'Sinistra', value: 'left' },
548
+ { label: 'Destra', value: 'right' },
549
+ { label: 'Solo icona', value: 'only' },
550
+ ],
551
+ },
552
+ {
553
+ name: 'iconName',
554
+ type: 'select',
555
+ label: 'Icona',
556
+ options: [
557
+ ...iconsList
558
+ ],
559
+ admin: {
560
+ width: '33%',
561
+ condition: (_, siblingData) => siblingData?.useIcon === true,
562
+ },
563
+ // Qui potresti usare un select con le icone disponibili se hai una libreria predefinita
564
+ },
565
+ ]
566
+ }
567
+ ]
568
+ }
569
+ ]
570
+ });
571
+
572
+ const fieldConfigProps = (customFields = []) => {
573
+ return {
574
+ name: 'config',
575
+ label: 'Configurazione',
576
+ type: 'group',
577
+ fields: [
578
+ ...customFields,
579
+ ],
580
+ };
581
+ };
582
+
583
+ const fieldContentProps = (customFields = []) => {
584
+ return {
585
+ name: 'cntP',
586
+ label: 'Contenuto',
587
+ type: 'group',
588
+ fields: [
589
+ ...customFields,
590
+ ],
591
+ };
592
+ };
593
+
594
+ /**
595
+ * Genera un campo per la selezione delle altezze
596
+ * @returns Field - Campo di tipo `select` per PayloadCMS
597
+ */
598
+ const fieldViewportHeights = () => {
599
+ return fieldRoles.fieldSelect({
600
+ name: 'h',
601
+ label: 'Altezza',
602
+ type: 'select',
603
+ options: [{ value: '', label: '(Nessuno)' }, ...fieldRoles.TailwindViewportHeights.map(h => ({ value: `h-${h}`, label: h }))],
604
+ admin: {
605
+ description: 'Definisce l’altezza dell’elemento.',
606
+ width: '50%'
607
+ },
608
+ });
609
+ };
610
+
611
+ const fieldSectionProps = (customFields = []) => {
612
+ return {
613
+ name: 'sctP',
614
+ label: 'Proprietà sezione',
615
+ type: 'group',
616
+ fields: [
617
+ ...customFields,
618
+ fieldRichText({ name: 'body', label: 'Contenuto', required: false }),
619
+ {
620
+ type: 'tabs',
621
+ tabs: [
622
+ {
623
+ label: 'Stile',
624
+ fields: [
625
+ fieldRoles.fieldUpload('media', { name: 'bgi', label: 'Immagine di sfondo' }),
626
+ fieldThemeColor({ name: 'bgc', label: 'Colore di sfondo', required: false }),
627
+ ]
628
+ }
629
+ ]
630
+ },
631
+ {
632
+ type: 'tabs',
633
+ tabs: [
634
+ {
635
+ label: 'Dimensioni',
636
+ fields: [
637
+ fieldViewportHeights(),
638
+ {
639
+ type: 'tabs',
640
+ tabs: [{
641
+ label: 'Margini',
642
+ fields: [
643
+ fieldMargins()
644
+ ]
645
+ },
646
+ {
647
+ label: 'Paddings',
648
+ fields: [
649
+ fieldPaddings()
650
+ ]
651
+ }
652
+ ]
653
+ }
654
+ ]
655
+ }
656
+ ]
657
+ },
658
+ ],
659
+ };
660
+ };
661
+
662
+ const fieldSectionTabs = (options = {}) => {
663
+ const { config = true, section = true, container = true, content = true, configFields = [], sectionFields = [], containerFields = [], contentFields = [] } = options;
664
+ const tabs = [];
665
+ if (config) {
666
+ tabs.push({
667
+ label: 'Configurazione',
668
+ fields: [
669
+ fieldConfigProps(configFields)
670
+ ],
671
+ });
672
+ }
673
+ // Tab per la sezione
674
+ if (section) {
675
+ tabs.push({
676
+ label: 'Sezione',
677
+ fields: [
678
+ fieldSectionProps(sectionFields)
679
+ ],
680
+ });
681
+ }
682
+ // Tab per il container
683
+ if (container) {
684
+ tabs.push({
685
+ label: 'Container',
686
+ fields: [
687
+ fieldContainerProps(containerFields)
688
+ ],
689
+ });
690
+ }
691
+ // Tab per il contenuto
692
+ if (content) {
693
+ tabs.push({
694
+ label: 'Contenuto',
695
+ fields: [
696
+ fieldContentProps(contentFields)
697
+ ],
698
+ });
699
+ }
700
+ return {
701
+ type: 'tabs',
702
+ tabs: tabs,
703
+ };
704
+ };
705
+
706
+ /**
707
+ * Genera un campo per la selezione delle larghezze del container
708
+ * @returns Field - Campo di tipo `select` per PayloadCMS
709
+ */
710
+ const fieldContainerWidths = () => {
711
+ return fieldRoles.fieldSelect({
712
+ name: 'container',
713
+ label: 'Larghezza del container',
714
+ options: [{ value: '', label: '(Nessuno)' }, ...fieldRoles.TailwindContainerWidths],
715
+ admin: {
716
+ description: 'Seleziona una larghezza massima per il container. Usa "None" per una larghezza a schermo intero.',
717
+ },
718
+ });
719
+ };
720
+
721
+ const fieldFontSizes = () => {
722
+ return fieldRoles.fieldSelect({
723
+ name: 'fs',
724
+ label: 'Dimensione del testo',
725
+ options: fieldRoles.TailwindTextSizes,
726
+ defaultValue: 'text-base',
727
+ admin: {
728
+ description: 'Seleziona una dimensione per il testo (es. Small, Base, Large, ecc.).',
729
+ },
730
+ });
731
+ };
732
+
733
+ /**
734
+ * Genera un campo per la selezione delle altezze
735
+ * @returns Field - Campo di tipo `select` per PayloadCMS
736
+ */
737
+ const fieldHeights = () => {
738
+ return fieldRoles.fieldSelect({
739
+ name: 'h',
740
+ label: 'Altezza',
741
+ type: 'select',
742
+ defaultValue: 'h-full',
743
+ options: [{ value: '', label: '(Nessuno)' }, ...fieldRoles.TailwindHeights.map(h => ({ value: `h-${h}`, label: h }))],
744
+ admin: {
745
+ description: 'Definisce l’altezza dell’elemento.',
746
+ },
747
+ });
748
+ };
749
+
750
+ const concatMarginFields = (args) => {
751
+ const { value, siblingData, operation, } = args;
752
+ if (operation === 'create' || operation === 'update') {
753
+ const margins = siblingData || {};
754
+ const { all, x, y, t, r, b, l } = margins;
755
+ const classes = [];
756
+ if (all)
757
+ classes.push(`m-${all}`);
758
+ if (x)
759
+ classes.push(`mx-${x}`);
760
+ if (y)
761
+ classes.push(`my-${y}`);
762
+ if (t)
763
+ classes.push(`mt-${t}`);
764
+ if (r)
765
+ classes.push(`mr-${r}`);
766
+ if (b)
767
+ classes.push(`mb-${b}`);
768
+ if (l)
769
+ classes.push(`ml-${l}`);
770
+ return classes.join(' ');
771
+ }
772
+ return value;
773
+ };
774
+ /**
775
+ * Genera un campo per la selezione dinamica dei margini
776
+ * @returns Field - Campo di tipo `group` per PayloadCMS
777
+ */
778
+ const fieldMargins = () => {
779
+ return {
780
+ name: 'm',
781
+ label: 'Margini',
782
+ type: 'group',
783
+ fields: [
784
+ {
785
+ name: 'className',
786
+ label: 'Classi CSS Margini',
787
+ type: 'text',
788
+ hooks: {
789
+ beforeChange: [concatMarginFields],
790
+ },
791
+ admin: {
792
+ readOnly: true,
793
+ description: 'Questa stringa verrà generata automaticamente in base ai campi sottostanti.',
794
+ },
795
+ },
796
+ {
797
+ type: 'row',
798
+ fields: [
799
+ fieldNumber({
800
+ name: 'all',
801
+ label: 'Tutti i lati',
802
+ type: 'number',
803
+ min: 0,
804
+ max: 96,
805
+ admin: {
806
+ width: '33%'
807
+ }
808
+ }),
809
+ fieldNumber({
810
+ name: 'x',
811
+ label: 'Orizzontale',
812
+ type: 'number',
813
+ min: 0,
814
+ max: 96,
815
+ admin: {
816
+ width: '33%'
817
+ }
818
+ }),
819
+ fieldNumber({
820
+ name: 'y',
821
+ label: 'Verticale',
822
+ type: 'number',
823
+ min: 0,
824
+ max: 96,
825
+ admin: {
826
+ width: '33%'
827
+ }
828
+ }),
829
+ fieldNumber({
830
+ name: 't',
831
+ label: 'Top',
832
+ type: 'number',
833
+ min: 0,
834
+ max: 96,
835
+ admin: {
836
+ width: '25%'
837
+ }
838
+ }),
839
+ fieldNumber({
840
+ name: 'r',
841
+ label: 'Right',
842
+ type: 'number',
843
+ min: 0,
844
+ max: 96,
845
+ admin: {
846
+ width: '25%'
847
+ }
848
+ }),
849
+ fieldNumber({
850
+ name: 'b',
851
+ label: 'Bottom',
852
+ type: 'number',
853
+ min: 0,
854
+ max: 96,
855
+ admin: {
856
+ width: '25%'
857
+ }
858
+ }),
859
+ fieldNumber({
860
+ name: 'l',
861
+ label: 'Left',
862
+ type: 'number',
863
+ min: 0,
864
+ max: 96,
865
+ admin: {
866
+ width: '25%'
867
+ }
868
+ }),
869
+ ]
870
+ }
871
+ ],
872
+ admin: {
873
+ description: 'Definisce lo spazio esterno generale, orizzontale, verticale o per ciascun lato.',
874
+ },
875
+ };
876
+ };
877
+
878
+ /**
879
+ * Hook per concatenare le classi CSS di padding
880
+ */
881
+ const concatPaddingFields = (args) => {
882
+ const { value, siblingData, operation, } = args;
883
+ if (operation === 'create' || operation === 'update') {
884
+ const paddings = siblingData || {};
885
+ const { all, x, y, t, r, b, l } = paddings;
886
+ const classes = [];
887
+ if (all)
888
+ classes.push(`p-${all}`);
889
+ if (x)
890
+ classes.push(`px-${x}`);
891
+ if (y)
892
+ classes.push(`py-${y}`);
893
+ if (t)
894
+ classes.push(`pt-${t}`);
895
+ if (r)
896
+ classes.push(`pr-${r}`);
897
+ if (b)
898
+ classes.push(`pb-${b}`);
899
+ if (l)
900
+ classes.push(`pl-${l}`);
901
+ return classes.join(' ');
902
+ }
903
+ return value;
904
+ };
905
+ /**
906
+ * Genera un campo per la selezione dinamica dei padding
907
+ * @returns Field - Campo di tipo `group` per PayloadCMS
908
+ */
909
+ const fieldPaddings = () => {
910
+ return {
911
+ name: 'p',
912
+ label: 'Padding',
913
+ type: 'group',
914
+ fields: [
915
+ {
916
+ name: 'className',
917
+ label: 'Classi CSS Padding',
918
+ type: 'text',
919
+ hooks: {
920
+ beforeChange: [concatPaddingFields],
921
+ },
922
+ admin: {
923
+ readOnly: true,
924
+ description: 'Questa stringa verrà generata automaticamente in base ai campi sottostanti.',
925
+ },
926
+ },
927
+ {
928
+ type: 'row',
929
+ fields: [
930
+ fieldNumber({
931
+ name: 'all',
932
+ label: 'Tutti i lati',
933
+ type: 'number',
934
+ min: 0,
935
+ max: 96,
936
+ admin: {
937
+ width: '33%'
938
+ }
939
+ }),
940
+ fieldNumber({
941
+ name: 'x',
942
+ label: 'Orizzontale',
943
+ type: 'number',
944
+ min: 0,
945
+ max: 96,
946
+ admin: {
947
+ width: '33%'
948
+ }
949
+ }),
950
+ fieldNumber({
951
+ name: 'y',
952
+ label: 'Verticale',
953
+ type: 'number',
954
+ min: 0,
955
+ max: 96,
956
+ admin: {
957
+ width: '33%'
958
+ }
959
+ }),
960
+ fieldNumber({
961
+ name: 't',
962
+ label: 'Top',
963
+ type: 'number',
964
+ min: 0,
965
+ max: 96,
966
+ admin: {
967
+ width: '25%'
968
+ }
969
+ }),
970
+ fieldNumber({
971
+ name: 'r',
972
+ label: 'Right',
973
+ type: 'number',
974
+ min: 0,
975
+ max: 96,
976
+ admin: {
977
+ width: '25%'
978
+ }
979
+ }),
980
+ fieldNumber({
981
+ name: 'b',
982
+ label: 'Bottom',
983
+ type: 'number',
984
+ min: 0,
985
+ max: 96,
986
+ admin: {
987
+ width: '25%'
988
+ }
989
+ }),
990
+ fieldNumber({
991
+ name: 'l',
992
+ label: 'Left',
993
+ type: 'number',
994
+ min: 0,
995
+ max: 96,
996
+ admin: {
997
+ width: '25%'
998
+ }
999
+ }),
1000
+ ]
1001
+ }
1002
+ ],
1003
+ admin: {
1004
+ description: 'Definisce lo spazio interno generale, orizzontale, verticale o per ciascun lato.',
1005
+ },
1006
+ };
1007
+ };
1008
+
1009
+ const fieldMenuItems = (override) => ({
1010
+ name: 'menuItems',
1011
+ label: 'Menu items',
1012
+ type: 'array',
1013
+ fields: [
1014
+ {
1015
+ name: 'test',
1016
+ type: 'text'
1017
+ },
1018
+ fieldCheckbox({
1019
+ name: 'is-external',
1020
+ label: 'open in new tab',
1021
+ }),
1022
+ fieldRoles.fieldText({ name: 'label', label: 'label' }),
1023
+ {
1024
+ name: 'relationship',
1025
+ type: 'relationship',
1026
+ relationTo: ['destinations'],
1027
+ },
1028
+ //WFieldRelationship(['pages', 'destinations']),
1029
+ fieldRoles.fieldArray({
1030
+ name: 'sub-menu',
1031
+ label: 'Sub menu',
1032
+ admin: {
1033
+ description: 'Aggiungere voci figlio a una voce di menù ne disabilita il click di navigazione per permettere l\'apertura del dropdown'
1034
+ },
1035
+ fields: [
1036
+ fieldCheckbox({
1037
+ name: 'is-external',
1038
+ label: 'open in new tab',
1039
+ }),
1040
+ fieldRoles.fieldText({ name: 'label', label: 'label' }),
1041
+ {
1042
+ name: 'relationship',
1043
+ type: 'relationship',
1044
+ relationTo: ['pages', 'posts', 'destinations'],
1045
+ },
1046
+ ]
1047
+ })
1048
+ ],
1049
+ });
1050
+
1051
+ // Esportazioni dalle cartelle principali
1052
+
1053
+ var index = /*#__PURE__*/Object.freeze({
1054
+ __proto__: null,
1055
+ fieldAction: fieldAction,
1056
+ fieldArray: fieldRoles.fieldArray,
1057
+ fieldBlocks: fieldBlocks,
1058
+ fieldCheckbox: fieldCheckbox,
1059
+ fieldCode: fieldCode,
1060
+ fieldColor: fieldThemeColor,
1061
+ fieldConfigProps: fieldConfigProps,
1062
+ fieldContainerProps: fieldContainerProps,
1063
+ fieldContainerWidths: fieldContainerWidths,
1064
+ fieldContentProps: fieldContentProps,
1065
+ fieldDate: fieldDate,
1066
+ fieldEmail: fieldEmail,
1067
+ fieldFontSizes: fieldFontSizes,
1068
+ fieldHeights: fieldHeights,
1069
+ fieldJoin: fieldJoin,
1070
+ fieldMargins: fieldMargins,
1071
+ fieldMenuItems: fieldMenuItems,
1072
+ fieldNumber: fieldNumber,
1073
+ fieldPaddings: fieldPaddings,
1074
+ fieldPoint: fieldPoint,
1075
+ fieldRadioGroup: fieldRadioGroup,
1076
+ fieldRelationship: fieldRelationship,
1077
+ fieldRichText: fieldRichText,
1078
+ fieldRoles: fieldRoles.fieldRoles,
1079
+ fieldSectionProps: fieldSectionProps,
1080
+ fieldSectionTabs: fieldSectionTabs,
1081
+ fieldSelect: fieldRoles.fieldSelect,
1082
+ fieldText: fieldRoles.fieldText,
1083
+ fieldTextArea: fieldTextArea,
1084
+ fieldUpload: fieldRoles.fieldUpload,
1085
+ fieldViewportHeights: fieldViewportHeights
1086
+ });
1087
+
1088
+ exports.fieldAction = fieldAction;
1089
+ exports.fieldBlocks = fieldBlocks;
1090
+ exports.fieldCheckbox = fieldCheckbox;
1091
+ exports.fieldCode = fieldCode;
1092
+ exports.fieldConfigProps = fieldConfigProps;
1093
+ exports.fieldContainerProps = fieldContainerProps;
1094
+ exports.fieldContainerWidths = fieldContainerWidths;
1095
+ exports.fieldContentProps = fieldContentProps;
1096
+ exports.fieldDate = fieldDate;
1097
+ exports.fieldEmail = fieldEmail;
1098
+ exports.fieldFontSizes = fieldFontSizes;
1099
+ exports.fieldHeights = fieldHeights;
1100
+ exports.fieldJoin = fieldJoin;
1101
+ exports.fieldMargins = fieldMargins;
1102
+ exports.fieldMenuItems = fieldMenuItems;
1103
+ exports.fieldNumber = fieldNumber;
1104
+ exports.fieldPaddings = fieldPaddings;
1105
+ exports.fieldPoint = fieldPoint;
1106
+ exports.fieldRadioGroup = fieldRadioGroup;
1107
+ exports.fieldRelationship = fieldRelationship;
1108
+ exports.fieldRichText = fieldRichText;
1109
+ exports.fieldSectionProps = fieldSectionProps;
1110
+ exports.fieldSectionTabs = fieldSectionTabs;
1111
+ exports.fieldTextArea = fieldTextArea;
1112
+ exports.fieldThemeColor = fieldThemeColor;
1113
+ exports.fieldViewportHeights = fieldViewportHeights;
1114
+ exports.index = index;
1115
+ //# sourceMappingURL=index-BsQFx-nI.js.map