@woodylab/payload 0.0.19 → 0.0.22

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/index.cjs.js CHANGED
@@ -1,12 +1,289 @@
1
1
  'use strict';
2
2
 
3
3
  var fields_index = require('./index-DhejC-CC.js');
4
- var config_index = require('./index-Ds44OSfM.js');
4
+ var config_index = require('./index-D0uU9RKm.js');
5
5
  var fieldRoles = require('./fieldRoles-ByWB8j1Q.js');
6
6
 
7
+ const hexToRgb = (hex) => {
8
+ // Rimuove il simbolo `#` se presente
9
+ const cleanedHex = hex.replace(/^#/, '');
10
+ // Controlla che il colore sia valido (3 o 6 caratteri)
11
+ if (!/^([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$/.test(cleanedHex)) {
12
+ throw new Error(`Colore HEX non valido: ${hex}`);
13
+ }
14
+ // In caso di formato corto (es. "FFF"), lo converte in formato lungo (es. "FFFFFF")
15
+ const expandedHex = cleanedHex.length === 3
16
+ ? cleanedHex
17
+ .split('')
18
+ .map(char => char + char)
19
+ .join('')
20
+ : cleanedHex;
21
+ // Converte il valore HEX in decimali per R, G e B
22
+ const r = parseInt(expandedHex.slice(0, 2), 16);
23
+ const g = parseInt(expandedHex.slice(2, 4), 16);
24
+ const b = parseInt(expandedHex.slice(4, 6), 16);
25
+ return { r, g, b };
26
+ };
7
27
 
28
+ function generateCssVars(settings) {
29
+ // Gestione robusta dei font
30
+ const fontWeights = [300, 400, 500, 600, 700, 800];
31
+ const fontsToImport = [settings.headingFont, settings.textFont]
32
+ .filter(Boolean)
33
+ .map(f => {
34
+ if (!f)
35
+ return '';
36
+ // Aggiungiamo il parametro wght per specificare i pesi da caricare
37
+ return `@import url('https://fonts.googleapis.com/css2?family=${f.replace(/ /g, "+")}:wght@${fontWeights.join(';')}&display=swap');`;
38
+ })
39
+ .join("\n");
40
+ const generateOpacityVariants = (color, name) => {
41
+ if (!color) {
42
+ return '';
43
+ }
44
+ try {
45
+ const rgbValue = hexToRgb(color);
46
+ if (!rgbValue || typeof rgbValue.r !== 'number' ||
47
+ typeof rgbValue.g !== 'number' ||
48
+ typeof rgbValue.b !== 'number') {
49
+ console.warn(`Impossibile convertire il colore ${name}: ${color}`);
50
+ return '';
51
+ }
52
+ const { r, g, b } = rgbValue;
53
+ const opacityVars = Array.from({ length: 9 }, (_, i) => {
54
+ const opacity = (i + 1) * 10;
55
+ return `--color-${name}-${opacity}: rgba(${r}, ${g}, ${b}, ${opacity / 100});`;
56
+ }).join("\n");
57
+ return `
58
+ --color-${name}: rgb(${r}, ${g}, ${b}); /* Default (opacità 1) */
59
+ ${opacityVars}
60
+ `;
61
+ }
62
+ catch (error) {
63
+ console.warn(`Errore nella generazione delle varianti di opacità per ${name}: ${error}`);
64
+ return '';
65
+ }
66
+ };
67
+ // Genera variabili solo per i colori forniti
68
+ const primaryVars = generateOpacityVariants(settings.primaryColor, "primary");
69
+ const secondaryVars = generateOpacityVariants(settings.secondaryColor, "secondary");
70
+ const accentVars = generateOpacityVariants(settings.accentColor, "accent");
71
+ const darkVars = generateOpacityVariants(settings.darkColor, "dark");
72
+ const lightVars = generateOpacityVariants(settings.lightColor, "light");
73
+ // Genera i valori dei font in modo sicuro
74
+ const headingFontValue = settings.headingFont
75
+ ? `'${settings.headingFont}', sans-serif`
76
+ : 'system-layout, sans-serif';
77
+ const textFontValue = settings.textFont
78
+ ? `'${settings.textFont}', sans-serif`
79
+ : 'system-layout, sans-serif';
80
+ return `
81
+ ${fontsToImport}
82
+
83
+ :root {
84
+ --font-heading: ${headingFontValue};
85
+ --font-text: ${textFontValue};
86
+ --color-white: #ffffff;
87
+ --color-black: #000000;
88
+ --color-foreground: ${settings.foregroundColor || '#FFFFFF'};
89
+ ${primaryVars}
90
+ ${secondaryVars}
91
+ ${accentVars}
92
+ ${darkVars}
93
+ ${lightVars}
94
+ }
95
+ `;
96
+ }
97
+
98
+ function getButtonClasses(config) {
99
+ const { buttonStyle = 'solid', buttonColor = 'primary', buttonSize = 'default', buttonRounded = 'default', iconPosition = 'left', textColor, // Aggiungiamo il colore del testo
100
+ additionalEffects = [], } = config;
101
+ const classes = [
102
+ 'inline-flex',
103
+ 'items-center',
104
+ 'justify-center',
105
+ 'font-medium',
106
+ 'focus:outline-none',
107
+ 'focus-visible:ring-2',
108
+ 'focus-visible:ring-offset-2',
109
+ ];
110
+ // Stile base
111
+ switch (buttonStyle) {
112
+ case 'solid':
113
+ classes.push(`bg-${buttonColor}`);
114
+ // Usa textColor se specificato, altrimenti usa il colore predefinito basato sul buttonColor
115
+ if (textColor) {
116
+ classes.push(`text-${textColor}`);
117
+ }
118
+ else {
119
+ classes.push(buttonColor === 'light' ? 'text-dark' : 'text-white');
120
+ }
121
+ classes.push(`hover:bg-${buttonColor}/90`);
122
+ break;
123
+ case 'outline':
124
+ classes.push(`border`);
125
+ classes.push(`border-${buttonColor}`);
126
+ // Usa textColor se specificato, altrimenti usa il colore del bottone
127
+ if (textColor) {
128
+ classes.push(`text-${textColor}`);
129
+ // Mantieni lo stesso colore di testo per l'hover, a meno che non sia specificato diversamente
130
+ classes.push(`hover:text-${textColor}`);
131
+ }
132
+ else {
133
+ classes.push(`text-${buttonColor}`);
134
+ classes.push(`hover:text-${buttonColor === 'light' ? 'dark' : 'white'}`);
135
+ }
136
+ classes.push(`hover:bg-${buttonColor}`);
137
+ break;
138
+ case 'ghost':
139
+ // Usa textColor se specificato, altrimenti usa il colore del bottone
140
+ if (textColor) {
141
+ classes.push(`text-${textColor}`);
142
+ }
143
+ else {
144
+ classes.push(`text-${buttonColor}`);
145
+ }
146
+ classes.push(`hover:bg-${buttonColor}/10`);
147
+ break;
148
+ case 'link':
149
+ // Usa textColor se specificato, altrimenti usa il colore del bottone
150
+ if (textColor) {
151
+ classes.push(`text-${textColor}`);
152
+ }
153
+ else {
154
+ classes.push(`text-${buttonColor}`);
155
+ }
156
+ classes.push('hover:underline');
157
+ break;
158
+ }
159
+ // Dimensione
160
+ switch (buttonSize) {
161
+ case 'small':
162
+ classes.push('text-xs px-2.5 py-1.5');
163
+ break;
164
+ case 'default':
165
+ classes.push('text-sm px-4 py-2');
166
+ break;
167
+ case 'medium':
168
+ classes.push('text-base px-5 py-2.5');
169
+ break;
170
+ case 'large':
171
+ classes.push('text-lg px-6 py-3');
172
+ break;
173
+ case 'xl':
174
+ classes.push('text-xl px-8 py-4');
175
+ break;
176
+ }
177
+ // Se è solo icona, aggiusta il padding per renderlo quadrato/rotondo
178
+ if (config.useIcon && iconPosition === 'only') {
179
+ classes.push('p-0');
180
+ switch (buttonSize) {
181
+ case 'small':
182
+ classes.push('w-7 h-7');
183
+ break;
184
+ case 'default':
185
+ classes.push('w-9 h-9');
186
+ break;
187
+ case 'medium':
188
+ classes.push('w-10 h-10');
189
+ break;
190
+ case 'large':
191
+ classes.push('w-12 h-12');
192
+ break;
193
+ case 'xl':
194
+ classes.push('w-14 h-14');
195
+ break;
196
+ }
197
+ }
198
+ // Arrotondamento
199
+ switch (buttonRounded) {
200
+ case 'none':
201
+ classes.push('rounded-none');
202
+ break;
203
+ case 'sm':
204
+ classes.push('rounded-sm');
205
+ break;
206
+ case 'default':
207
+ classes.push('rounded');
208
+ break;
209
+ case 'lg':
210
+ classes.push('rounded-lg');
211
+ break;
212
+ case 'full':
213
+ classes.push('rounded-full');
214
+ break;
215
+ }
216
+ // Effetti aggiuntivi
217
+ if (additionalEffects) {
218
+ if (additionalEffects.includes('shadow')) {
219
+ classes.push('shadow-md hover:shadow-lg');
220
+ }
221
+ if (additionalEffects.includes('transition')) {
222
+ classes.push('transition-all duration-200');
223
+ }
224
+ if (additionalEffects.includes('scale')) {
225
+ classes.push('transform hover:scale-105');
226
+ }
227
+ }
228
+ // Aggiungi la classe focus-ring per il colore appropriato
229
+ classes.push(`focus-visible:ring-${buttonColor}/50`);
230
+ return classes.join(' ');
231
+ }
232
+
233
+ function getClassName(config) {
234
+ // Mantieni tutte le altre classi Tailwind, ma ometti quelle di colore di sfondo
235
+ const classList = [];
236
+ // Gestione campi compositi
237
+ ['p', 'm'].forEach((field) => {
238
+ if (config[field]?.className) {
239
+ classList.push(config[field].className);
240
+ }
241
+ });
242
+ // Gestione campi diretti
243
+ ['fs', 'h', 'container'].forEach((field) => {
244
+ if (config[field]) {
245
+ classList.push(config[field]);
246
+ }
247
+ });
248
+ // Altre classi che non sono colori dinamici
249
+ if (config.bgi && config.bgi.url) {
250
+ classList.push('bg-no-repeat bg-cover');
251
+ }
252
+ if (config.boxShadow) {
253
+ classList.push(config.boxShadow);
254
+ }
255
+ if (config.borderRadius) {
256
+ classList.push(config.borderRadius);
257
+ }
258
+ return classList.join(' ');
259
+ }
260
+
261
+ function getInlineStyles(config) {
262
+ const styles = {};
263
+ // Gestisci il background color con stile inline
264
+ if (config.bgc) {
265
+ styles.backgroundColor = config.bgc;
266
+ }
267
+ // Gestione background image
268
+ if (config.bgi && config.bgi.url) {
269
+ styles.backgroundImage = `url("${config.bgi.url}")`;
270
+ // Gestione focal point
271
+ if (typeof config.bgi.focalX === 'number' && typeof config.bgi.focalY === 'number') {
272
+ styles.backgroundPosition = `${config.bgi.focalX}% ${config.bgi.focalY}%`;
273
+ }
274
+ }
275
+ return styles;
276
+ }
8
277
 
9
278
  exports.Fields = fields_index.index;
10
279
  exports.Config = config_index.index;
280
+ exports.generatePreviewPath = config_index.generatePreviewPath;
281
+ exports.googleFonts = config_index.GoogleFonts;
11
282
  exports.Tailwind = fieldRoles.index;
283
+ exports.iconsList = fieldRoles.iconsList;
284
+ exports.generateCssVars = generateCssVars;
285
+ exports.getButtonClasses = getButtonClasses;
286
+ exports.getClassName = getClassName;
287
+ exports.getInlineStyles = getInlineStyles;
288
+ exports.hexToRgb = hexToRgb;
12
289
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/hexToRgb.ts","../src/generateCssVars.ts","../src/getButtonClasses.ts","../src/getClassName.ts","../src/getInlineStyles.ts"],"sourcesContent":["const hexToRgb = (hex: string): { r: number; g: number; b: number } => {\n // Rimuove il simbolo `#` se presente\n const cleanedHex = hex.replace(/^#/, '');\n\n // Controlla che il colore sia valido (3 o 6 caratteri)\n if (!/^([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$/.test(cleanedHex)) {\n throw new Error(`Colore HEX non valido: ${hex}`);\n }\n\n // In caso di formato corto (es. \"FFF\"), lo converte in formato lungo (es. \"FFFFFF\")\n const expandedHex =\n cleanedHex.length === 3\n ? cleanedHex\n .split('')\n .map(char => char + char)\n .join('')\n : cleanedHex;\n\n // Converte il valore HEX in decimali per R, G e B\n const r = parseInt(expandedHex.slice(0, 2), 16);\n const g = parseInt(expandedHex.slice(2, 4), 16);\n const b = parseInt(expandedHex.slice(4, 6), 16);\n\n return { r, g, b };\n};\n\nexport default hexToRgb;","import hexToRgb from \"./hexToRgb\";\n\nfunction generateCssVars(settings: {\n headingFont?: string;\n textFont?: string;\n foregroundColor?: string;\n primaryColor?: string;\n secondaryColor?: string;\n accentColor?: string;\n darkColor?: string;\n lightColor?: string;\n}): string {\n // Gestione robusta dei font\n const fontWeights = [300, 400, 500, 600, 700, 800];\n\n const fontsToImport = [settings.headingFont, settings.textFont]\n .filter(Boolean)\n .map(f => {\n if (!f) return '';\n // Aggiungiamo il parametro wght per specificare i pesi da caricare\n return `@import url('https://fonts.googleapis.com/css2?family=${f.replace(\n / /g,\n \"+\"\n )}:wght@${fontWeights.join(';')}&display=swap');`\n })\n .join(\"\\n\");\n\n\n const generateOpacityVariants = (color: string | undefined, name: string): string => {\n if (!color) {\n return '';\n }\n\n try {\n const rgbValue = hexToRgb(color);\n\n if (!rgbValue || typeof rgbValue.r !== 'number' ||\n typeof rgbValue.g !== 'number' ||\n typeof rgbValue.b !== 'number') {\n console.warn(`Impossibile convertire il colore ${name}: ${color}`);\n return '';\n }\n\n const { r, g, b } = rgbValue;\n\n const opacityVars = Array.from({ length: 9 }, (_, i) => {\n const opacity = (i + 1) * 10;\n return `--color-${name}-${opacity}: rgba(${r}, ${g}, ${b}, ${opacity / 100});`;\n }).join(\"\\n\");\n\n return `\n --color-${name}: rgb(${r}, ${g}, ${b}); /* Default (opacità 1) */\n ${opacityVars}\n `;\n } catch (error) {\n console.warn(`Errore nella generazione delle varianti di opacità per ${name}: ${error}`);\n return '';\n }\n };\n\n // Genera variabili solo per i colori forniti\n const primaryVars = generateOpacityVariants(settings.primaryColor, \"primary\");\n const secondaryVars = generateOpacityVariants(settings.secondaryColor, \"secondary\");\n const accentVars = generateOpacityVariants(settings.accentColor, \"accent\");\n const darkVars = generateOpacityVariants(settings.darkColor, \"dark\");\n const lightVars = generateOpacityVariants(settings.lightColor, \"light\");\n\n // Genera i valori dei font in modo sicuro\n const headingFontValue = settings.headingFont\n ? `'${settings.headingFont}', sans-serif`\n : 'system-layout, sans-serif';\n\n const textFontValue = settings.textFont\n ? `'${settings.textFont}', sans-serif`\n : 'system-layout, sans-serif';\n\n return `\n ${fontsToImport}\n\n :root {\n --font-heading: ${headingFontValue};\n --font-text: ${textFontValue};\n --color-white: #ffffff;\n --color-black: #000000;\n --color-foreground: ${settings.foregroundColor || '#FFFFFF'};\n ${primaryVars}\n ${secondaryVars}\n ${accentVars}\n ${darkVars}\n ${lightVars}\n }\n `;\n}\n\nexport default generateCssVars;\n","export type ButtonConfig = {\n show: boolean\n buttonStyle?: 'solid' | 'outline' | 'ghost' | 'link'\n buttonColor?: 'primary' | 'secondary' | 'accent' | 'dark' | 'light'\n buttonSize?: 'small' | 'default' | 'medium' | 'large' | 'xl'\n buttonRounded?: 'none' | 'sm' | 'default' | 'lg' | 'full'\n useIcon?: boolean\n iconPosition?: 'left' | 'right' | 'only'\n iconName?: string\n iconVariant?: 'outline' | 'solid'\n alignment?: 'left' | 'center' | 'right'\n textColor?: 'primary' | 'secondary' | 'accent' | 'dark' | 'light' | 'white' | 'black'\n additionalEffects?: ('shadow' | 'transition' | 'scale')[]\n}\n\nexport type ActionConfig = ButtonConfig & {\n show?: boolean\n actionType?: 'internalLink' | 'externalLink' | 'customAction'\n internalLink?: {\n relationTo: string\n value: {\n slug: string\n id: string\n }\n }\n externalLink?: string\n customActionId?: string\n label?: string\n onClick?: () => void\n}\n\nfunction getButtonClasses(config: ActionConfig): string {\n const {\n buttonStyle = 'solid',\n buttonColor = 'primary',\n buttonSize = 'default',\n buttonRounded = 'default',\n iconPosition = 'left',\n textColor, // Aggiungiamo il colore del testo\n additionalEffects = [],\n } = config\n\n const classes: string[] = [\n 'inline-flex',\n 'items-center',\n 'justify-center',\n 'font-medium',\n 'focus:outline-none',\n 'focus-visible:ring-2',\n 'focus-visible:ring-offset-2',\n ]\n\n // Stile base\n switch (buttonStyle) {\n case 'solid':\n classes.push(`bg-${buttonColor}`)\n // Usa textColor se specificato, altrimenti usa il colore predefinito basato sul buttonColor\n if (textColor) {\n classes.push(`text-${textColor}`)\n } else {\n classes.push(buttonColor === 'light' ? 'text-dark' : 'text-white')\n }\n classes.push(`hover:bg-${buttonColor}/90`)\n break\n case 'outline':\n classes.push(`border`)\n classes.push(`border-${buttonColor}`)\n // Usa textColor se specificato, altrimenti usa il colore del bottone\n if (textColor) {\n classes.push(`text-${textColor}`)\n // Mantieni lo stesso colore di testo per l'hover, a meno che non sia specificato diversamente\n classes.push(`hover:text-${textColor}`)\n } else {\n classes.push(`text-${buttonColor}`)\n classes.push(`hover:text-${buttonColor === 'light' ? 'dark' : 'white'}`)\n }\n classes.push(`hover:bg-${buttonColor}`)\n break\n case 'ghost':\n // Usa textColor se specificato, altrimenti usa il colore del bottone\n if (textColor) {\n classes.push(`text-${textColor}`)\n } else {\n classes.push(`text-${buttonColor}`)\n }\n classes.push(`hover:bg-${buttonColor}/10`)\n break\n case 'link':\n // Usa textColor se specificato, altrimenti usa il colore del bottone\n if (textColor) {\n classes.push(`text-${textColor}`)\n } else {\n classes.push(`text-${buttonColor}`)\n }\n classes.push('hover:underline')\n break\n }\n\n // Dimensione\n switch (buttonSize) {\n case 'small':\n classes.push('text-xs px-2.5 py-1.5')\n break\n case 'default':\n classes.push('text-sm px-4 py-2')\n break\n case 'medium':\n classes.push('text-base px-5 py-2.5')\n break\n case 'large':\n classes.push('text-lg px-6 py-3')\n break\n case 'xl':\n classes.push('text-xl px-8 py-4')\n break\n }\n\n // Se è solo icona, aggiusta il padding per renderlo quadrato/rotondo\n if (config.useIcon && iconPosition === 'only') {\n classes.push('p-0')\n switch (buttonSize) {\n case 'small':\n classes.push('w-7 h-7')\n break\n case 'default':\n classes.push('w-9 h-9')\n break\n case 'medium':\n classes.push('w-10 h-10')\n break\n case 'large':\n classes.push('w-12 h-12')\n break\n case 'xl':\n classes.push('w-14 h-14')\n break\n }\n }\n\n // Arrotondamento\n switch (buttonRounded) {\n case 'none':\n classes.push('rounded-none')\n break\n case 'sm':\n classes.push('rounded-sm')\n break\n case 'default':\n classes.push('rounded')\n break\n case 'lg':\n classes.push('rounded-lg')\n break\n case 'full':\n classes.push('rounded-full')\n break\n }\n\n // Effetti aggiuntivi\n if (additionalEffects) {\n if (additionalEffects.includes('shadow')) {\n classes.push('shadow-md hover:shadow-lg')\n }\n if (additionalEffects.includes('transition')) {\n classes.push('transition-all duration-200')\n }\n if (additionalEffects.includes('scale')) {\n classes.push('transform hover:scale-105')\n }\n }\n\n // Aggiungi la classe focus-ring per il colore appropriato\n classes.push(`focus-visible:ring-${buttonColor}/50`)\n\n return classes.join(' ')\n}\n\nexport default getButtonClasses\n","function getClassName(config: any): string {\n // Mantieni tutte le altre classi Tailwind, ma ometti quelle di colore di sfondo\n const classList: string[] = [];\n\n // Gestione campi compositi\n ['p', 'm'].forEach((field) => {\n if (config[field]?.className) {\n classList.push(config[field].className);\n }\n });\n\n // Gestione campi diretti\n ['fs', 'h', 'container'].forEach((field) => {\n if (config[field]) {\n classList.push(config[field]);\n }\n });\n\n // Altre classi che non sono colori dinamici\n if (config.bgi && config.bgi.url) {\n classList.push('bg-no-repeat bg-cover');\n }\n if (config.boxShadow) {\n classList.push(config.boxShadow);\n }\n if (config.borderRadius) {\n classList.push(config.borderRadius);\n }\n\n return classList.join(' ');\n}\nexport default getClassName;\n","import React from 'react'\n\nfunction getInlineStyles(config: any): React.CSSProperties {\n const styles: React.CSSProperties = {}\n\n // Gestisci il background color con stile inline\n if (config.bgc) {\n styles.backgroundColor = config.bgc\n }\n\n // Gestione background image\n if (config.bgi && config.bgi.url) {\n styles.backgroundImage = `url(\"${config.bgi.url}\")`\n\n // Gestione focal point\n if (typeof config.bgi.focalX === 'number' && typeof config.bgi.focalY === 'number') {\n styles.backgroundPosition = `${config.bgi.focalX}% ${config.bgi.focalY}%`\n }\n }\n\n return styles\n}\n\nexport default getInlineStyles\n"],"names":[],"mappings":";;;;;;AAAA,MAAM,QAAQ,GAAG,CAAC,GAAW,KAAyC;;IAElE,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;;IAGxC,IAAI,CAAC,mCAAmC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;AACvD,QAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,CAAA,CAAE,CAAC;IACpD;;AAGA,IAAA,MAAM,WAAW,GACb,UAAU,CAAC,MAAM,KAAK;AAClB,UAAE;aACG,KAAK,CAAC,EAAE;aACR,GAAG,CAAC,IAAI,IAAI,IAAI,GAAG,IAAI;aACvB,IAAI,CAAC,EAAE;UACV,UAAU;;AAGpB,IAAA,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;AAC/C,IAAA,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;AAC/C,IAAA,MAAM,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,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AAC,GAAG,CAAC;AAC9B;;AC5BA,SAAS,eAAe,CAAC,MAAW,EAAA;IAClC,MAAM,MAAM,GAAwB,EAAE;;AAGtC,IAAA,IAAI,MAAM,CAAC,GAAG,EAAE;AACd,QAAA,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC,GAAG;IACrC;;IAGA,IAAI,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE;QAChC,MAAM,CAAC,eAAe,GAAG,CAAA,KAAA,EAAQ,MAAM,CAAC,GAAG,CAAC,GAAG,CAAA,EAAA,CAAI;;AAGnD,QAAA,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAE;AAClF,YAAA,MAAM,CAAC,kBAAkB,GAAG,CAAA,EAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAA,EAAA,EAAK,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG;QAC3E;IACF;AAEA,IAAA,OAAO,MAAM;AACf;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,11 @@
1
1
  export * as Fields from './fields';
2
2
  export * as Config from './config';
3
3
  export * as Tailwind from './tailwind';
4
+ export { default as generateCssVars } from './generateCssVars';
5
+ export { default as generatePreviewPath } from './generatePreviewPath';
6
+ export { default as getButtonClasses } from './getButtonClasses';
7
+ export { default as getClassName } from './getClassName';
8
+ export { default as getInlineStyles } from './getInlineStyles';
9
+ export { default as googleFonts } from './googleFonts';
10
+ export { default as hexToRgb } from './hexToRgb';
11
+ export { default as iconsList } from './iconsList';
package/dist/index.esm.js CHANGED
@@ -1,4 +1,277 @@
1
- export { i as Fields } from './index-zJMnbEc6.js';
2
- export { i as Config } from './index-BPmTpfXE.js';
3
- export { i as Tailwind } from './fieldRoles-C_8MuKLB.js';
1
+ export { i as Fields } from './index-DwDOFamE.js';
2
+ export { i as Config, g as generatePreviewPath, G as googleFonts } from './index-DUzSwmzd.js';
3
+ export { i as Tailwind, a as iconsList } from './fieldRoles-CJKOMPeo.js';
4
+
5
+ const hexToRgb = (hex) => {
6
+ // Rimuove il simbolo `#` se presente
7
+ const cleanedHex = hex.replace(/^#/, '');
8
+ // Controlla che il colore sia valido (3 o 6 caratteri)
9
+ if (!/^([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$/.test(cleanedHex)) {
10
+ throw new Error(`Colore HEX non valido: ${hex}`);
11
+ }
12
+ // In caso di formato corto (es. "FFF"), lo converte in formato lungo (es. "FFFFFF")
13
+ const expandedHex = cleanedHex.length === 3
14
+ ? cleanedHex
15
+ .split('')
16
+ .map(char => char + char)
17
+ .join('')
18
+ : cleanedHex;
19
+ // Converte il valore HEX in decimali per R, G e B
20
+ const r = parseInt(expandedHex.slice(0, 2), 16);
21
+ const g = parseInt(expandedHex.slice(2, 4), 16);
22
+ const b = parseInt(expandedHex.slice(4, 6), 16);
23
+ return { r, g, b };
24
+ };
25
+
26
+ function generateCssVars(settings) {
27
+ // Gestione robusta dei font
28
+ const fontWeights = [300, 400, 500, 600, 700, 800];
29
+ const fontsToImport = [settings.headingFont, settings.textFont]
30
+ .filter(Boolean)
31
+ .map(f => {
32
+ if (!f)
33
+ return '';
34
+ // Aggiungiamo il parametro wght per specificare i pesi da caricare
35
+ return `@import url('https://fonts.googleapis.com/css2?family=${f.replace(/ /g, "+")}:wght@${fontWeights.join(';')}&display=swap');`;
36
+ })
37
+ .join("\n");
38
+ const generateOpacityVariants = (color, name) => {
39
+ if (!color) {
40
+ return '';
41
+ }
42
+ try {
43
+ const rgbValue = hexToRgb(color);
44
+ if (!rgbValue || typeof rgbValue.r !== 'number' ||
45
+ typeof rgbValue.g !== 'number' ||
46
+ typeof rgbValue.b !== 'number') {
47
+ console.warn(`Impossibile convertire il colore ${name}: ${color}`);
48
+ return '';
49
+ }
50
+ const { r, g, b } = rgbValue;
51
+ const opacityVars = Array.from({ length: 9 }, (_, i) => {
52
+ const opacity = (i + 1) * 10;
53
+ return `--color-${name}-${opacity}: rgba(${r}, ${g}, ${b}, ${opacity / 100});`;
54
+ }).join("\n");
55
+ return `
56
+ --color-${name}: rgb(${r}, ${g}, ${b}); /* Default (opacità 1) */
57
+ ${opacityVars}
58
+ `;
59
+ }
60
+ catch (error) {
61
+ console.warn(`Errore nella generazione delle varianti di opacità per ${name}: ${error}`);
62
+ return '';
63
+ }
64
+ };
65
+ // Genera variabili solo per i colori forniti
66
+ const primaryVars = generateOpacityVariants(settings.primaryColor, "primary");
67
+ const secondaryVars = generateOpacityVariants(settings.secondaryColor, "secondary");
68
+ const accentVars = generateOpacityVariants(settings.accentColor, "accent");
69
+ const darkVars = generateOpacityVariants(settings.darkColor, "dark");
70
+ const lightVars = generateOpacityVariants(settings.lightColor, "light");
71
+ // Genera i valori dei font in modo sicuro
72
+ const headingFontValue = settings.headingFont
73
+ ? `'${settings.headingFont}', sans-serif`
74
+ : 'system-layout, sans-serif';
75
+ const textFontValue = settings.textFont
76
+ ? `'${settings.textFont}', sans-serif`
77
+ : 'system-layout, sans-serif';
78
+ return `
79
+ ${fontsToImport}
80
+
81
+ :root {
82
+ --font-heading: ${headingFontValue};
83
+ --font-text: ${textFontValue};
84
+ --color-white: #ffffff;
85
+ --color-black: #000000;
86
+ --color-foreground: ${settings.foregroundColor || '#FFFFFF'};
87
+ ${primaryVars}
88
+ ${secondaryVars}
89
+ ${accentVars}
90
+ ${darkVars}
91
+ ${lightVars}
92
+ }
93
+ `;
94
+ }
95
+
96
+ function getButtonClasses(config) {
97
+ const { buttonStyle = 'solid', buttonColor = 'primary', buttonSize = 'default', buttonRounded = 'default', iconPosition = 'left', textColor, // Aggiungiamo il colore del testo
98
+ additionalEffects = [], } = config;
99
+ const classes = [
100
+ 'inline-flex',
101
+ 'items-center',
102
+ 'justify-center',
103
+ 'font-medium',
104
+ 'focus:outline-none',
105
+ 'focus-visible:ring-2',
106
+ 'focus-visible:ring-offset-2',
107
+ ];
108
+ // Stile base
109
+ switch (buttonStyle) {
110
+ case 'solid':
111
+ classes.push(`bg-${buttonColor}`);
112
+ // Usa textColor se specificato, altrimenti usa il colore predefinito basato sul buttonColor
113
+ if (textColor) {
114
+ classes.push(`text-${textColor}`);
115
+ }
116
+ else {
117
+ classes.push(buttonColor === 'light' ? 'text-dark' : 'text-white');
118
+ }
119
+ classes.push(`hover:bg-${buttonColor}/90`);
120
+ break;
121
+ case 'outline':
122
+ classes.push(`border`);
123
+ classes.push(`border-${buttonColor}`);
124
+ // Usa textColor se specificato, altrimenti usa il colore del bottone
125
+ if (textColor) {
126
+ classes.push(`text-${textColor}`);
127
+ // Mantieni lo stesso colore di testo per l'hover, a meno che non sia specificato diversamente
128
+ classes.push(`hover:text-${textColor}`);
129
+ }
130
+ else {
131
+ classes.push(`text-${buttonColor}`);
132
+ classes.push(`hover:text-${buttonColor === 'light' ? 'dark' : 'white'}`);
133
+ }
134
+ classes.push(`hover:bg-${buttonColor}`);
135
+ break;
136
+ case 'ghost':
137
+ // Usa textColor se specificato, altrimenti usa il colore del bottone
138
+ if (textColor) {
139
+ classes.push(`text-${textColor}`);
140
+ }
141
+ else {
142
+ classes.push(`text-${buttonColor}`);
143
+ }
144
+ classes.push(`hover:bg-${buttonColor}/10`);
145
+ break;
146
+ case 'link':
147
+ // Usa textColor se specificato, altrimenti usa il colore del bottone
148
+ if (textColor) {
149
+ classes.push(`text-${textColor}`);
150
+ }
151
+ else {
152
+ classes.push(`text-${buttonColor}`);
153
+ }
154
+ classes.push('hover:underline');
155
+ break;
156
+ }
157
+ // Dimensione
158
+ switch (buttonSize) {
159
+ case 'small':
160
+ classes.push('text-xs px-2.5 py-1.5');
161
+ break;
162
+ case 'default':
163
+ classes.push('text-sm px-4 py-2');
164
+ break;
165
+ case 'medium':
166
+ classes.push('text-base px-5 py-2.5');
167
+ break;
168
+ case 'large':
169
+ classes.push('text-lg px-6 py-3');
170
+ break;
171
+ case 'xl':
172
+ classes.push('text-xl px-8 py-4');
173
+ break;
174
+ }
175
+ // Se è solo icona, aggiusta il padding per renderlo quadrato/rotondo
176
+ if (config.useIcon && iconPosition === 'only') {
177
+ classes.push('p-0');
178
+ switch (buttonSize) {
179
+ case 'small':
180
+ classes.push('w-7 h-7');
181
+ break;
182
+ case 'default':
183
+ classes.push('w-9 h-9');
184
+ break;
185
+ case 'medium':
186
+ classes.push('w-10 h-10');
187
+ break;
188
+ case 'large':
189
+ classes.push('w-12 h-12');
190
+ break;
191
+ case 'xl':
192
+ classes.push('w-14 h-14');
193
+ break;
194
+ }
195
+ }
196
+ // Arrotondamento
197
+ switch (buttonRounded) {
198
+ case 'none':
199
+ classes.push('rounded-none');
200
+ break;
201
+ case 'sm':
202
+ classes.push('rounded-sm');
203
+ break;
204
+ case 'default':
205
+ classes.push('rounded');
206
+ break;
207
+ case 'lg':
208
+ classes.push('rounded-lg');
209
+ break;
210
+ case 'full':
211
+ classes.push('rounded-full');
212
+ break;
213
+ }
214
+ // Effetti aggiuntivi
215
+ if (additionalEffects) {
216
+ if (additionalEffects.includes('shadow')) {
217
+ classes.push('shadow-md hover:shadow-lg');
218
+ }
219
+ if (additionalEffects.includes('transition')) {
220
+ classes.push('transition-all duration-200');
221
+ }
222
+ if (additionalEffects.includes('scale')) {
223
+ classes.push('transform hover:scale-105');
224
+ }
225
+ }
226
+ // Aggiungi la classe focus-ring per il colore appropriato
227
+ classes.push(`focus-visible:ring-${buttonColor}/50`);
228
+ return classes.join(' ');
229
+ }
230
+
231
+ function getClassName(config) {
232
+ // Mantieni tutte le altre classi Tailwind, ma ometti quelle di colore di sfondo
233
+ const classList = [];
234
+ // Gestione campi compositi
235
+ ['p', 'm'].forEach((field) => {
236
+ if (config[field]?.className) {
237
+ classList.push(config[field].className);
238
+ }
239
+ });
240
+ // Gestione campi diretti
241
+ ['fs', 'h', 'container'].forEach((field) => {
242
+ if (config[field]) {
243
+ classList.push(config[field]);
244
+ }
245
+ });
246
+ // Altre classi che non sono colori dinamici
247
+ if (config.bgi && config.bgi.url) {
248
+ classList.push('bg-no-repeat bg-cover');
249
+ }
250
+ if (config.boxShadow) {
251
+ classList.push(config.boxShadow);
252
+ }
253
+ if (config.borderRadius) {
254
+ classList.push(config.borderRadius);
255
+ }
256
+ return classList.join(' ');
257
+ }
258
+
259
+ function getInlineStyles(config) {
260
+ const styles = {};
261
+ // Gestisci il background color con stile inline
262
+ if (config.bgc) {
263
+ styles.backgroundColor = config.bgc;
264
+ }
265
+ // Gestione background image
266
+ if (config.bgi && config.bgi.url) {
267
+ styles.backgroundImage = `url("${config.bgi.url}")`;
268
+ // Gestione focal point
269
+ if (typeof config.bgi.focalX === 'number' && typeof config.bgi.focalY === 'number') {
270
+ styles.backgroundPosition = `${config.bgi.focalX}% ${config.bgi.focalY}%`;
271
+ }
272
+ }
273
+ return styles;
274
+ }
275
+
276
+ export { generateCssVars, getButtonClasses, getClassName, getInlineStyles, hexToRgb };
4
277
  //# sourceMappingURL=index.esm.js.map