fansunited-frontend-core 0.0.43 → 0.0.44
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/functions/functions.js +4 -0
- package/functions/functions.js.map +1 -0
- package/functions/helpers.js +129 -0
- package/functions/helpers.js.map +1 -0
- package/index.es.js +7761 -7576
- package/package.json +1 -1
- package/types/types.js +2 -0
- package/types/types.js.map +1 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useSpacingScale, getSpacing, isMobile, isExtraSmall, isTablet, isDesktop, useFontFamily, useCornerRadius, useColors, useBorderSize, useInternalTheme, useImageBackgroundGradient, isLarge, useCurrentThemeMode, } from "./theme";
|
|
2
|
+
export { stripHtmlTags, hexToRgb, isAndroid, getDefaultCountryByCode, getDefaultCountryByLanguage, extractBrandingModelProperties, extractBrandingProperties, sanitizeBackgroundUrl, mapContentTypeToConsentEntityType, getBrandingClickUrl, getRelatedInfoPageId, isWithPrize, } from "./helpers";
|
|
3
|
+
export { initializeI18n } from "./i18n";
|
|
4
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/functions/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,aAAa,EACb,eAAe,EACf,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,OAAO,EACP,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,aAAa,EACb,QAAQ,EACR,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,iCAAiC,EACjC,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { countries, languageToCountryCode } from "../constants/constants";
|
|
2
|
+
import { isMobile } from "./theme";
|
|
3
|
+
export const stripHtmlTags = (html) => {
|
|
4
|
+
const tmp = document.createElement("div");
|
|
5
|
+
tmp.innerHTML = html || "";
|
|
6
|
+
return tmp.textContent || tmp.innerText || "";
|
|
7
|
+
};
|
|
8
|
+
export const hexToRgb = (hex) => {
|
|
9
|
+
// Remove the hash if present
|
|
10
|
+
hex = hex.replace(/^#/, "");
|
|
11
|
+
// Parse the hex values
|
|
12
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
13
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
14
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
15
|
+
return `${r}, ${g}, ${b}`;
|
|
16
|
+
};
|
|
17
|
+
// Helper function to check if running on Android
|
|
18
|
+
export const isAndroid = () => {
|
|
19
|
+
return /Android/i.test(navigator.userAgent);
|
|
20
|
+
};
|
|
21
|
+
export const getDefaultCountryByCode = (phoneCountryCode) => {
|
|
22
|
+
const code = phoneCountryCode || "44";
|
|
23
|
+
return countries.find((country) => country.phone === code) || null;
|
|
24
|
+
};
|
|
25
|
+
export const getDefaultCountryByLanguage = (language) => {
|
|
26
|
+
const code = language ? languageToCountryCode[language] : "GB";
|
|
27
|
+
return countries.find((country) => country.code === code) || null;
|
|
28
|
+
};
|
|
29
|
+
export const getCountryByCode = (code) => {
|
|
30
|
+
return countries.find((country) => country.code === code) || null;
|
|
31
|
+
};
|
|
32
|
+
export const extractBrandingModelProperties = (branding) => {
|
|
33
|
+
const mobile = isMobile();
|
|
34
|
+
let brandingImage = branding?.images?.backgroundImage || null;
|
|
35
|
+
let brandingLogo = branding?.images?.mainLogo || null;
|
|
36
|
+
let brandingColors = null;
|
|
37
|
+
if (mobile && branding?.images) {
|
|
38
|
+
brandingImage =
|
|
39
|
+
branding.images.mobileBackgroundImage ||
|
|
40
|
+
branding.images.backgroundImage ||
|
|
41
|
+
null;
|
|
42
|
+
brandingLogo = branding.images.mobileLogo || branding.images.mainLogo;
|
|
43
|
+
}
|
|
44
|
+
if (branding?.colors) {
|
|
45
|
+
brandingColors = branding.colors;
|
|
46
|
+
}
|
|
47
|
+
return { brandingImage, brandingColors, brandingLogo };
|
|
48
|
+
};
|
|
49
|
+
export const extractBrandingProperties = (branding) => {
|
|
50
|
+
const mobile = isMobile();
|
|
51
|
+
let brandingImage = branding?.images?.background_image || null;
|
|
52
|
+
let brandingLogo = branding?.images?.main_logo || null;
|
|
53
|
+
let brandingColors = null;
|
|
54
|
+
if (mobile && branding?.images) {
|
|
55
|
+
brandingImage =
|
|
56
|
+
branding.images.mobile_background_image ||
|
|
57
|
+
branding.images.background_image ||
|
|
58
|
+
null;
|
|
59
|
+
brandingLogo = branding.images.mobile_logo || branding.images.main_logo;
|
|
60
|
+
}
|
|
61
|
+
if (branding?.colors) {
|
|
62
|
+
brandingColors = branding.colors;
|
|
63
|
+
}
|
|
64
|
+
return { brandingImage, brandingColors, brandingLogo };
|
|
65
|
+
};
|
|
66
|
+
export const sanitizeBackgroundUrl = (url) => {
|
|
67
|
+
try {
|
|
68
|
+
return `url("${url}")`;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return "none";
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export const mapContentTypeToConsentEntityType = (type) => {
|
|
75
|
+
if (!type)
|
|
76
|
+
return undefined;
|
|
77
|
+
// Backward compatibility: map generic "quiz" to "classic_quiz"
|
|
78
|
+
if (type === "quiz")
|
|
79
|
+
return "classic_quiz";
|
|
80
|
+
// If already valid, pass through
|
|
81
|
+
const valid = [
|
|
82
|
+
"template",
|
|
83
|
+
"classic_quiz",
|
|
84
|
+
"personality_quiz",
|
|
85
|
+
"either_or",
|
|
86
|
+
"match_quiz",
|
|
87
|
+
"top_x",
|
|
88
|
+
"bracket",
|
|
89
|
+
"standing",
|
|
90
|
+
"poll",
|
|
91
|
+
];
|
|
92
|
+
if (valid.includes(type))
|
|
93
|
+
return type;
|
|
94
|
+
// Fallback: don't set entityType if unknown
|
|
95
|
+
console.warn(`[CollectLead] Unknown content type "${type}" for consents; omitting entityType.`);
|
|
96
|
+
return undefined;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Get the appropriate URL for branding elements based on primaryUrl and secondaryUrl
|
|
100
|
+
* @param primaryUrl - Primary URL from branding.urls.primaryUrl
|
|
101
|
+
* @param secondaryUrl - Secondary URL from branding.urls.secondaryUrl
|
|
102
|
+
* @param target - Target element type: 'image' or 'logo'
|
|
103
|
+
* @returns The appropriate URL or null
|
|
104
|
+
*
|
|
105
|
+
* Logic:
|
|
106
|
+
* - For images: use primaryUrl if available, otherwise null
|
|
107
|
+
* - For logos: use secondaryUrl if available, otherwise primaryUrl if available, otherwise null
|
|
108
|
+
*/
|
|
109
|
+
export const getBrandingClickUrl = (primaryUrl, secondaryUrl, target) => {
|
|
110
|
+
const primary = primaryUrl?.trim() || null;
|
|
111
|
+
const secondary = secondaryUrl?.trim() || null;
|
|
112
|
+
if (target === "image") {
|
|
113
|
+
return primary;
|
|
114
|
+
}
|
|
115
|
+
// For logo: secondary takes priority, fallback to primary
|
|
116
|
+
return secondary || primary;
|
|
117
|
+
};
|
|
118
|
+
export const getRelatedInfoPageId = (related) => {
|
|
119
|
+
if (!related?.length)
|
|
120
|
+
return null;
|
|
121
|
+
const match = related.find((r) => r.entityType === "info_page" && r.entityRelationship === "relatedTo");
|
|
122
|
+
return match?.entityId ?? null;
|
|
123
|
+
};
|
|
124
|
+
export const isWithPrize = (flags) => {
|
|
125
|
+
if (!flags)
|
|
126
|
+
return false;
|
|
127
|
+
return flags.some((flag) => flag.toLowerCase() === "prize");
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/functions/helpers.ts"],"names":[],"mapp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