@gamifyio/react 0.1.3 → 0.1.5
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -122
- package/dist/index.d.ts +67 -122
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import { GamifyConfig, Gamify, SessionResponse, CartItem, LoyaltyProfile, LoyaltyHistoryResponse, AffiliateStats as AffiliateStats$1, LeaderboardResponse, QuestWithProgress, StreakWithProgress, StreaksResponse, FreezeResponse, BadgeWithStatus, BadgesResponse, RewardItem, RedemptionResult, LeaderboardEntry } from '@gamifyio/core';
|
|
4
|
-
export { AffiliateEarnings, AffiliateStats as AffiliateStatsData, AffiliateTier, AppliedEffect, BadgeRarity, BadgeWithStatus, BadgesResponse, CartItem, FreezeResponse, GamifyConfig, GamifyEvent, LeaderboardEntry, LeaderboardResponse, LoyaltyHistoryResponse, LoyaltyProfile, LoyaltyTier, LoyaltyTransaction, QuestStep, QuestWithProgress, QuestsResponse, RedemptionResult, RewardItem, RewardsStoreResponse, SessionResponse, StreakMilestone, StreakWithProgress, StreaksResponse, UserTraits } from '@gamifyio/core';
|
|
3
|
+
import { GamifyConfig, Theme, Gamify, SessionResponse, CartItem, LoyaltyProfile, LoyaltyHistoryResponse, AffiliateStats as AffiliateStats$1, LeaderboardResponse, QuestWithProgress, StreakWithProgress, StreaksResponse, FreezeResponse, BadgeWithStatus, BadgesResponse, RewardItem, RedemptionResult, LeaderboardEntry } from '@gamifyio/core';
|
|
4
|
+
export { AffiliateEarnings, AffiliateStats as AffiliateStatsData, AffiliateTier, AppliedEffect, BadgeRarity, BadgeWithStatus, BadgesResponse, CartItem, FreezeResponse, GamifyConfig, GamifyEvent, LeaderboardEntry, LeaderboardResponse, LoyaltyHistoryResponse, LoyaltyProfile, LoyaltyTier, LoyaltyTransaction, QuestStep, QuestWithProgress, QuestsResponse, RedemptionResult, RewardItem, RewardsStoreResponse, SessionResponse, StreakMilestone, StreakWithProgress, StreaksResponse, Theme, UserTraits, defaultTheme } from '@gamifyio/core';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Context value for Gamify React SDK
|
|
@@ -26,6 +26,8 @@ interface GamifyContextValue {
|
|
|
26
26
|
interface GamifyProviderProps {
|
|
27
27
|
/** Gamify SDK configuration */
|
|
28
28
|
config: GamifyConfig;
|
|
29
|
+
/** Optional theme override (Partial<Theme>) */
|
|
30
|
+
theme?: Partial<Theme>;
|
|
29
31
|
/** Child components */
|
|
30
32
|
children: ReactNode;
|
|
31
33
|
}
|
|
@@ -37,9 +39,29 @@ interface GamifyProviderProps {
|
|
|
37
39
|
* <GamifyProvider config={{ apiKey: 'your-api-key' }}>
|
|
38
40
|
* <App />
|
|
39
41
|
* </GamifyProvider>
|
|
42
|
+
*
|
|
43
|
+
* // With custom theme
|
|
44
|
+
* <GamifyProvider
|
|
45
|
+
* config={{ apiKey: 'your-api-key' }}
|
|
46
|
+
* theme={{ primary: '#00FF00' }}
|
|
47
|
+
* >
|
|
48
|
+
* <App />
|
|
49
|
+
* </GamifyProvider>
|
|
40
50
|
* ```
|
|
41
51
|
*/
|
|
42
|
-
declare function GamifyProvider({ config, children }: GamifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
52
|
+
declare function GamifyProvider({ config, theme, children }: GamifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* useGamifyTheme - Hook to access the current theme
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* function MyComponent() {
|
|
59
|
+
* const theme = useGamifyTheme();
|
|
60
|
+
* return <div style={{ color: theme.foreground }}>Themed content</div>;
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function useGamifyTheme(): Theme;
|
|
43
65
|
|
|
44
66
|
/**
|
|
45
67
|
* useGamify - Hook to access Gamify SDK methods
|
|
@@ -569,28 +591,18 @@ interface AffiliateStatsProps {
|
|
|
569
591
|
};
|
|
570
592
|
/** Auto-refresh stats on mount */
|
|
571
593
|
autoRefresh?: boolean;
|
|
594
|
+
/** Show tier badge with commission rate (default: true) */
|
|
595
|
+
showTierBadge?: boolean;
|
|
596
|
+
/** Show referral code with copy button (default: true) */
|
|
597
|
+
showReferralCode?: boolean;
|
|
598
|
+
/** Show earnings breakdown section (default: true) */
|
|
599
|
+
showEarningsBreakdown?: boolean;
|
|
572
600
|
/** Custom render for loading state */
|
|
573
601
|
renderLoading?: () => React.ReactNode;
|
|
574
602
|
/** Custom render for error state */
|
|
575
603
|
renderError?: (error: string) => React.ReactNode;
|
|
576
604
|
}
|
|
577
|
-
|
|
578
|
-
* AffiliateStats - Display grid with affiliate statistics
|
|
579
|
-
*
|
|
580
|
-
* Shows referral count, clicks, and earnings in a card layout.
|
|
581
|
-
* Headless-first: unstyled by default but includes sensible defaults.
|
|
582
|
-
*
|
|
583
|
-
* @example
|
|
584
|
-
* ```tsx
|
|
585
|
-
* <AffiliateStats autoRefresh />
|
|
586
|
-
*
|
|
587
|
-
* // With custom theme
|
|
588
|
-
* <AffiliateStats
|
|
589
|
-
* theme={{ cardBackground: '#1a1a1a', valueColor: '#fff' }}
|
|
590
|
-
* />
|
|
591
|
-
* ```
|
|
592
|
-
*/
|
|
593
|
-
declare function AffiliateStats({ className, style, theme, autoRefresh, renderLoading, renderError, }: AffiliateStatsProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
605
|
+
declare const AffiliateStats: React.FC<AffiliateStatsProps>;
|
|
594
606
|
/**
|
|
595
607
|
* Props for Leaderboard component
|
|
596
608
|
*/
|
|
@@ -605,6 +617,12 @@ interface LeaderboardProps {
|
|
|
605
617
|
currentUserId?: string;
|
|
606
618
|
/** Custom empty state message */
|
|
607
619
|
emptyMessage?: string;
|
|
620
|
+
/** Show medal icons for top 3 positions (default: true) */
|
|
621
|
+
showMedals?: boolean;
|
|
622
|
+
/** Show tier info with percentage (default: true) */
|
|
623
|
+
showTierInfo?: boolean;
|
|
624
|
+
/** Show earnings column (default: true) */
|
|
625
|
+
showEarnings?: boolean;
|
|
608
626
|
/** Theme customization */
|
|
609
627
|
theme?: {
|
|
610
628
|
rowBackground?: string;
|
|
@@ -619,27 +637,7 @@ interface LeaderboardProps {
|
|
|
619
637
|
/** Custom render for error state */
|
|
620
638
|
renderError?: (error: string) => React.ReactNode;
|
|
621
639
|
}
|
|
622
|
-
|
|
623
|
-
* Leaderboard - Ranked affiliate leaderboard display
|
|
624
|
-
*
|
|
625
|
-
* Shows ranked list of top affiliates with referral counts.
|
|
626
|
-
* Highlights the current user if their ID is provided.
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* ```tsx
|
|
630
|
-
* <Leaderboard limit={10} currentUserId={userId} />
|
|
631
|
-
*
|
|
632
|
-
* // With custom render
|
|
633
|
-
* <Leaderboard
|
|
634
|
-
* renderRow={(entry, isCurrent) => (
|
|
635
|
-
* <div className={isCurrent ? 'highlight' : ''}>
|
|
636
|
-
* #{entry.rank} - {entry.displayName}
|
|
637
|
-
* </div>
|
|
638
|
-
* )}
|
|
639
|
-
* />
|
|
640
|
-
* ```
|
|
641
|
-
*/
|
|
642
|
-
declare function Leaderboard({ limit, className, style, currentUserId, emptyMessage, theme, renderRow, renderLoading, renderError, }: LeaderboardProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
640
|
+
declare const Leaderboard: React.FC<LeaderboardProps>;
|
|
643
641
|
/**
|
|
644
642
|
* Props for ReferralLink component
|
|
645
643
|
*/
|
|
@@ -662,6 +660,16 @@ interface ReferralLinkProps {
|
|
|
662
660
|
shareText?: string;
|
|
663
661
|
/** Show share button on mobile */
|
|
664
662
|
showShareButton?: boolean;
|
|
663
|
+
/** Show referrer attribution section (default: true) */
|
|
664
|
+
showReferrerAttribution?: boolean;
|
|
665
|
+
/** Current referrer code (who referred this user) */
|
|
666
|
+
referrerCode?: string | null;
|
|
667
|
+
/** Callback when referrer is set */
|
|
668
|
+
onSetReferrer?: (code: string) => void;
|
|
669
|
+
/** Callback to detect referrer from URL */
|
|
670
|
+
onDetectFromUrl?: () => void;
|
|
671
|
+
/** Callback when referrer is cleared */
|
|
672
|
+
onClearReferrer?: () => void;
|
|
665
673
|
/** Theme customization */
|
|
666
674
|
theme?: {
|
|
667
675
|
inputBackground?: string;
|
|
@@ -675,25 +683,7 @@ interface ReferralLinkProps {
|
|
|
675
683
|
/** Callback when link is shared */
|
|
676
684
|
onShare?: (link: string) => void;
|
|
677
685
|
}
|
|
678
|
-
|
|
679
|
-
* ReferralLink - Input field with user's referral code and copy/share buttons
|
|
680
|
-
*
|
|
681
|
-
* Displays the user's unique referral link with easy copy functionality.
|
|
682
|
-
* Includes native share button for mobile devices.
|
|
683
|
-
*
|
|
684
|
-
* @example
|
|
685
|
-
* ```tsx
|
|
686
|
-
* <ReferralLink />
|
|
687
|
-
*
|
|
688
|
-
* // With custom base URL
|
|
689
|
-
* <ReferralLink
|
|
690
|
-
* baseUrl="https://myapp.com/signup"
|
|
691
|
-
* shareTitle="Join my app!"
|
|
692
|
-
* shareText="Sign up using my referral link"
|
|
693
|
-
* />
|
|
694
|
-
* ```
|
|
695
|
-
*/
|
|
696
|
-
declare function ReferralLink({ baseUrl, className, style, copyButtonText, copiedText, shareButtonText, shareTitle, shareText, showShareButton, theme, onCopy, onShare, }: ReferralLinkProps): react_jsx_runtime.JSX.Element | null;
|
|
686
|
+
declare const ReferralLink: React.FC<ReferralLinkProps>;
|
|
697
687
|
/**
|
|
698
688
|
* Props for QuestProgress component
|
|
699
689
|
*/
|
|
@@ -706,6 +696,12 @@ interface QuestProgressProps {
|
|
|
706
696
|
className?: string;
|
|
707
697
|
/** Custom styles override */
|
|
708
698
|
style?: React.CSSProperties;
|
|
699
|
+
/** Enable expandable accordion mode (default: true) */
|
|
700
|
+
expandable?: boolean;
|
|
701
|
+
/** Default expanded quest ID (defaults to first in-progress) */
|
|
702
|
+
defaultExpandedId?: string;
|
|
703
|
+
/** Show XP reward in header (default: true) */
|
|
704
|
+
showXpReward?: boolean;
|
|
709
705
|
/** Callback when a quest is completed */
|
|
710
706
|
onComplete?: (quest: QuestWithProgress) => void;
|
|
711
707
|
/** Theme customization */
|
|
@@ -722,17 +718,7 @@ interface QuestProgressProps {
|
|
|
722
718
|
/** Custom render for each quest */
|
|
723
719
|
renderQuest?: (quest: QuestWithProgress) => React.ReactNode;
|
|
724
720
|
}
|
|
725
|
-
|
|
726
|
-
* QuestProgress - Display quest progress with step checklist
|
|
727
|
-
*
|
|
728
|
-
* Shows quest name, description, progress bar, and step completion status.
|
|
729
|
-
*
|
|
730
|
-
* @example
|
|
731
|
-
* ```tsx
|
|
732
|
-
* <QuestProgress hideCompleted onComplete={(quest) => console.log('Completed:', quest.name)} />
|
|
733
|
-
* ```
|
|
734
|
-
*/
|
|
735
|
-
declare function QuestProgress({ questId, hideCompleted, className, style, onComplete, theme, renderLoading, renderError, renderQuest, }: QuestProgressProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
721
|
+
declare const QuestProgress: React.FC<QuestProgressProps>;
|
|
736
722
|
/**
|
|
737
723
|
* Props for StreakFlame component
|
|
738
724
|
*/
|
|
@@ -760,17 +746,7 @@ interface StreakFlameProps {
|
|
|
760
746
|
/** Custom render for error state */
|
|
761
747
|
renderError?: (error: string) => React.ReactNode;
|
|
762
748
|
}
|
|
763
|
-
|
|
764
|
-
* StreakFlame - Display streak counter with flame icon
|
|
765
|
-
*
|
|
766
|
-
* Shows current streak count with status indicator and optional freeze button.
|
|
767
|
-
*
|
|
768
|
-
* @example
|
|
769
|
-
* ```tsx
|
|
770
|
-
* <StreakFlame showFreezeButton onFreeze={(id, remaining) => console.log('Freeze used')} />
|
|
771
|
-
* ```
|
|
772
|
-
*/
|
|
773
|
-
declare function StreakFlame({ ruleId, size, showFreezeButton, className, style, onFreeze, theme, renderLoading, renderError, }: StreakFlameProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
749
|
+
declare const StreakFlame: React.FC<StreakFlameProps>;
|
|
774
750
|
/**
|
|
775
751
|
* Props for BadgeGrid component
|
|
776
752
|
*/
|
|
@@ -785,7 +761,11 @@ interface BadgeGridProps {
|
|
|
785
761
|
className?: string;
|
|
786
762
|
/** Custom styles override */
|
|
787
763
|
style?: React.CSSProperties;
|
|
788
|
-
/** Show
|
|
764
|
+
/** Show progress summary header (default: true) */
|
|
765
|
+
showProgressSummary?: boolean;
|
|
766
|
+
/** Show filter tabs (All/Earned/Locked) (default: true) */
|
|
767
|
+
showFilterTabs?: boolean;
|
|
768
|
+
/** @deprecated Use showProgressSummary instead */
|
|
789
769
|
showStats?: boolean;
|
|
790
770
|
/** Callback when a badge is clicked */
|
|
791
771
|
onBadgeClick?: (badge: BadgeWithStatus) => void;
|
|
@@ -801,17 +781,7 @@ interface BadgeGridProps {
|
|
|
801
781
|
/** Custom render for each badge */
|
|
802
782
|
renderBadge?: (badge: BadgeWithStatus) => React.ReactNode;
|
|
803
783
|
}
|
|
804
|
-
|
|
805
|
-
* BadgeGrid - Display badge collection in a grid
|
|
806
|
-
*
|
|
807
|
-
* Shows badges with unlock status, rarity indicators, and optional filtering.
|
|
808
|
-
*
|
|
809
|
-
* @example
|
|
810
|
-
* ```tsx
|
|
811
|
-
* <BadgeGrid showLocked showStats onBadgeClick={(badge) => showBadgeModal(badge)} />
|
|
812
|
-
* ```
|
|
813
|
-
*/
|
|
814
|
-
declare function BadgeGrid({ showLocked, category, columns, className, style, showStats, onBadgeClick, theme, renderLoading, renderError, renderBadge, }: BadgeGridProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
784
|
+
declare const BadgeGrid: React.FC<BadgeGridProps>;
|
|
815
785
|
/**
|
|
816
786
|
* Props for LevelProgress component
|
|
817
787
|
*/
|
|
@@ -835,17 +805,7 @@ interface LevelProgressProps {
|
|
|
835
805
|
/** Custom render for error state */
|
|
836
806
|
renderError?: (error: string) => React.ReactNode;
|
|
837
807
|
}
|
|
838
|
-
|
|
839
|
-
* LevelProgress - Display tier/level progress
|
|
840
|
-
*
|
|
841
|
-
* Shows current tier, XP/points, and progress to next tier.
|
|
842
|
-
*
|
|
843
|
-
* @example
|
|
844
|
-
* ```tsx
|
|
845
|
-
* <LevelProgress showNextTier showBenefits />
|
|
846
|
-
* ```
|
|
847
|
-
*/
|
|
848
|
-
declare function LevelProgress({ showNextTier, showBenefits, className, style, theme, renderLoading, renderError, }: LevelProgressProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
808
|
+
declare const LevelProgress: React.FC<LevelProgressProps>;
|
|
849
809
|
/**
|
|
850
810
|
* Props for RewardStore component
|
|
851
811
|
*/
|
|
@@ -872,21 +832,6 @@ interface RewardStoreProps {
|
|
|
872
832
|
/** Custom render for each item */
|
|
873
833
|
renderItem?: (item: RewardItem, onRedeem: () => void) => React.ReactNode;
|
|
874
834
|
}
|
|
875
|
-
|
|
876
|
-
* RewardStore - Display reward catalog with redeem functionality
|
|
877
|
-
*
|
|
878
|
-
* Shows available rewards with point costs and redeem buttons.
|
|
879
|
-
*
|
|
880
|
-
* @example
|
|
881
|
-
* ```tsx
|
|
882
|
-
* <RewardStore
|
|
883
|
-
* showPointsHeader
|
|
884
|
-
* onRedeem={(item, result) => {
|
|
885
|
-
* if (result.success) toast.success(`Redeemed ${item.name}!`);
|
|
886
|
-
* }}
|
|
887
|
-
* />
|
|
888
|
-
* ```
|
|
889
|
-
*/
|
|
890
|
-
declare function RewardStore({ showUnavailable, className, style, showPointsHeader, onRedeem, theme, renderLoading, renderError, renderItem, }: RewardStoreProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
835
|
+
declare const RewardStore: React.FC<RewardStoreProps>;
|
|
891
836
|
|
|
892
|
-
export { AffiliateStats, type AffiliateStatsProps, BadgeGrid, type BadgeGridProps, type GamifyContextValue, GamifyPageView, type GamifyPageViewProps, GamifyProvider, type GamifyProviderProps, GamifyTrackClick, type GamifyTrackClickProps, Leaderboard, type LeaderboardProps, LevelProgress, type LevelProgressProps, QuestProgress, type QuestProgressProps, ReferralLink, type ReferralLinkProps, RewardStore, type RewardStoreProps, StreakFlame, type StreakFlameProps, useAffiliateStats, useBadges, useGamify, useIdentify, useLeaderboard, useLoyalty, useQuests, useReferral, useRewards, useSession, useStreaks, useTrack };
|
|
837
|
+
export { AffiliateStats, type AffiliateStatsProps, BadgeGrid, type BadgeGridProps, type GamifyContextValue, GamifyPageView, type GamifyPageViewProps, GamifyProvider, type GamifyProviderProps, GamifyTrackClick, type GamifyTrackClickProps, Leaderboard, type LeaderboardProps, LevelProgress, type LevelProgressProps, QuestProgress, type QuestProgressProps, ReferralLink, type ReferralLinkProps, RewardStore, type RewardStoreProps, StreakFlame, type StreakFlameProps, useAffiliateStats, useBadges, useGamify, useGamifyTheme, useIdentify, useLeaderboard, useLoyalty, useQuests, useReferral, useRewards, useSession, useStreaks, useTrack };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
-
import { GamifyConfig, Gamify, SessionResponse, CartItem, LoyaltyProfile, LoyaltyHistoryResponse, AffiliateStats as AffiliateStats$1, LeaderboardResponse, QuestWithProgress, StreakWithProgress, StreaksResponse, FreezeResponse, BadgeWithStatus, BadgesResponse, RewardItem, RedemptionResult, LeaderboardEntry } from '@gamifyio/core';
|
|
4
|
-
export { AffiliateEarnings, AffiliateStats as AffiliateStatsData, AffiliateTier, AppliedEffect, BadgeRarity, BadgeWithStatus, BadgesResponse, CartItem, FreezeResponse, GamifyConfig, GamifyEvent, LeaderboardEntry, LeaderboardResponse, LoyaltyHistoryResponse, LoyaltyProfile, LoyaltyTier, LoyaltyTransaction, QuestStep, QuestWithProgress, QuestsResponse, RedemptionResult, RewardItem, RewardsStoreResponse, SessionResponse, StreakMilestone, StreakWithProgress, StreaksResponse, UserTraits } from '@gamifyio/core';
|
|
3
|
+
import { GamifyConfig, Theme, Gamify, SessionResponse, CartItem, LoyaltyProfile, LoyaltyHistoryResponse, AffiliateStats as AffiliateStats$1, LeaderboardResponse, QuestWithProgress, StreakWithProgress, StreaksResponse, FreezeResponse, BadgeWithStatus, BadgesResponse, RewardItem, RedemptionResult, LeaderboardEntry } from '@gamifyio/core';
|
|
4
|
+
export { AffiliateEarnings, AffiliateStats as AffiliateStatsData, AffiliateTier, AppliedEffect, BadgeRarity, BadgeWithStatus, BadgesResponse, CartItem, FreezeResponse, GamifyConfig, GamifyEvent, LeaderboardEntry, LeaderboardResponse, LoyaltyHistoryResponse, LoyaltyProfile, LoyaltyTier, LoyaltyTransaction, QuestStep, QuestWithProgress, QuestsResponse, RedemptionResult, RewardItem, RewardsStoreResponse, SessionResponse, StreakMilestone, StreakWithProgress, StreaksResponse, Theme, UserTraits, defaultTheme } from '@gamifyio/core';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Context value for Gamify React SDK
|
|
@@ -26,6 +26,8 @@ interface GamifyContextValue {
|
|
|
26
26
|
interface GamifyProviderProps {
|
|
27
27
|
/** Gamify SDK configuration */
|
|
28
28
|
config: GamifyConfig;
|
|
29
|
+
/** Optional theme override (Partial<Theme>) */
|
|
30
|
+
theme?: Partial<Theme>;
|
|
29
31
|
/** Child components */
|
|
30
32
|
children: ReactNode;
|
|
31
33
|
}
|
|
@@ -37,9 +39,29 @@ interface GamifyProviderProps {
|
|
|
37
39
|
* <GamifyProvider config={{ apiKey: 'your-api-key' }}>
|
|
38
40
|
* <App />
|
|
39
41
|
* </GamifyProvider>
|
|
42
|
+
*
|
|
43
|
+
* // With custom theme
|
|
44
|
+
* <GamifyProvider
|
|
45
|
+
* config={{ apiKey: 'your-api-key' }}
|
|
46
|
+
* theme={{ primary: '#00FF00' }}
|
|
47
|
+
* >
|
|
48
|
+
* <App />
|
|
49
|
+
* </GamifyProvider>
|
|
40
50
|
* ```
|
|
41
51
|
*/
|
|
42
|
-
declare function GamifyProvider({ config, children }: GamifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
52
|
+
declare function GamifyProvider({ config, theme, children }: GamifyProviderProps): react_jsx_runtime.JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* useGamifyTheme - Hook to access the current theme
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* function MyComponent() {
|
|
59
|
+
* const theme = useGamifyTheme();
|
|
60
|
+
* return <div style={{ color: theme.foreground }}>Themed content</div>;
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare function useGamifyTheme(): Theme;
|
|
43
65
|
|
|
44
66
|
/**
|
|
45
67
|
* useGamify - Hook to access Gamify SDK methods
|
|
@@ -569,28 +591,18 @@ interface AffiliateStatsProps {
|
|
|
569
591
|
};
|
|
570
592
|
/** Auto-refresh stats on mount */
|
|
571
593
|
autoRefresh?: boolean;
|
|
594
|
+
/** Show tier badge with commission rate (default: true) */
|
|
595
|
+
showTierBadge?: boolean;
|
|
596
|
+
/** Show referral code with copy button (default: true) */
|
|
597
|
+
showReferralCode?: boolean;
|
|
598
|
+
/** Show earnings breakdown section (default: true) */
|
|
599
|
+
showEarningsBreakdown?: boolean;
|
|
572
600
|
/** Custom render for loading state */
|
|
573
601
|
renderLoading?: () => React.ReactNode;
|
|
574
602
|
/** Custom render for error state */
|
|
575
603
|
renderError?: (error: string) => React.ReactNode;
|
|
576
604
|
}
|
|
577
|
-
|
|
578
|
-
* AffiliateStats - Display grid with affiliate statistics
|
|
579
|
-
*
|
|
580
|
-
* Shows referral count, clicks, and earnings in a card layout.
|
|
581
|
-
* Headless-first: unstyled by default but includes sensible defaults.
|
|
582
|
-
*
|
|
583
|
-
* @example
|
|
584
|
-
* ```tsx
|
|
585
|
-
* <AffiliateStats autoRefresh />
|
|
586
|
-
*
|
|
587
|
-
* // With custom theme
|
|
588
|
-
* <AffiliateStats
|
|
589
|
-
* theme={{ cardBackground: '#1a1a1a', valueColor: '#fff' }}
|
|
590
|
-
* />
|
|
591
|
-
* ```
|
|
592
|
-
*/
|
|
593
|
-
declare function AffiliateStats({ className, style, theme, autoRefresh, renderLoading, renderError, }: AffiliateStatsProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
605
|
+
declare const AffiliateStats: React.FC<AffiliateStatsProps>;
|
|
594
606
|
/**
|
|
595
607
|
* Props for Leaderboard component
|
|
596
608
|
*/
|
|
@@ -605,6 +617,12 @@ interface LeaderboardProps {
|
|
|
605
617
|
currentUserId?: string;
|
|
606
618
|
/** Custom empty state message */
|
|
607
619
|
emptyMessage?: string;
|
|
620
|
+
/** Show medal icons for top 3 positions (default: true) */
|
|
621
|
+
showMedals?: boolean;
|
|
622
|
+
/** Show tier info with percentage (default: true) */
|
|
623
|
+
showTierInfo?: boolean;
|
|
624
|
+
/** Show earnings column (default: true) */
|
|
625
|
+
showEarnings?: boolean;
|
|
608
626
|
/** Theme customization */
|
|
609
627
|
theme?: {
|
|
610
628
|
rowBackground?: string;
|
|
@@ -619,27 +637,7 @@ interface LeaderboardProps {
|
|
|
619
637
|
/** Custom render for error state */
|
|
620
638
|
renderError?: (error: string) => React.ReactNode;
|
|
621
639
|
}
|
|
622
|
-
|
|
623
|
-
* Leaderboard - Ranked affiliate leaderboard display
|
|
624
|
-
*
|
|
625
|
-
* Shows ranked list of top affiliates with referral counts.
|
|
626
|
-
* Highlights the current user if their ID is provided.
|
|
627
|
-
*
|
|
628
|
-
* @example
|
|
629
|
-
* ```tsx
|
|
630
|
-
* <Leaderboard limit={10} currentUserId={userId} />
|
|
631
|
-
*
|
|
632
|
-
* // With custom render
|
|
633
|
-
* <Leaderboard
|
|
634
|
-
* renderRow={(entry, isCurrent) => (
|
|
635
|
-
* <div className={isCurrent ? 'highlight' : ''}>
|
|
636
|
-
* #{entry.rank} - {entry.displayName}
|
|
637
|
-
* </div>
|
|
638
|
-
* )}
|
|
639
|
-
* />
|
|
640
|
-
* ```
|
|
641
|
-
*/
|
|
642
|
-
declare function Leaderboard({ limit, className, style, currentUserId, emptyMessage, theme, renderRow, renderLoading, renderError, }: LeaderboardProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
640
|
+
declare const Leaderboard: React.FC<LeaderboardProps>;
|
|
643
641
|
/**
|
|
644
642
|
* Props for ReferralLink component
|
|
645
643
|
*/
|
|
@@ -662,6 +660,16 @@ interface ReferralLinkProps {
|
|
|
662
660
|
shareText?: string;
|
|
663
661
|
/** Show share button on mobile */
|
|
664
662
|
showShareButton?: boolean;
|
|
663
|
+
/** Show referrer attribution section (default: true) */
|
|
664
|
+
showReferrerAttribution?: boolean;
|
|
665
|
+
/** Current referrer code (who referred this user) */
|
|
666
|
+
referrerCode?: string | null;
|
|
667
|
+
/** Callback when referrer is set */
|
|
668
|
+
onSetReferrer?: (code: string) => void;
|
|
669
|
+
/** Callback to detect referrer from URL */
|
|
670
|
+
onDetectFromUrl?: () => void;
|
|
671
|
+
/** Callback when referrer is cleared */
|
|
672
|
+
onClearReferrer?: () => void;
|
|
665
673
|
/** Theme customization */
|
|
666
674
|
theme?: {
|
|
667
675
|
inputBackground?: string;
|
|
@@ -675,25 +683,7 @@ interface ReferralLinkProps {
|
|
|
675
683
|
/** Callback when link is shared */
|
|
676
684
|
onShare?: (link: string) => void;
|
|
677
685
|
}
|
|
678
|
-
|
|
679
|
-
* ReferralLink - Input field with user's referral code and copy/share buttons
|
|
680
|
-
*
|
|
681
|
-
* Displays the user's unique referral link with easy copy functionality.
|
|
682
|
-
* Includes native share button for mobile devices.
|
|
683
|
-
*
|
|
684
|
-
* @example
|
|
685
|
-
* ```tsx
|
|
686
|
-
* <ReferralLink />
|
|
687
|
-
*
|
|
688
|
-
* // With custom base URL
|
|
689
|
-
* <ReferralLink
|
|
690
|
-
* baseUrl="https://myapp.com/signup"
|
|
691
|
-
* shareTitle="Join my app!"
|
|
692
|
-
* shareText="Sign up using my referral link"
|
|
693
|
-
* />
|
|
694
|
-
* ```
|
|
695
|
-
*/
|
|
696
|
-
declare function ReferralLink({ baseUrl, className, style, copyButtonText, copiedText, shareButtonText, shareTitle, shareText, showShareButton, theme, onCopy, onShare, }: ReferralLinkProps): react_jsx_runtime.JSX.Element | null;
|
|
686
|
+
declare const ReferralLink: React.FC<ReferralLinkProps>;
|
|
697
687
|
/**
|
|
698
688
|
* Props for QuestProgress component
|
|
699
689
|
*/
|
|
@@ -706,6 +696,12 @@ interface QuestProgressProps {
|
|
|
706
696
|
className?: string;
|
|
707
697
|
/** Custom styles override */
|
|
708
698
|
style?: React.CSSProperties;
|
|
699
|
+
/** Enable expandable accordion mode (default: true) */
|
|
700
|
+
expandable?: boolean;
|
|
701
|
+
/** Default expanded quest ID (defaults to first in-progress) */
|
|
702
|
+
defaultExpandedId?: string;
|
|
703
|
+
/** Show XP reward in header (default: true) */
|
|
704
|
+
showXpReward?: boolean;
|
|
709
705
|
/** Callback when a quest is completed */
|
|
710
706
|
onComplete?: (quest: QuestWithProgress) => void;
|
|
711
707
|
/** Theme customization */
|
|
@@ -722,17 +718,7 @@ interface QuestProgressProps {
|
|
|
722
718
|
/** Custom render for each quest */
|
|
723
719
|
renderQuest?: (quest: QuestWithProgress) => React.ReactNode;
|
|
724
720
|
}
|
|
725
|
-
|
|
726
|
-
* QuestProgress - Display quest progress with step checklist
|
|
727
|
-
*
|
|
728
|
-
* Shows quest name, description, progress bar, and step completion status.
|
|
729
|
-
*
|
|
730
|
-
* @example
|
|
731
|
-
* ```tsx
|
|
732
|
-
* <QuestProgress hideCompleted onComplete={(quest) => console.log('Completed:', quest.name)} />
|
|
733
|
-
* ```
|
|
734
|
-
*/
|
|
735
|
-
declare function QuestProgress({ questId, hideCompleted, className, style, onComplete, theme, renderLoading, renderError, renderQuest, }: QuestProgressProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
721
|
+
declare const QuestProgress: React.FC<QuestProgressProps>;
|
|
736
722
|
/**
|
|
737
723
|
* Props for StreakFlame component
|
|
738
724
|
*/
|
|
@@ -760,17 +746,7 @@ interface StreakFlameProps {
|
|
|
760
746
|
/** Custom render for error state */
|
|
761
747
|
renderError?: (error: string) => React.ReactNode;
|
|
762
748
|
}
|
|
763
|
-
|
|
764
|
-
* StreakFlame - Display streak counter with flame icon
|
|
765
|
-
*
|
|
766
|
-
* Shows current streak count with status indicator and optional freeze button.
|
|
767
|
-
*
|
|
768
|
-
* @example
|
|
769
|
-
* ```tsx
|
|
770
|
-
* <StreakFlame showFreezeButton onFreeze={(id, remaining) => console.log('Freeze used')} />
|
|
771
|
-
* ```
|
|
772
|
-
*/
|
|
773
|
-
declare function StreakFlame({ ruleId, size, showFreezeButton, className, style, onFreeze, theme, renderLoading, renderError, }: StreakFlameProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
749
|
+
declare const StreakFlame: React.FC<StreakFlameProps>;
|
|
774
750
|
/**
|
|
775
751
|
* Props for BadgeGrid component
|
|
776
752
|
*/
|
|
@@ -785,7 +761,11 @@ interface BadgeGridProps {
|
|
|
785
761
|
className?: string;
|
|
786
762
|
/** Custom styles override */
|
|
787
763
|
style?: React.CSSProperties;
|
|
788
|
-
/** Show
|
|
764
|
+
/** Show progress summary header (default: true) */
|
|
765
|
+
showProgressSummary?: boolean;
|
|
766
|
+
/** Show filter tabs (All/Earned/Locked) (default: true) */
|
|
767
|
+
showFilterTabs?: boolean;
|
|
768
|
+
/** @deprecated Use showProgressSummary instead */
|
|
789
769
|
showStats?: boolean;
|
|
790
770
|
/** Callback when a badge is clicked */
|
|
791
771
|
onBadgeClick?: (badge: BadgeWithStatus) => void;
|
|
@@ -801,17 +781,7 @@ interface BadgeGridProps {
|
|
|
801
781
|
/** Custom render for each badge */
|
|
802
782
|
renderBadge?: (badge: BadgeWithStatus) => React.ReactNode;
|
|
803
783
|
}
|
|
804
|
-
|
|
805
|
-
* BadgeGrid - Display badge collection in a grid
|
|
806
|
-
*
|
|
807
|
-
* Shows badges with unlock status, rarity indicators, and optional filtering.
|
|
808
|
-
*
|
|
809
|
-
* @example
|
|
810
|
-
* ```tsx
|
|
811
|
-
* <BadgeGrid showLocked showStats onBadgeClick={(badge) => showBadgeModal(badge)} />
|
|
812
|
-
* ```
|
|
813
|
-
*/
|
|
814
|
-
declare function BadgeGrid({ showLocked, category, columns, className, style, showStats, onBadgeClick, theme, renderLoading, renderError, renderBadge, }: BadgeGridProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
784
|
+
declare const BadgeGrid: React.FC<BadgeGridProps>;
|
|
815
785
|
/**
|
|
816
786
|
* Props for LevelProgress component
|
|
817
787
|
*/
|
|
@@ -835,17 +805,7 @@ interface LevelProgressProps {
|
|
|
835
805
|
/** Custom render for error state */
|
|
836
806
|
renderError?: (error: string) => React.ReactNode;
|
|
837
807
|
}
|
|
838
|
-
|
|
839
|
-
* LevelProgress - Display tier/level progress
|
|
840
|
-
*
|
|
841
|
-
* Shows current tier, XP/points, and progress to next tier.
|
|
842
|
-
*
|
|
843
|
-
* @example
|
|
844
|
-
* ```tsx
|
|
845
|
-
* <LevelProgress showNextTier showBenefits />
|
|
846
|
-
* ```
|
|
847
|
-
*/
|
|
848
|
-
declare function LevelProgress({ showNextTier, showBenefits, className, style, theme, renderLoading, renderError, }: LevelProgressProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
808
|
+
declare const LevelProgress: React.FC<LevelProgressProps>;
|
|
849
809
|
/**
|
|
850
810
|
* Props for RewardStore component
|
|
851
811
|
*/
|
|
@@ -872,21 +832,6 @@ interface RewardStoreProps {
|
|
|
872
832
|
/** Custom render for each item */
|
|
873
833
|
renderItem?: (item: RewardItem, onRedeem: () => void) => React.ReactNode;
|
|
874
834
|
}
|
|
875
|
-
|
|
876
|
-
* RewardStore - Display reward catalog with redeem functionality
|
|
877
|
-
*
|
|
878
|
-
* Shows available rewards with point costs and redeem buttons.
|
|
879
|
-
*
|
|
880
|
-
* @example
|
|
881
|
-
* ```tsx
|
|
882
|
-
* <RewardStore
|
|
883
|
-
* showPointsHeader
|
|
884
|
-
* onRedeem={(item, result) => {
|
|
885
|
-
* if (result.success) toast.success(`Redeemed ${item.name}!`);
|
|
886
|
-
* }}
|
|
887
|
-
* />
|
|
888
|
-
* ```
|
|
889
|
-
*/
|
|
890
|
-
declare function RewardStore({ showUnavailable, className, style, showPointsHeader, onRedeem, theme, renderLoading, renderError, renderItem, }: RewardStoreProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
835
|
+
declare const RewardStore: React.FC<RewardStoreProps>;
|
|
891
836
|
|
|
892
|
-
export { AffiliateStats, type AffiliateStatsProps, BadgeGrid, type BadgeGridProps, type GamifyContextValue, GamifyPageView, type GamifyPageViewProps, GamifyProvider, type GamifyProviderProps, GamifyTrackClick, type GamifyTrackClickProps, Leaderboard, type LeaderboardProps, LevelProgress, type LevelProgressProps, QuestProgress, type QuestProgressProps, ReferralLink, type ReferralLinkProps, RewardStore, type RewardStoreProps, StreakFlame, type StreakFlameProps, useAffiliateStats, useBadges, useGamify, useIdentify, useLeaderboard, useLoyalty, useQuests, useReferral, useRewards, useSession, useStreaks, useTrack };
|
|
837
|
+
export { AffiliateStats, type AffiliateStatsProps, BadgeGrid, type BadgeGridProps, type GamifyContextValue, GamifyPageView, type GamifyPageViewProps, GamifyProvider, type GamifyProviderProps, GamifyTrackClick, type GamifyTrackClickProps, Leaderboard, type LeaderboardProps, LevelProgress, type LevelProgressProps, QuestProgress, type QuestProgressProps, ReferralLink, type ReferralLinkProps, RewardStore, type RewardStoreProps, StreakFlame, type StreakFlameProps, useAffiliateStats, useBadges, useGamify, useGamifyTheme, useIdentify, useLeaderboard, useLoyalty, useQuests, useReferral, useRewards, useSession, useStreaks, useTrack };
|