fansunited-frontend-components 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 CHANGED
@@ -548,6 +548,499 @@ import { WidgetTemplate } from "fansunited-frontend-core";
548
548
  />
549
549
  ```
550
550
 
551
- #### Related Packages
551
+ ### CollectLead
552
+
553
+ Lead collection component for capturing user information with customizable forms, branding, and success actions. Perfect for newsletter signups, contact forms, and user registration flows.
554
+
555
+ **Key Features:**
556
+ - Customizable form fields (name, email, phone, country, gender, custom fields)
557
+ - Consent management and privacy policy integration
558
+ - Custom branding and theming support
559
+ - Success page with custom CTAs
560
+ - Three responsive templates (Standard, Split, Overlay)
561
+ - Phone number validation with country codes
562
+ - Multi-language support
563
+
564
+ #### Required Props
565
+
566
+ | Prop | Type | Description |
567
+ | ---------- | -------------------- | ------------------------------ |
568
+ | `entityId` | `string` | Lead collection form identifier |
569
+ | `sdk` | `FansUnitedSDKModel` | SDK instance |
570
+ | `template` | `WidgetTemplate` | Layout template |
571
+ | `language` | `LanguageType` | Display language |
572
+
573
+ #### Optional Props
574
+
575
+ | Prop | Type | Description |
576
+ | ---------------------------- | ----------------------- | ------------------------------------------- |
577
+ | `themeOptions` | `CustomThemeOptions` | Theme configuration |
578
+ | `fields` | `LeadField[]` | Form fields to display |
579
+ | `labels` | `LeadLabels` | Custom labels for form elements |
580
+ | `imagePosition` | `"left" \| "right"` | Image position (STANDARD template only) |
581
+ | `defaultImagePlaceholderUrl` | `string` | URL for default image placeholder |
582
+ | `phoneCountryCode` | `string` | Default country code for phone fields |
583
+ | `onSuccessCTA` | `OnSuccessCTADetails` | Success page call to action configuration |
584
+ | `customFields` | `LeadCustomField[]` | Additional custom form fields |
585
+ | `consents` | `LeadConsent[]` | Consent checkboxes for privacy compliance |
586
+ | `content` | `ContentInfo` | Content metadata |
587
+ | `campaign` | `CampaignInfo` | Campaign information |
588
+ | `branding` | `BrandingInfo` | Branding configuration |
589
+ | `images` | `ImagesModel` | Image assets |
590
+
591
+ #### Templates
592
+
593
+ ```tsx
594
+ import { WidgetTemplate, CollectLeadProps } from "fansunited-frontend-core";
595
+
596
+ // Standard template with optional image positioning
597
+ const standardProps: CollectLeadProps = {
598
+ template: WidgetTemplate.STANDARD,
599
+ imagePosition: "left", // or 'right'
600
+ // ... other props
601
+ };
602
+
603
+ // Split template - side-by-side layout
604
+ const splitProps: CollectLeadProps = {
605
+ template: WidgetTemplate.SPLIT,
606
+ // imagePosition not available for non-standard templates
607
+ // ... other props
608
+ };
609
+
610
+ // Overlay template - full-screen immersive experience
611
+ const overlayProps: CollectLeadProps = {
612
+ template: WidgetTemplate.OVERLAY,
613
+ // ... other props
614
+ };
615
+ ```
616
+
617
+ #### Form Configuration
618
+
619
+ Configure which fields to display and their behavior:
620
+
621
+ ```tsx
622
+ import { LeadField, LeadCustomField, LeadConsent } from "fansunited-frontend-core";
623
+
624
+ // Standard form fields
625
+ const fields: LeadField[] = [
626
+ "fullName",
627
+ "email",
628
+ "phoneNumber",
629
+ "country",
630
+ "gender"
631
+ ];
632
+
633
+ // Custom fields for additional data collection
634
+ const customFields: LeadCustomField[] = [
635
+ {
636
+ key: "company",
637
+ label: "Company Name",
638
+ type: "input",
639
+ required: true,
640
+ placeholder: "Enter your company name"
641
+ },
642
+ {
643
+ key: "message",
644
+ label: "Message",
645
+ type: "textarea",
646
+ required: false,
647
+ placeholder: "Tell us about your needs..."
648
+ }
649
+ ];
650
+
651
+ // Consent checkboxes for privacy compliance
652
+ const consents: LeadConsent[] = [
653
+ {
654
+ id: "marketing",
655
+ label: "I agree to receive marketing communications"
656
+ },
657
+ {
658
+ id: "newsletter",
659
+ label: "Subscribe to our newsletter"
660
+ }
661
+ ];
662
+
663
+ <CollectLead
664
+ {...otherProps}
665
+ fields={fields}
666
+ customFields={customFields}
667
+ consents={consents}
668
+ />
669
+ ```
670
+
671
+ #### Custom Labels
672
+
673
+ Customize all text displayed in the form:
674
+
675
+ ```tsx
676
+ import { LeadLabels } from "fansunited-frontend-core";
677
+
678
+ const labels: LeadLabels = {
679
+ title: "Join Our Community",
680
+ description: "Get exclusive updates and early access to new features",
681
+ formTitle: "Sign Up Today",
682
+ formDescription: "Fill out the form below to get started",
683
+ formFullNameLabel: "Full Name",
684
+ formFullNamePlaceholder: "Enter your full name",
685
+ formEmailLabel: "Email Address",
686
+ formGenderLabel: "Gender",
687
+ formGenderPlaceholder: "Select your gender",
688
+ formCountryLabel: "Country",
689
+ formCountryPlaceholder: "Select your country",
690
+ formPhoneNumberLabel: "Phone Number",
691
+ formPhoneNumberPlaceholder: "Enter your phone number",
692
+ submitButtonLabel: "Subscribe Now",
693
+ successTitle: "Welcome Aboard!",
694
+ successDescription: "Thank you for joining our community. Check your email for next steps.",
695
+ privacyPolicyUrlLabel: "Privacy Policy",
696
+ termsAndConditionsUrlLabel: "Terms & Conditions",
697
+ presentedByLabel: "Powered by"
698
+ };
699
+
700
+ <CollectLead {...otherProps} labels={labels} />
701
+ ```
702
+
703
+ #### Success Actions
704
+
705
+ Configure what happens after successful form submission:
706
+
707
+ ```tsx
708
+ import { OnSuccessCTADetails } from "fansunited-frontend-core";
709
+
710
+ // Custom success action with onClick handler
711
+ const onSuccessCTA: OnSuccessCTADetails = {
712
+ defaultLabel: "Continue to Dashboard",
713
+ onClick: () => {
714
+ // Handle post-submission logic
715
+ window.location.href = "/dashboard";
716
+ }
717
+ };
718
+
719
+ // Success action with URL navigation
720
+ const onSuccessCTA: OnSuccessCTADetails = {
721
+ defaultLabel: "Visit Our Website",
722
+ url: "https://your-website.com",
723
+ target: "_blank"
724
+ };
725
+
726
+ // Custom success component
727
+ const onSuccessCTA: OnSuccessCTADetails = {
728
+ component: <CustomSuccessButton />
729
+ };
730
+
731
+ <CollectLead {...otherProps} onSuccessCTA={onSuccessCTA} />
732
+ ```
733
+
734
+ #### Examples
735
+
736
+ ##### Basic Lead Form
737
+
738
+ ```tsx
739
+ import { CollectLead } from "fansunited-frontend-components";
740
+ import { WidgetTemplate } from "fansunited-frontend-core";
741
+
742
+ <CollectLead
743
+ entityId="lead-form-123"
744
+ sdk={sdkInstance}
745
+ template={WidgetTemplate.STANDARD}
746
+ language="en"
747
+ fields={["fullName", "email"]}
748
+ />
749
+ ```
750
+
751
+ ##### Advanced Lead Form
752
+
753
+ ```tsx
754
+ <CollectLead
755
+ entityId="lead-form-123"
756
+ sdk={sdkInstance}
757
+ template={WidgetTemplate.OVERLAY}
758
+ language="en"
759
+ fields={["fullName", "email", "phoneNumber", "country"]}
760
+ phoneCountryCode="44"
761
+ customFields={[
762
+ {
763
+ key: "company",
764
+ label: "Company",
765
+ type: "input",
766
+ required: true
767
+ }
768
+ ]}
769
+ consents={[
770
+ {
771
+ id: "marketing",
772
+ label: "I agree to receive marketing emails"
773
+ }
774
+ ]}
775
+ labels={{
776
+ title: "Get Early Access",
777
+ submitButtonLabel: "Join Waitlist",
778
+ successTitle: "You're In!",
779
+ successDescription: "We'll notify you when we launch."
780
+ }}
781
+ onSuccessCTA={{
782
+ defaultLabel: "Learn More",
783
+ url: "https://example.com/learn-more",
784
+ target: "_blank"
785
+ }}
786
+ themeOptions={{
787
+ mode: "dark"
788
+ }}
789
+ />
790
+ ```
791
+
792
+ ### PersonalityQuizPlay
793
+
794
+ Interactive personality quiz component that matches users with personas based on their answers. Features comprehensive result displays with persona matching, detailed explanations, and customizable templates.
795
+
796
+ **Key Features:**
797
+ - Personality matching algorithm with percentage scores
798
+ - Multiple persona results with detailed descriptions
799
+ - Tabbed result interface with top match highlighting
800
+ - Answer explanations and persona insights
801
+ - Three responsive templates (Standard, Split, Overlay)
802
+ - Lead collection integration
803
+ - Authentication support
804
+ - Custom theming and branding
805
+ - Result sharing capabilities
806
+
807
+ #### Required Props
808
+
809
+ | Prop | Type | Description |
810
+ | ---------- | -------------------- | ---------------------------------- |
811
+ | `entityId` | `string` | Personality Quiz identifier |
812
+ | `sdk` | `FansUnitedSDKModel` | SDK instance |
813
+ | `template` | `WidgetTemplate` | Layout template |
814
+ | `language` | `LanguageType` | Display language |
815
+
816
+ #### Optional Props
817
+
818
+ | Prop | Type | Description |
819
+ | ---------------------------- | -------------------- | ------------------------------------------- |
820
+ | `themeOptions` | `CustomThemeOptions` | Theme configuration |
821
+ | `showAnswerExplanations` | `boolean` | Show explanations after quiz completion |
822
+ | `leads` | `LeadsOptions` | Lead collection settings |
823
+ | `imagePosition` | `"left" \| "right"` | Image position (STANDARD template only) |
824
+ | `defaultImagePlaceholderUrl` | `string` | URL for default image placeholder |
825
+ | `userIsLoggedIn` | `boolean` | Determine if the user is logged in |
826
+ | `signInCTA` | `SignInCTADetails` | Sign in call to action button configuration |
827
+ | `optionsLayout` | `OptionsLayout` | Layout for answer options |
828
+
829
+ #### Templates
830
+
831
+ ```tsx
832
+ import { WidgetTemplate, PersonalityQuizPlayProps } from "fansunited-frontend-core";
833
+
834
+ // Standard template with optional image positioning
835
+ const standardProps: PersonalityQuizPlayProps = {
836
+ template: WidgetTemplate.STANDARD,
837
+ imagePosition: "left", // or 'right'
838
+ // ... other props
839
+ };
840
+
841
+ // Split template - side-by-side layout
842
+ const splitProps: PersonalityQuizPlayProps = {
843
+ template: WidgetTemplate.SPLIT,
844
+ // imagePosition not available for non-standard templates
845
+ // ... other props
846
+ };
847
+
848
+ // Overlay template - full-screen immersive experience
849
+ const overlayProps: PersonalityQuizPlayProps = {
850
+ template: WidgetTemplate.OVERLAY,
851
+ // ... other props
852
+ };
853
+ ```
854
+
855
+ #### Options Layout
856
+
857
+ Configure how answer options are displayed:
858
+
859
+ ```tsx
860
+ import { OptionsLayout } from "fansunited-frontend-core";
861
+
862
+ // Two-by-two grid layout
863
+ const twoByTwoLayout: PersonalityQuizPlayProps = {
864
+ optionsLayout: "twoByTwo",
865
+ // ... other props
866
+ };
867
+
868
+ // Horizontal row layout
869
+ const rowLayout: PersonalityQuizPlayProps = {
870
+ optionsLayout: "row",
871
+ // ... other props
872
+ };
873
+
874
+ // Vertical column layout
875
+ const columnLayout: PersonalityQuizPlayProps = {
876
+ optionsLayout: "column",
877
+ // ... other props
878
+ };
879
+ ```
880
+
881
+ #### Sign in Configuration
882
+
883
+ Control user authentication and quiz access using the `userIsLoggedIn` and `signInCTA` props.
884
+
885
+ ```tsx
886
+ import { SignInCTADetails } from "fansunited-frontend-core";
887
+
888
+ // Custom sign-in component
889
+ const signInCTA: SignInCTADetails = {
890
+ component: <CustomSignInButton />
891
+ };
892
+
893
+ // Basic sign-in with onClick handler
894
+ const signInCTA: SignInCTADetails = {
895
+ defaultLabel: "Sign in to take quiz",
896
+ onClick: () => {
897
+ // Handle sign-in logic
898
+ console.log("Sign in clicked");
899
+ }
900
+ };
901
+
902
+ // Sign-in with URL navigation
903
+ const signInCTA: SignInCTADetails = {
904
+ defaultLabel: "Login to discover your personality",
905
+ url: "https://your-auth-provider.com/login",
906
+ target: "_blank"
907
+ };
908
+
909
+ <PersonalityQuizPlay
910
+ {...otherProps}
911
+ userIsLoggedIn={false}
912
+ signInCTA={signInCTA}
913
+ />
914
+ ```
915
+
916
+ **Sign-in Priority Order:**
917
+
918
+ 1. **Custom Component** - If `signInCTA.component` is provided, it will be rendered
919
+ 2. **Click Handler** - If `signInCTA.onClick` is provided, a button with the handler will be rendered
920
+ 3. **URL Navigation** - If `signInCTA.url` is provided, a button will be rendered and clicking will navigate to the URL
921
+ 4. **Disabled** - If no `signInCTA` is provided, a disabled button will be shown
922
+
923
+ **Behavior:**
924
+
925
+ - When `userIsLoggedIn` is `false` and the quiz requires authentication (`authRequirement: "REGISTERED"`), the sign-in screen will be displayed instead of the quiz
926
+
927
+ #### Lead Collection
928
+
929
+ Capture user information before or after taking the personality quiz:
930
+
931
+ ```tsx
932
+ import { LeadsOptions } from "fansunited-frontend-core";
933
+
934
+ const leads: LeadsOptions = {
935
+ position: "before", // "before" | "after"
936
+ fields: ["fullName", "email"], // Available: "fullName" | "firstName" | "lastName" | "email" | "gender" | "country" | "phoneCountryCode" | "phoneNumber"
937
+ campaignId: "personality-quiz-2024",
938
+ campaignName: "Personality Assessment Campaign",
939
+ phoneCountryCode: "1", // Default country code for phone fields
940
+ };
941
+
942
+ <PersonalityQuizPlay {...otherProps} leads={leads} />
943
+ ```
944
+
945
+ #### Answer Explanations
946
+
947
+ Enable detailed explanations for quiz answers and persona matching:
948
+
949
+ ```tsx
950
+ <PersonalityQuizPlay
951
+ {...otherProps}
952
+ showAnswerExplanations={true}
953
+ />
954
+ ```
955
+
956
+ When enabled, users will see:
957
+ - Explanations for each answer choice
958
+ - Detailed persona descriptions
959
+ - Matching algorithm insights
960
+ - Percentage breakdowns for each persona
961
+
962
+ #### Examples
963
+
964
+ ##### Basic Personality Quiz
965
+
966
+ ```tsx
967
+ import { PersonalityQuizPlay } from "fansunited-frontend-components";
968
+ import { WidgetTemplate } from "fansunited-frontend-core";
969
+
970
+ <PersonalityQuizPlay
971
+ entityId="personality-quiz-123"
972
+ sdk={sdkInstance}
973
+ template={WidgetTemplate.STANDARD}
974
+ language="en"
975
+ />
976
+ ```
977
+
978
+ ##### Advanced Personality Quiz
979
+
980
+ ```tsx
981
+ <PersonalityQuizPlay
982
+ entityId="personality-quiz-123"
983
+ sdk={sdkInstance}
984
+ template={WidgetTemplate.OVERLAY}
985
+ language="en"
986
+ showAnswerExplanations={true}
987
+ optionsLayout="twoByTwo"
988
+ userIsLoggedIn={false}
989
+ signInCTA={{
990
+ defaultLabel: "Sign in to save results",
991
+ onClick: () => handleSignIn(),
992
+ }}
993
+ leads={{
994
+ position: "after",
995
+ fields: ["fullName", "email"],
996
+ campaignId: "personality-campaign",
997
+ campaignName: "Personality Assessment 2024",
998
+ phoneCountryCode: "44",
999
+ }}
1000
+ themeOptions={{
1001
+ mode: "dark",
1002
+ colorSchemes: {
1003
+ dark: {
1004
+ textPrimary: "#ffffff",
1005
+ surface: "#1a1a1a"
1006
+ }
1007
+ }
1008
+ }}
1009
+ />
1010
+ ```
1011
+
1012
+ ##### Customized Layout
1013
+
1014
+ ```tsx
1015
+ <PersonalityQuizPlay
1016
+ entityId="personality-quiz-123"
1017
+ sdk={sdkInstance}
1018
+ template={WidgetTemplate.STANDARD}
1019
+ imagePosition="right"
1020
+ language="en"
1021
+ optionsLayout="column"
1022
+ showAnswerExplanations={true}
1023
+ themeOptions={{
1024
+ mode: "light",
1025
+ customFontFamily: {
1026
+ light: {
1027
+ primary: "Inter, sans-serif",
1028
+ secondary: "Roboto, sans-serif"
1029
+ }
1030
+ }
1031
+ }}
1032
+ />
1033
+ ```
1034
+
1035
+ ## Available Components
1036
+
1037
+ This package exports the following components:
1038
+
1039
+ - **`ClassicQuizPlay`** - Traditional quiz with scoring and explanations
1040
+ - **`PollVote`** - Interactive polling with real-time results
1041
+ - **`CollectLead`** - Lead collection forms with custom fields
1042
+ - **`PersonalityQuizPlay`** - Personality assessment with persona matching
1043
+
1044
+ ## Related Packages
552
1045
 
553
1046
  - [`fansunited-frontend-core`](https://www.npmjs.com/package/fansunited-frontend-core) - Core types and utilities
package/components.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { ClassicQuizPlayProps, PollVoteProps, CollectLeadProps } from 'fansunited-frontend-core';
1
+ import { ClassicQuizPlayProps, PollVoteProps, CollectLeadProps, PersonalityQuizPlayProps } from 'fansunited-frontend-core';
2
2
 
3
3
  export declare const ClassicQuizPlay: React.FC<ClassicQuizPlayProps>;
4
4
  export declare const PollVote: React.FC<PollVoteProps>;
5
5
  export declare const CollectLead: React.FC<CollectLeadProps>;
6
+ export declare const PersonalityQuizPlay: React.FC<PersonalityQuizPlayProps>;
6
7
  //# sourceMappingURL=components.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CACjC,CAAC;AAE3B,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAqB,CAAC;AAEnE,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAwB,CAAC"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AAIA,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CACjC,CAAC;AAE3B,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAAqB,CAAC;AAEnE,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAwB,CAAC;AAE5E,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CACrC,CAAC"}