@eqproject/eqp-dynamic-module 2.10.67 → 2.10.68
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/esm2020/lib/components/exported/eqp-dynamic-module-configurator/eqp-dynamic-module-configurator.component.mjs +3 -1
- package/esm2020/lib/components/private/form-records/add-form-record/add-form-record.component.mjs +3 -1
- package/esm2020/lib/utils/google-fonts-injector.mjs +78 -0
- package/fesm2015/eqproject-eqp-dynamic-module.mjs +81 -0
- package/fesm2015/eqproject-eqp-dynamic-module.mjs.map +1 -1
- package/fesm2020/eqproject-eqp-dynamic-module.mjs +80 -0
- package/fesm2020/eqproject-eqp-dynamic-module.mjs.map +1 -1
- package/lib/utils/google-fonts-injector.d.ts +7 -0
- package/package.json +1 -1
|
@@ -3084,6 +3084,84 @@ var LogicOperator;
|
|
|
3084
3084
|
LogicOperator[LogicOperator["CONTIENE TUTTI"] = 12] = "CONTIENE TUTTI";
|
|
3085
3085
|
})(LogicOperator || (LogicOperator = {}));
|
|
3086
3086
|
|
|
3087
|
+
const SYSTEM_FONTS = new Set([
|
|
3088
|
+
// Generici CSS
|
|
3089
|
+
'sans-serif', 'serif', 'monospace', 'cursive', 'fantasy', 'system-ui',
|
|
3090
|
+
'inherit', 'initial', 'unset', 'revert',
|
|
3091
|
+
// Famiglie sistema Windows / Mac / Linux
|
|
3092
|
+
'-apple-system', 'blinkmacsystemfont', 'segoe ui', 'helvetica neue',
|
|
3093
|
+
'helvetica', 'arial', 'verdana', 'tahoma', 'trebuchet ms', 'georgia',
|
|
3094
|
+
'times new roman', 'times', 'courier new', 'courier', 'lucida console',
|
|
3095
|
+
'lucida sans unicode', 'impact', 'comic sans ms', 'palatino linotype',
|
|
3096
|
+
'book antiqua', 'palatino', 'garamond', 'bookman',
|
|
3097
|
+
]);
|
|
3098
|
+
const FIELD_CSS_KEYS = [
|
|
3099
|
+
'TextFieldStyleCSS', 'TextareaFieldStyleCSS', 'BooleanFieldStyleCSS',
|
|
3100
|
+
'DateFieldStyleCSS', 'NumericFieldStyleCSS', 'AttachmentFieldStyleCSS',
|
|
3101
|
+
'ImageFieldStyleCSS', 'ListValueFieldStyleCSS', 'ImageSelectorFieldStyleCSS',
|
|
3102
|
+
'LabelFieldStyleCSS', 'ImageWithMarkersFieldStyleCSS', 'ActionButtonFieldStyleCSS',
|
|
3103
|
+
];
|
|
3104
|
+
function collectCssStrings(form) {
|
|
3105
|
+
const result = [];
|
|
3106
|
+
if (form.ThemeCSS)
|
|
3107
|
+
result.push(form.ThemeCSS);
|
|
3108
|
+
if (form.TitleCSS)
|
|
3109
|
+
result.push(form.TitleCSS);
|
|
3110
|
+
for (const field of form.Fields ?? []) {
|
|
3111
|
+
const f = field;
|
|
3112
|
+
if (f.FieldstyleCSS)
|
|
3113
|
+
result.push(f.FieldstyleCSS);
|
|
3114
|
+
if (f.LabelstyleCSS)
|
|
3115
|
+
result.push(f.LabelstyleCSS);
|
|
3116
|
+
for (const key of FIELD_CSS_KEYS) {
|
|
3117
|
+
const cssObj = f[key];
|
|
3118
|
+
if (cssObj && typeof cssObj === 'object') {
|
|
3119
|
+
for (const val of Object.values(cssObj)) {
|
|
3120
|
+
if (typeof val === 'string' && val)
|
|
3121
|
+
result.push(val);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
return result;
|
|
3127
|
+
}
|
|
3128
|
+
function extractGoogleFontNames(cssStrings) {
|
|
3129
|
+
const found = new Set();
|
|
3130
|
+
for (const css of cssStrings) {
|
|
3131
|
+
const regex = /font-family\s*:\s*([^;]+)/gi;
|
|
3132
|
+
let match;
|
|
3133
|
+
while ((match = regex.exec(css)) !== null) {
|
|
3134
|
+
for (const part of match[1].split(',')) {
|
|
3135
|
+
const name = part.trim().replace(/^['"]|['"]$/g, '').trim();
|
|
3136
|
+
if (name && !SYSTEM_FONTS.has(name.toLowerCase())) {
|
|
3137
|
+
found.add(name);
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
return Array.from(found);
|
|
3143
|
+
}
|
|
3144
|
+
/**
|
|
3145
|
+
* Scansiona tutte le stringhe CSS del form (ThemeCSS, TitleCSS, FieldStyleCSS tipizzati)
|
|
3146
|
+
* ed inietta un <link> a Google Fonts per ogni font non-di-sistema trovato.
|
|
3147
|
+
* Idempotente: non aggiunge link già presenti nel DOM.
|
|
3148
|
+
*/
|
|
3149
|
+
function injectGoogleFontsFromForm(form) {
|
|
3150
|
+
if (!form || typeof document === 'undefined')
|
|
3151
|
+
return;
|
|
3152
|
+
const fonts = extractGoogleFontNames(collectCssStrings(form));
|
|
3153
|
+
for (const font of fonts) {
|
|
3154
|
+
const id = `gfont-${font.replace(/\s+/g, '-').toLowerCase()}`;
|
|
3155
|
+
if (document.getElementById(id))
|
|
3156
|
+
continue;
|
|
3157
|
+
const link = document.createElement('link');
|
|
3158
|
+
link.id = id;
|
|
3159
|
+
link.rel = 'stylesheet';
|
|
3160
|
+
link.href = `https://fonts.bunny.net/css2?family=${encodeURIComponent(font)}:ital,wght@0,400;0,700;1,400&display=swap`;
|
|
3161
|
+
document.head.appendChild(link);
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3087
3165
|
/* ESEMPIO D'USO
|
|
3088
3166
|
|
|
3089
3167
|
<textarea
|
|
@@ -8142,6 +8220,7 @@ class AddFormRecordComponent {
|
|
|
8142
8220
|
this.visibleActionButtons = new Array();
|
|
8143
8221
|
}
|
|
8144
8222
|
ngOnInit() {
|
|
8223
|
+
injectGoogleFontsFromForm(this.form);
|
|
8145
8224
|
if (this.form != null && this.orgaID != null) {
|
|
8146
8225
|
this.form.OrgaID = this.orgaID;
|
|
8147
8226
|
}
|
|
@@ -17645,6 +17724,7 @@ class EqpDynamicModuleConfiguratorComponent {
|
|
|
17645
17724
|
}
|
|
17646
17725
|
this.configureColumns();
|
|
17647
17726
|
this.createFormForm();
|
|
17727
|
+
injectGoogleFontsFromForm(this.form);
|
|
17648
17728
|
}
|
|
17649
17729
|
/**
|
|
17650
17730
|
* Configura le colonne per le tabelle necessarie alla creazione della form:
|