kundli-generator 1.0.3 → 1.0.4

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.
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Event names matching Kundli Generator Events taxonomy (Mixpanel).
3
+ * Host app (e.g. hanuman) should use these when calling logEvent.
4
+ */
5
+ export declare const KUNDLI_ANALYTICS_EVENT_NAMES: {
6
+ readonly banner_clicked_fe: "banner_clicked_fe";
7
+ readonly primary_cta_clicked_fe: "primary_cta_clicked_fe";
8
+ readonly language_changed_fe: "language_changed_fe";
9
+ readonly language_clicked_fe: "language_clicked_fe";
10
+ readonly retry_payment: "retry_payment";
11
+ readonly detailed_kundli_report_impression_fe: "detailed_kundli_report_impression_fe";
12
+ readonly payment_partner_page_opened: "payment_partner_page_opened";
13
+ readonly view_sample_report_clicked: "view_sample_report_clicked";
14
+ readonly view_sample_report_closed: "view_sample_report_closed";
15
+ readonly l1_page_opened: "l1_page_opened";
16
+ readonly info_icon_clicked: "info_icon_clicked";
17
+ readonly name_section_clicked: "name_section_clicked";
18
+ readonly name_section_filled: "name_section_filled";
19
+ readonly phone_section_clicked: "phone_section_clicked";
20
+ readonly phone_section_filled: "phone_section_filled";
21
+ readonly email_section_clicked: "email_section_clicked";
22
+ readonly email_section_filled: "email_section_filled";
23
+ readonly dob_clicked: "dob_clicked";
24
+ readonly dob_filled: "dob_filled";
25
+ readonly time_clicked: "time_clicked";
26
+ readonly time_filled: "time_filled";
27
+ readonly time_checkbox_clicked: "time_checkbox_clicked";
28
+ readonly place_of_birth_clicked: "place_of_birth_clicked";
29
+ readonly place_of_birth_chosen: "place_of_birth_chosen";
30
+ readonly language_of_report_clicked: "language_of_report_clicked";
31
+ readonly primary_cta_clicked_l1: "primary_cta_clicked_l1";
32
+ /** Legacy / alias: when landing page is viewed */
33
+ readonly kundli_page_view: "kundli_page_view";
34
+ /** Legacy / alias: when L1 form page is viewed (same as l1_page_opened) */
35
+ readonly kundli_form_view: "kundli_form_view";
36
+ };
37
+ export type KundliAnalyticsEventName = (typeof KUNDLI_ANALYTICS_EVENT_NAMES)[keyof typeof KUNDLI_ANALYTICS_EVENT_NAMES];
38
+ /** Optional analytics implementation. Pass from host to KundliPage/KundliForm to track events. */
39
+ export interface KundliAnalytics {
40
+ trackBannerClicked?(): void;
41
+ trackPrimaryCtaClickedFe?(params: {
42
+ ctaText?: string;
43
+ }): void;
44
+ trackLanguageChangedFe?(params: {
45
+ newLanguage: string;
46
+ }): void;
47
+ trackLanguageClickedFe?(params: {
48
+ language: string;
49
+ }): void;
50
+ trackDetailedKundliReportImpressionFe?(params: {
51
+ section: string;
52
+ timestamp?: string;
53
+ }): void;
54
+ trackViewSampleReportClicked?(): void;
55
+ trackViewSampleReportClosed?(): void;
56
+ trackL1PageOpened?(): void;
57
+ trackInfoIconClicked?(params: {
58
+ fieldName: string;
59
+ }): void;
60
+ trackNameSectionClicked?(): void;
61
+ trackNameSectionFilled?(): void;
62
+ trackPhoneSectionClicked?(): void;
63
+ trackPhoneSectionFilled?(): void;
64
+ trackEmailSectionClicked?(): void;
65
+ trackEmailSectionFilled?(): void;
66
+ trackDobClicked?(): void;
67
+ trackDobFilled?(): void;
68
+ trackTimeClicked?(): void;
69
+ trackTimeFilled?(): void;
70
+ trackTimeCheckboxClicked?(): void;
71
+ trackPlaceOfBirthClicked?(): void;
72
+ trackPlaceOfBirthChosen?(): void;
73
+ trackLanguageOfReportClicked?(): void;
74
+ trackPrimaryCtaClickedL1?(params: {
75
+ avenue?: string;
76
+ }): void;
77
+ trackKundliPageView?(): void;
78
+ trackKundliFormView?(): void;
79
+ }
@@ -1,5 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { SupportedLocale } from '../../i18n/translations';
3
+ import { KundliAnalytics } from '../../analytics';
3
4
  export interface KundliFormValues {
4
5
  fullName: string;
5
6
  phone?: string;
@@ -11,17 +12,15 @@ export interface KundliFormValues {
11
12
  }
12
13
  export interface KundliFormProps {
13
14
  className?: string;
14
- /** Language (en, hi, ta, te). Overrides I18nProvider if set. */
15
+ /** Language (en, hi, ta, te). Overrides I18nProvider if set. Initial value when using dropdown. */
15
16
  locale?: SupportedLocale;
16
17
  /** Show language dropdown. Default true. */
17
18
  showLanguageSelector?: boolean;
18
- /** Header logo URL */
19
- logoUrl?: string;
20
- /** Back button handler (e.g. go back to KundliPage) */
19
+ /** Back button handler in header */
21
20
  onBack?: () => void;
22
21
  /** Initial field values */
23
22
  initialValues?: Partial<KundliFormValues>;
24
- /** Called when user clicks Proceed; receives form data. Use for payment/navigation in consumer. */
23
+ /** Called when user clicks Proceed to payment */
25
24
  onProceed?: (values: KundliFormValues) => void;
26
25
  /** If provided, proceed CTA becomes a link */
27
26
  proceedHref?: string;
@@ -29,6 +28,7 @@ export interface KundliFormProps {
29
28
  originalPriceLabel?: string;
30
29
  discountedPriceLabel?: string;
31
30
  discountPillLabel?: string;
31
+ /** Optional analytics for tracking form events */
32
+ analytics?: KundliAnalytics;
32
33
  }
33
- /** Standalone Kundli form. Use with onProceed callback to get form data; no context required. */
34
34
  export declare const KundliForm: React.FC<KundliFormProps>;
@@ -1,10 +1,12 @@
1
1
  import { default as React } from 'react';
2
2
  import { KundliFormValues } from '../../KundliForm';
3
+ import { KundliAnalytics } from '../../../../../analytics';
3
4
  export interface ProceedFooterProps {
4
5
  t: (key: string) => string;
5
6
  values: KundliFormValues;
6
7
  onProceed?: (values: KundliFormValues) => void;
7
8
  href?: string;
9
+ analytics?: KundliAnalytics;
8
10
  className?: string;
9
11
  originalPriceLabel?: string;
10
12
  discountedPriceLabel?: string;
@@ -1,9 +1,11 @@
1
1
  import { default as React } from 'react';
2
2
  import { KundliFormValues } from '../../KundliForm';
3
+ import { KundliAnalytics } from '../../../../../analytics';
3
4
  export interface UserInfoFormSectionProps {
4
5
  t: (key: string) => string;
5
6
  values: KundliFormValues;
6
7
  onChange: (values: KundliFormValues) => void;
8
+ analytics?: KundliAnalytics;
7
9
  className?: string;
8
10
  }
9
11
  export declare const UserInfoFormSection: React.FC<UserInfoFormSectionProps>;
@@ -0,0 +1,44 @@
1
+ import { default as React } from 'react';
2
+ import { SupportedLocale } from '../../i18n/translations';
3
+ import { KundliFormValues } from '../KundliForm';
4
+ import { KundliAnalytics } from '../../analytics';
5
+ export type KundliView = "landing" | "form";
6
+ export interface KundliContextConfig {
7
+ locale?: SupportedLocale;
8
+ showLanguageSelector?: boolean;
9
+ userId?: number;
10
+ logoUrl?: string;
11
+ reportImageUrl?: string;
12
+ universityLogoUrls?: [string?, string?];
13
+ sampleReportHref?: string;
14
+ onViewSampleReport?: () => void;
15
+ ctaHref?: string;
16
+ onCtaClick?: () => void;
17
+ readMoreReviewsHref?: string;
18
+ onProceed?: (values: KundliFormValues) => void;
19
+ proceedHref?: string;
20
+ originalPriceLabel?: string;
21
+ discountedPriceLabel?: string;
22
+ discountPillLabel?: string;
23
+ analytics?: KundliAnalytics;
24
+ }
25
+ export interface KundliContextValue {
26
+ view: KundliView;
27
+ locale: SupportedLocale;
28
+ setLocale: (locale: SupportedLocale) => void;
29
+ config: KundliContextConfig;
30
+ formValues: KundliFormValues;
31
+ setFormValues: React.Dispatch<React.SetStateAction<KundliFormValues>>;
32
+ goToForm: () => void;
33
+ goToPage: () => void;
34
+ onProceed?: (values: KundliFormValues) => void;
35
+ }
36
+ declare const KundliContext: React.Context<KundliContextValue | null>;
37
+ export interface KundliProviderProps extends KundliContextConfig {
38
+ className?: string;
39
+ children?: React.ReactNode;
40
+ }
41
+ export declare const KundliProvider: React.FC<KundliProviderProps>;
42
+ export declare function useKundliContext(): KundliContextValue | null;
43
+ export declare function useKundliContextOrThrow(): KundliContextValue;
44
+ export { KundliContext };
@@ -1,5 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { SupportedLocale } from '../../i18n/translations';
3
+ import { KundliFormValues } from '../KundliForm';
4
+ import { KundliAnalytics } from '../../analytics';
3
5
  export interface KundliPageProps {
4
6
  /** Optional CSS class name */
5
7
  className?: string;
@@ -11,8 +13,6 @@ export interface KundliPageProps {
11
13
  userId?: number;
12
14
  /** Header logo URL */
13
15
  logoUrl?: string;
14
- /** A4B API instance (for consumer use; e.g. pass to form submit in Hanuman) */
15
- a4bApi?: A4BApi;
16
16
  /** Premium report cover image URL */
17
17
  reportImageUrl?: string;
18
18
  /** University logo URLs [BHU, VSU] */
@@ -21,12 +21,21 @@ export interface KundliPageProps {
21
21
  sampleReportHref?: string;
22
22
  /** Called when "View Sample Report" is clicked (if sampleReportHref not set) */
23
23
  onViewSampleReport?: () => void;
24
- /** CTA button link (e.g. checkout URL). If set, CTA is a link; otherwise CTA triggers onCtaClick. */
24
+ /** CTA button link (e.g. checkout URL). If set, CTA is a link; otherwise CTA shows the Kundli form. */
25
25
  ctaHref?: string;
26
- /** Called when CTA button is clicked (when ctaHref is not set). Consumer can show KundliForm. */
26
+ /** Called when CTA button is clicked (if ctaHref not set). Also called after navigating to form when integrated. */
27
27
  onCtaClick?: () => void;
28
28
  /** Read more reviews link */
29
29
  readMoreReviewsHref?: string;
30
+ /** Called when user proceeds from the form (e.g. to payment) */
31
+ onProceed?: (values: KundliFormValues) => void;
32
+ /** Form: proceed CTA as link */
33
+ proceedHref?: string;
34
+ /** Form: pricing labels */
35
+ originalPriceLabel?: string;
36
+ discountedPriceLabel?: string;
37
+ discountPillLabel?: string;
38
+ /** Optional analytics implementation for Mixpanel/tracking events */
39
+ analytics?: KundliAnalytics;
30
40
  }
31
- /** Landing page content (hero, steps, CTA). Decoupled from form; use onCtaClick to show KundliForm in consumer. */
32
41
  export declare const KundliPage: React.FC<KundliPageProps>;
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { KundliAnalytics } from '../../../../../analytics';
2
3
  export interface ViewSampleReportButtonProps {
3
4
  t: (key: string) => string;
4
5
  /** PDF URL to display in modal. Defaults to a sample PDF. */
@@ -7,6 +8,8 @@ export interface ViewSampleReportButtonProps {
7
8
  href?: string;
8
9
  /** Called when button is clicked (e.g. for analytics). Modal opens regardless. */
9
10
  onClick?: () => void;
11
+ /** Optional analytics for tracking view sample clicked/closed */
12
+ analytics?: KundliAnalytics;
10
13
  className?: string;
11
14
  }
12
15
  export declare const ViewSampleReportButton: React.FC<ViewSampleReportButtonProps>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { KundliPage } from './components/KundliPage';
2
- export type { KundliPageProps } from './components/KundliPage';
2
+ export { KundliProvider, useKundliContext, useKundliContextOrThrow, KundliContext, } from './components/KundliPage/KundliContext';
3
+ export type { KundliView, KundliContextConfig, KundliContextValue, KundliProviderProps, } from './components/KundliPage/KundliContext';
4
+ export { KUNDLI_ANALYTICS_EVENT_NAMES, type KundliAnalytics, type KundliAnalyticsEventName, } from './analytics';
3
5
  export { KundliForm } from './components/KundliForm';
4
- export type { KundliFormValues, KundliFormProps } from './components/KundliForm';
6
+ export type { KundliFormValues } from './components/KundliForm';
5
7
  export { I18nProvider, useI18n, SUPPORTED_LOCALES, type SupportedLocale, } from './i18n';