fansunited-frontend-core 0.0.19 → 0.0.20
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/README.md +373 -6
- package/functions/helpers.d.ts +2 -2
- package/functions/helpers.d.ts.map +1 -1
- package/index.es.js +1194 -1155
- package/interfaces/interfaces.d.ts +10 -0
- package/interfaces/interfaces.d.ts.map +1 -1
- package/locales/en.json.d.ts +39 -0
- package/package.json +1 -1
- package/locales/bg.json +0 -113
- package/locales/de.json +0 -113
- package/locales/en.json +0 -113
- package/locales/es.json +0 -113
- package/locales/fr-be.json +0 -113
- package/locales/fr.json +0 -113
- package/locales/it.json +0 -113
- package/locales/pl.json +0 -113
- package/locales/pt-br.json +0 -113
- package/locales/pt.json +0 -113
- package/locales/ro.json +0 -113
- package/locales/sk.json +0 -113
- package/locales/sr.json +0 -113
package/README.md
CHANGED
|
@@ -27,12 +27,100 @@ yarn add fansunited-frontend-core
|
|
|
27
27
|
|
|
28
28
|
```tsx
|
|
29
29
|
import {
|
|
30
|
+
// Component Props
|
|
30
31
|
ClassicQuizPlayProps,
|
|
31
|
-
|
|
32
|
+
BaseClassicQuizPlayProps,
|
|
33
|
+
ClassicQuizAwarenessProps,
|
|
34
|
+
PollVoteProps,
|
|
35
|
+
BasePollVoteProps,
|
|
36
|
+
PersonalityQuizPlayProps,
|
|
37
|
+
BasePersonalityQuizPlayProps,
|
|
38
|
+
CollectLeadProps,
|
|
39
|
+
BaseCollectLeadProps,
|
|
40
|
+
CollectLeadFormProps,
|
|
41
|
+
CollectLeadMainProps,
|
|
32
42
|
MainProps,
|
|
43
|
+
|
|
44
|
+
// Configuration Interfaces
|
|
45
|
+
Configuration,
|
|
46
|
+
ClassicQuizAwarenessConfiguration,
|
|
47
|
+
ClassicQuizPlayConfiguration,
|
|
48
|
+
|
|
49
|
+
// Theme and Styling
|
|
33
50
|
CustomThemeOptions,
|
|
51
|
+
EnhancedCustomThemeOptions,
|
|
52
|
+
InternalCustomThemeOptions,
|
|
53
|
+
CustomColors,
|
|
54
|
+
InternalCustomColors,
|
|
55
|
+
CustomSpacingScale,
|
|
56
|
+
CustomBorderRadius,
|
|
57
|
+
CustomBorderSize,
|
|
58
|
+
CustomBreakpoints,
|
|
59
|
+
ImageBackgroundGradient,
|
|
60
|
+
FontConfig,
|
|
61
|
+
ThemeMode,
|
|
62
|
+
|
|
63
|
+
// Lead Management
|
|
34
64
|
LeadsOptions,
|
|
35
|
-
|
|
65
|
+
LeadCustomField,
|
|
66
|
+
LeadConsent,
|
|
67
|
+
LeadLabels,
|
|
68
|
+
FormLeadLabels,
|
|
69
|
+
|
|
70
|
+
// Content and Branding
|
|
71
|
+
ContentInfo,
|
|
72
|
+
CampaignInfo,
|
|
73
|
+
BrandingInfo,
|
|
74
|
+
BrandingImages,
|
|
75
|
+
FormBrandingInfo,
|
|
76
|
+
FormBrandingImages,
|
|
77
|
+
BrandingColors,
|
|
78
|
+
BrandingUrls,
|
|
79
|
+
|
|
80
|
+
// CTA and User Interaction
|
|
81
|
+
CTADetails,
|
|
82
|
+
SignInCTADetails,
|
|
83
|
+
OnSuccessCTADetails,
|
|
84
|
+
|
|
85
|
+
// Analytics and Events
|
|
86
|
+
AnalyticsEvent,
|
|
87
|
+
UserState,
|
|
88
|
+
|
|
89
|
+
// Enums
|
|
90
|
+
WidgetTemplate
|
|
91
|
+
} from "fansunited-frontend-core";
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Type Definitions
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import {
|
|
98
|
+
// Journey and Analytics Types
|
|
99
|
+
JourneyType,
|
|
100
|
+
StageType,
|
|
101
|
+
ActionType,
|
|
102
|
+
CTAType,
|
|
103
|
+
StagesType,
|
|
104
|
+
WidgetType,
|
|
105
|
+
|
|
106
|
+
// UI and Layout Types
|
|
107
|
+
LinkTargetType,
|
|
108
|
+
ContentViewType,
|
|
109
|
+
OptionsLayout,
|
|
110
|
+
|
|
111
|
+
// Internationalization
|
|
112
|
+
LanguageType,
|
|
113
|
+
|
|
114
|
+
// Lead Collection
|
|
115
|
+
LeadField,
|
|
116
|
+
LeadPosition,
|
|
117
|
+
CountryType,
|
|
118
|
+
ContentType,
|
|
119
|
+
|
|
120
|
+
// Hook Types
|
|
121
|
+
UseLeadFormParams,
|
|
122
|
+
UseLeadFormReturn,
|
|
123
|
+
LeadFormData
|
|
36
124
|
} from "fansunited-frontend-core";
|
|
37
125
|
```
|
|
38
126
|
|
|
@@ -46,7 +134,8 @@ import {
|
|
|
46
134
|
useCornerRadius,
|
|
47
135
|
useColors,
|
|
48
136
|
useBorderSize,
|
|
49
|
-
useInternalTheme
|
|
137
|
+
useInternalTheme,
|
|
138
|
+
useImageBackgroundGradient
|
|
50
139
|
} from "fansunited-frontend-core";
|
|
51
140
|
```
|
|
52
141
|
|
|
@@ -57,8 +146,95 @@ import {
|
|
|
57
146
|
stripHtmlTags,
|
|
58
147
|
hexToRgb,
|
|
59
148
|
isAndroid,
|
|
60
|
-
isMobile
|
|
149
|
+
isMobile,
|
|
150
|
+
getDefaultCountryByCode,
|
|
151
|
+
getDefaultCountryByLanguage,
|
|
152
|
+
extractBrandingProperties,
|
|
153
|
+
sanitizeBackgroundUrl,
|
|
154
|
+
mapContentTypeToConsentEntityType
|
|
155
|
+
} from "fansunited-frontend-core";
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### React Hooks
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import {
|
|
162
|
+
useImageUrl,
|
|
163
|
+
useThemeMode,
|
|
164
|
+
useConstantContext,
|
|
165
|
+
useImageVariant,
|
|
166
|
+
useLeadForm
|
|
167
|
+
} from "fansunited-frontend-core";
|
|
168
|
+
|
|
169
|
+
// Example: Lead form hook usage
|
|
170
|
+
const leadForm = useLeadForm({
|
|
171
|
+
sdk: sdkInstance,
|
|
172
|
+
fields: ["fullName", "email"],
|
|
173
|
+
campaignId: "campaign-123",
|
|
174
|
+
contentType: "quiz",
|
|
175
|
+
contentId: "quiz-456"
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### React Providers
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import {
|
|
183
|
+
ThemeProvider,
|
|
184
|
+
ConstantsProvider,
|
|
185
|
+
ConstantsContext
|
|
61
186
|
} from "fansunited-frontend-core";
|
|
187
|
+
|
|
188
|
+
// Example: Theme provider setup
|
|
189
|
+
<ThemeProvider themeOptions={customTheme}>
|
|
190
|
+
<ConstantsProvider
|
|
191
|
+
shadowRootElement={shadowRoot}
|
|
192
|
+
leadPhoneCountryCode="US"
|
|
193
|
+
language="en"
|
|
194
|
+
optionsLayout="twoByTwo"
|
|
195
|
+
>
|
|
196
|
+
<YourApp />
|
|
197
|
+
</ConstantsProvider>
|
|
198
|
+
</ThemeProvider>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Components
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import {
|
|
205
|
+
Spinner,
|
|
206
|
+
CollectLeadForm
|
|
207
|
+
} from "fansunited-frontend-core";
|
|
208
|
+
|
|
209
|
+
// Example: Spinner component
|
|
210
|
+
<Spinner my={4} />
|
|
211
|
+
|
|
212
|
+
// Example: Lead collection form
|
|
213
|
+
<CollectLeadForm
|
|
214
|
+
sdk={sdkInstance}
|
|
215
|
+
fields={["fullName", "email"]}
|
|
216
|
+
labels={{
|
|
217
|
+
title: "Join Our Newsletter",
|
|
218
|
+
submitButtonLabel: "Subscribe"
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Constants
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
import {
|
|
227
|
+
validWidgetTypes,
|
|
228
|
+
validWidgetTemplates,
|
|
229
|
+
countries,
|
|
230
|
+
languageToCountryCode
|
|
231
|
+
} from "fansunited-frontend-core";
|
|
232
|
+
|
|
233
|
+
// Access predefined country list
|
|
234
|
+
const countryOptions = countries;
|
|
235
|
+
|
|
236
|
+
// Get country code by language
|
|
237
|
+
const countryCode = languageToCountryCode["en"]; // "GB"
|
|
62
238
|
```
|
|
63
239
|
|
|
64
240
|
### Internationalization
|
|
@@ -86,22 +262,213 @@ initializeI18n("en");
|
|
|
86
262
|
- Serbian (sr)
|
|
87
263
|
- Slovak (sk)
|
|
88
264
|
|
|
89
|
-
## Usage
|
|
265
|
+
## Usage Examples
|
|
266
|
+
|
|
267
|
+
### Basic Widget Setup
|
|
90
268
|
|
|
91
269
|
This package is designed to work with `fansunited-frontend-components`:
|
|
92
270
|
|
|
93
271
|
```tsx
|
|
94
272
|
import { ClassicQuizPlay } from "fansunited-frontend-components";
|
|
95
|
-
import { WidgetTemplate } from "fansunited-frontend-core";
|
|
273
|
+
import { WidgetTemplate, CustomThemeOptions } from "fansunited-frontend-core";
|
|
274
|
+
|
|
275
|
+
const customTheme: CustomThemeOptions = {
|
|
276
|
+
mode: "light",
|
|
277
|
+
colorSchemes: {
|
|
278
|
+
light: {
|
|
279
|
+
textPrimary: "#333333",
|
|
280
|
+
surface: "#ffffff"
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
96
284
|
|
|
97
285
|
<ClassicQuizPlay
|
|
98
286
|
entityId="quiz-123"
|
|
99
287
|
sdk={sdkInstance}
|
|
100
288
|
template={WidgetTemplate.STANDARD}
|
|
101
289
|
language="en"
|
|
290
|
+
themeOptions={customTheme}
|
|
291
|
+
imagePosition="left"
|
|
102
292
|
/>;
|
|
103
293
|
```
|
|
104
294
|
|
|
295
|
+
### Lead Collection Setup
|
|
296
|
+
|
|
297
|
+
```tsx
|
|
298
|
+
import { CollectLead } from "fansunited-frontend-components";
|
|
299
|
+
import {
|
|
300
|
+
WidgetTemplate,
|
|
301
|
+
LeadField,
|
|
302
|
+
LeadCustomField,
|
|
303
|
+
LeadConsent
|
|
304
|
+
} from "fansunited-frontend-core";
|
|
305
|
+
|
|
306
|
+
const leadFields: LeadField[] = ["fullName", "email", "phoneNumber"];
|
|
307
|
+
|
|
308
|
+
const customFields: LeadCustomField[] = [
|
|
309
|
+
{
|
|
310
|
+
key: "company",
|
|
311
|
+
label: "Company Name",
|
|
312
|
+
type: "input",
|
|
313
|
+
required: true,
|
|
314
|
+
placeholder: "Enter your company name"
|
|
315
|
+
}
|
|
316
|
+
];
|
|
317
|
+
|
|
318
|
+
const consents: LeadConsent[] = [
|
|
319
|
+
{
|
|
320
|
+
id: "marketing",
|
|
321
|
+
label: "I agree to receive marketing communications"
|
|
322
|
+
}
|
|
323
|
+
];
|
|
324
|
+
|
|
325
|
+
<CollectLead
|
|
326
|
+
entityId="lead-form-123"
|
|
327
|
+
sdk={sdkInstance}
|
|
328
|
+
template={WidgetTemplate.OVERLAY}
|
|
329
|
+
language="en"
|
|
330
|
+
fields={leadFields}
|
|
331
|
+
customFields={customFields}
|
|
332
|
+
consents={consents}
|
|
333
|
+
labels={{
|
|
334
|
+
title: "Get Exclusive Updates",
|
|
335
|
+
submitButtonLabel: "Subscribe Now"
|
|
336
|
+
}}
|
|
337
|
+
/>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Theme Customization
|
|
341
|
+
|
|
342
|
+
```tsx
|
|
343
|
+
import {
|
|
344
|
+
ThemeProvider,
|
|
345
|
+
CustomThemeOptions,
|
|
346
|
+
FontConfig
|
|
347
|
+
} from "fansunited-frontend-core";
|
|
348
|
+
|
|
349
|
+
const customFont: FontConfig = {
|
|
350
|
+
family: "Inter",
|
|
351
|
+
url: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap",
|
|
352
|
+
weights: [400, 500, 600, 700],
|
|
353
|
+
display: "swap"
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const themeOptions: CustomThemeOptions = {
|
|
357
|
+
mode: "dark",
|
|
358
|
+
customFontFamily: {
|
|
359
|
+
light: {
|
|
360
|
+
primary: customFont,
|
|
361
|
+
secondary: "Arial, sans-serif"
|
|
362
|
+
},
|
|
363
|
+
dark: {
|
|
364
|
+
primary: customFont,
|
|
365
|
+
secondary: "Arial, sans-serif"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
spacingScale: {
|
|
369
|
+
xs: "6px",
|
|
370
|
+
sm: "12px",
|
|
371
|
+
md: "18px",
|
|
372
|
+
lg: "24px"
|
|
373
|
+
},
|
|
374
|
+
colorSchemes: {
|
|
375
|
+
dark: {
|
|
376
|
+
textPrimary: "#ffffff",
|
|
377
|
+
surface: "#1a1a1a",
|
|
378
|
+
palette: {
|
|
379
|
+
primary: {
|
|
380
|
+
plainColor: "#3b82f6",
|
|
381
|
+
primaryContainer: "#1e40af"
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
<ThemeProvider themeOptions={themeOptions}>
|
|
389
|
+
<YourApp />
|
|
390
|
+
</ThemeProvider>
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Using Hooks
|
|
394
|
+
|
|
395
|
+
```tsx
|
|
396
|
+
import {
|
|
397
|
+
useLeadForm,
|
|
398
|
+
useThemeMode,
|
|
399
|
+
useColors,
|
|
400
|
+
UseLeadFormParams
|
|
401
|
+
} from "fansunited-frontend-core";
|
|
402
|
+
|
|
403
|
+
function MyComponent() {
|
|
404
|
+
// Theme utilities
|
|
405
|
+
const colors = useColors();
|
|
406
|
+
const { mode, setMode } = useThemeMode();
|
|
407
|
+
|
|
408
|
+
// Lead form management
|
|
409
|
+
const leadFormParams: UseLeadFormParams = {
|
|
410
|
+
sdk: sdkInstance,
|
|
411
|
+
fields: ["fullName", "email"],
|
|
412
|
+
campaignId: "newsletter-2024",
|
|
413
|
+
contentType: "quiz",
|
|
414
|
+
contentId: "quiz-123"
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
const {
|
|
418
|
+
formData,
|
|
419
|
+
updateField,
|
|
420
|
+
submitForm,
|
|
421
|
+
isSubmitting,
|
|
422
|
+
isSuccess,
|
|
423
|
+
error
|
|
424
|
+
} = useLeadForm(leadFormParams);
|
|
425
|
+
|
|
426
|
+
return (
|
|
427
|
+
<div style={{ backgroundColor: colors.surface }}>
|
|
428
|
+
<button onClick={() => setMode(mode === "light" ? "dark" : "light")}>
|
|
429
|
+
Toggle Theme
|
|
430
|
+
</button>
|
|
431
|
+
{/* Your form UI */}
|
|
432
|
+
</div>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Country and Language Utilities
|
|
438
|
+
|
|
439
|
+
```tsx
|
|
440
|
+
import {
|
|
441
|
+
countries,
|
|
442
|
+
languageToCountryCode,
|
|
443
|
+
getDefaultCountryByLanguage,
|
|
444
|
+
getDefaultCountryByCode
|
|
445
|
+
} from "fansunited-frontend-core";
|
|
446
|
+
|
|
447
|
+
// Get all available countries
|
|
448
|
+
const allCountries = countries;
|
|
449
|
+
|
|
450
|
+
// Get suggested countries only
|
|
451
|
+
const suggestedCountries = countries.filter(country => country.suggested);
|
|
452
|
+
|
|
453
|
+
// Get default country by language
|
|
454
|
+
const defaultCountry = getDefaultCountryByLanguage("fr"); // Returns France
|
|
455
|
+
|
|
456
|
+
// Get country by code
|
|
457
|
+
const usCountry = getDefaultCountryByCode("US");
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
## Widget Templates
|
|
461
|
+
|
|
462
|
+
The package supports three main widget templates:
|
|
463
|
+
|
|
464
|
+
- **`WidgetTemplate.STANDARD`** - Traditional card layout with optional image positioning
|
|
465
|
+
- **`WidgetTemplate.OVERLAY`** - Full-screen overlay presentation
|
|
466
|
+
- **`WidgetTemplate.SPLIT`** - Split-screen layout with content and media sections
|
|
467
|
+
|
|
468
|
+
## TypeScript Support
|
|
469
|
+
|
|
470
|
+
This package is built with TypeScript and provides comprehensive type definitions for all exports. The types ensure type safety when working with widget configurations, theme options, and component props.
|
|
471
|
+
|
|
105
472
|
## License
|
|
106
473
|
|
|
107
474
|
© Fans United Media. All rights reserved.
|
package/functions/helpers.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BrandingColorsModel, BrandingModel, ConsentEntityType } from 'fansunited-sdk-esm';
|
|
2
2
|
|
|
3
|
-
export declare const stripHtmlTags: (html: string) => string;
|
|
3
|
+
export declare const stripHtmlTags: (html: string | null) => string;
|
|
4
4
|
export declare const hexToRgb: (hex: string) => string;
|
|
5
5
|
export declare const isAndroid: () => boolean;
|
|
6
6
|
export declare const getDefaultCountryByCode: (phoneCountryCode: string | null) => import('..').CountryType | null;
|
|
7
7
|
export declare const getDefaultCountryByLanguage: (language: string | null) => import('..').CountryType | null;
|
|
8
|
-
export declare const extractBrandingProperties: (branding: BrandingModel) => {
|
|
8
|
+
export declare const extractBrandingProperties: (branding: BrandingModel | null) => {
|
|
9
9
|
brandingImage: string | null;
|
|
10
10
|
brandingColors: BrandingColorsModel | null;
|
|
11
11
|
brandingLogo: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/functions/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/functions/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAI5B,eAAO,MAAM,aAAa,SAAU,MAAM,GAAG,IAAI,KAAG,MAKnD,CAAC;AAEF,eAAO,MAAM,QAAQ,QAAS,MAAM,KAAG,MAUtC,CAAC;AAGF,eAAO,MAAM,SAAS,QAAO,OAE5B,CAAC;AAEF,eAAO,MAAM,uBAAuB,qBAAsB,MAAM,GAAG,IAAI,oCAItE,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAAc,MAAM,GAAG,IAAI,oCAIlE,CAAC;AAEF,eAAO,MAAM,yBAAyB,aAAc,aAAa,GAAG,IAAI;;;;CAevE,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAS,MAAM,WAMhD,CAAC;AAEF,eAAO,MAAM,iCAAiC,SACtC,MAAM,GAAG,SAAS,GAAG,IAAI,KAC9B,iBAAiB,GAAG,SAsBtB,CAAC"}
|