@simple-parlay/components 1.29.0
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/LICENSE +71 -0
- package/README.md +196 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +325 -0
- package/dist/react/components/BrandLockup.d.ts +18 -0
- package/dist/react/components/BrandLogo.d.ts +17 -0
- package/dist/react/components/CategoryPickerPage.d.ts +22 -0
- package/dist/react/components/ConfirmPage.d.ts +23 -0
- package/dist/react/components/EntriesPage.d.ts +19 -0
- package/dist/react/components/EntrySubmission.d.ts +2 -0
- package/dist/react/components/EventFilterBanner.d.ts +4 -0
- package/dist/react/components/EventPickerPage.d.ts +5 -0
- package/dist/react/components/GameEntries.d.ts +2 -0
- package/dist/react/components/GameLogo.d.ts +10 -0
- package/dist/react/components/GameModeCard.d.ts +34 -0
- package/dist/react/components/GamePage.d.ts +36 -0
- package/dist/react/components/GameSelector.d.ts +2 -0
- package/dist/react/components/GameSetBetPage.d.ts +21 -0
- package/dist/react/components/GameSetupPage.d.ts +27 -0
- package/dist/react/components/HowToPlayButton.d.ts +28 -0
- package/dist/react/components/HowToPlayPropsTable.d.ts +6 -0
- package/dist/react/components/HtmlContent.d.ts +5 -0
- package/dist/react/components/IconSvg.d.ts +11 -0
- package/dist/react/components/LadderPage.d.ts +21 -0
- package/dist/react/components/LoadingIndicators.d.ts +67 -0
- package/dist/react/components/MarkdownContent.d.ts +13 -0
- package/dist/react/components/MirrorPage.d.ts +21 -0
- package/dist/react/components/MultiLegTable.d.ts +40 -0
- package/dist/react/components/PageBackButton.d.ts +13 -0
- package/dist/react/components/PayoutCircles.d.ts +15 -0
- package/dist/react/components/PerfectPickPage.d.ts +22 -0
- package/dist/react/components/PickYourDividendPage.d.ts +21 -0
- package/dist/react/components/PickerBrand.d.ts +19 -0
- package/dist/react/components/PlaceEntryProvider.d.ts +137 -0
- package/dist/react/components/PressToPlayTile.d.ts +14 -0
- package/dist/react/components/QuickPickButton.d.ts +11 -0
- package/dist/react/components/QuickPickMenu.d.ts +17 -0
- package/dist/react/components/RuleSetupPage.d.ts +27 -0
- package/dist/react/components/SelectionReview.d.ts +2 -0
- package/dist/react/components/SelectionsPage.d.ts +25 -0
- package/dist/react/components/SportPickerPage.d.ts +27 -0
- package/dist/react/components/SportSelector.d.ts +2 -0
- package/dist/react/components/SuccessPage.d.ts +27 -0
- package/dist/react/components/_primitives/index.d.ts +91 -0
- package/dist/react/hooks/index.d.ts +1 -0
- package/dist/react/index.d.ts +74 -0
- package/dist/react/index.js +1 -0
- package/dist/react/index.mjs +325 -0
- package/dist/react/types/index.d.ts +8 -0
- package/dist/react/utils/api-client.d.ts +2 -0
- package/dist/react/utils/design.d.ts +55 -0
- package/dist/react/utils/dummy-data.d.ts +1 -0
- package/dist/react/utils/index.d.ts +2 -0
- package/dist/react/utils/themes.d.ts +13 -0
- package/dist/react-native/components/BrandLockup.d.ts +17 -0
- package/dist/react-native/components/BrandLogo.d.ts +16 -0
- package/dist/react-native/components/CategoryPickerPage.d.ts +17 -0
- package/dist/react-native/components/ConfirmPage.d.ts +19 -0
- package/dist/react-native/components/EntriesPage.d.ts +14 -0
- package/dist/react-native/components/EntrySubmission.d.ts +2 -0
- package/dist/react-native/components/EventFilterBanner.d.ts +4 -0
- package/dist/react-native/components/EventPickerPage.d.ts +4 -0
- package/dist/react-native/components/GameEntries.d.ts +2 -0
- package/dist/react-native/components/GameLogo.d.ts +9 -0
- package/dist/react-native/components/GameModeCard.d.ts +33 -0
- package/dist/react-native/components/GamePage.d.ts +33 -0
- package/dist/react-native/components/GameSelector.d.ts +2 -0
- package/dist/react-native/components/GameSetBetPage.d.ts +19 -0
- package/dist/react-native/components/GameSetupPage.d.ts +26 -0
- package/dist/react-native/components/HowToPlayButton.d.ts +17 -0
- package/dist/react-native/components/IconSvg.d.ts +9 -0
- package/dist/react-native/components/LadderPage.d.ts +19 -0
- package/dist/react-native/components/LoadingIndicators.d.ts +62 -0
- package/dist/react-native/components/MirrorPage.d.ts +19 -0
- package/dist/react-native/components/MultiLegTable.d.ts +37 -0
- package/dist/react-native/components/NativeMenuOverlay.d.ts +32 -0
- package/dist/react-native/components/PageBackButton.d.ts +25 -0
- package/dist/react-native/components/PayoutCircles.d.ts +14 -0
- package/dist/react-native/components/PerfectPickPage.d.ts +20 -0
- package/dist/react-native/components/PickYourDividendPage.d.ts +19 -0
- package/dist/react-native/components/PickerBrand.d.ts +18 -0
- package/dist/react-native/components/PlaceEntryProvider.d.ts +129 -0
- package/dist/react-native/components/PressToPlayTile.d.ts +13 -0
- package/dist/react-native/components/QuickPickButton.d.ts +11 -0
- package/dist/react-native/components/QuickPickMenu.d.ts +17 -0
- package/dist/react-native/components/RuleSetupPage.d.ts +23 -0
- package/dist/react-native/components/SelectionReview.d.ts +2 -0
- package/dist/react-native/components/SelectionsPage.d.ts +22 -0
- package/dist/react-native/components/SportPickerPage.d.ts +20 -0
- package/dist/react-native/components/SportSelector.d.ts +2 -0
- package/dist/react-native/components/SuccessPage.d.ts +24 -0
- package/dist/react-native/components/_primitives/index.d.ts +93 -0
- package/dist/react-native/hooks/index.d.ts +1 -0
- package/dist/react-native/index.d.ts +72 -0
- package/dist/react-native/index.js +1 -0
- package/dist/react-native/index.mjs +334 -0
- package/dist/react-native/types/index.d.ts +1 -0
- package/dist/react-native/utils/api-client.d.ts +2 -0
- package/dist/react-native/utils/dummy-data.d.ts +1 -0
- package/dist/react-native/utils/index.d.ts +2 -0
- package/dist/react-native/utils/themes.d.ts +5 -0
- package/dist/shared/api-client.d.ts +73 -0
- package/dist/shared/composite.d.ts +44 -0
- package/dist/shared/date-filters.d.ts +25 -0
- package/dist/shared/dummy-data.d.ts +9 -0
- package/dist/shared/game-flow.d.ts +39 -0
- package/dist/shared/game-icons.d.ts +10 -0
- package/dist/shared/game-set-bet.d.ts +48 -0
- package/dist/shared/game-tiers.d.ts +23 -0
- package/dist/shared/hooks.d.ts +100 -0
- package/dist/shared/how-to-play-html.d.ts +12 -0
- package/dist/shared/how-to-play-logo.d.ts +2 -0
- package/dist/shared/how-to-play-props-table.d.ts +21 -0
- package/dist/shared/how-to-play-styles.d.ts +2 -0
- package/dist/shared/ladder.d.ts +53 -0
- package/dist/shared/markdown.d.ts +24 -0
- package/dist/shared/mirror.d.ts +66 -0
- package/dist/shared/pick-your-dividend.d.ts +59 -0
- package/dist/shared/picker-brand.d.ts +11 -0
- package/dist/shared/rule-setup.d.ts +75 -0
- package/dist/shared/same-game-multi.d.ts +22 -0
- package/dist/shared/themes.d.ts +164 -0
- package/dist/shared/tokens.d.ts +64 -0
- package/dist/shared/types.d.ts +397 -0
- package/dist/shared/utils.d.ts +118 -0
- package/package.json +101 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BladeTheme, BladeThemeSet, ColorScheme } from './themes';
|
|
3
|
+
export type { BladeTheme, BladeThemeSet, ColorScheme };
|
|
4
|
+
/** Screen size category for responsive behavior.
|
|
5
|
+
* - `'desktop'` — width >= 1280px
|
|
6
|
+
* - `'tablet'` — width >= 962px
|
|
7
|
+
* - `'mobile'` — width < 962px
|
|
8
|
+
*
|
|
9
|
+
* @default 'desktop'
|
|
10
|
+
*/
|
|
11
|
+
export type ScreenSize = 'mobile' | 'tablet' | 'desktop';
|
|
12
|
+
/** Availability summary returned by `/propositions/sports`. */
|
|
13
|
+
export interface SportSummary {
|
|
14
|
+
key: string;
|
|
15
|
+
label: string;
|
|
16
|
+
games_today: number;
|
|
17
|
+
active_props: number;
|
|
18
|
+
}
|
|
19
|
+
/** Result of a quick pick selection (yes/no assignment for each proposition). */
|
|
20
|
+
export interface QuickPickResult {
|
|
21
|
+
yesPicks: Proposition[];
|
|
22
|
+
noPicks: Proposition[];
|
|
23
|
+
}
|
|
24
|
+
export interface RuleExpressionObject {
|
|
25
|
+
type: string;
|
|
26
|
+
template?: string;
|
|
27
|
+
validated?: boolean;
|
|
28
|
+
expression: string;
|
|
29
|
+
}
|
|
30
|
+
export interface Game {
|
|
31
|
+
id: number;
|
|
32
|
+
game_name: string;
|
|
33
|
+
game_name_template?: string | null;
|
|
34
|
+
num_propositions?: number | null;
|
|
35
|
+
min_propositions?: number;
|
|
36
|
+
max_propositions?: number;
|
|
37
|
+
allowed_propositions?: number[];
|
|
38
|
+
color: string;
|
|
39
|
+
logo_url?: string | null;
|
|
40
|
+
rule_image_url?: string | null;
|
|
41
|
+
play_icon_url?: string | null;
|
|
42
|
+
rule: string;
|
|
43
|
+
description?: string | null;
|
|
44
|
+
active: boolean;
|
|
45
|
+
payout_structure?: {
|
|
46
|
+
type: string;
|
|
47
|
+
formula?: string;
|
|
48
|
+
expression?: string;
|
|
49
|
+
values?: Record<string, number>;
|
|
50
|
+
results?: Record<string, number>;
|
|
51
|
+
/** Stake the pricing ladder is designed around (e.g. 20). */
|
|
52
|
+
stake_reference?: number;
|
|
53
|
+
/** Per-leg win probability used to price near-miss bets (0.5). */
|
|
54
|
+
per_leg_probability?: number;
|
|
55
|
+
/** Round every dividend to the nearest multiple of this (e.g. 5). */
|
|
56
|
+
round_to?: number;
|
|
57
|
+
/** Perfect-prize doubling ladder: prize = stake × stake_multiple × 2^(legs − base_legs). */
|
|
58
|
+
perfect_prize?: {
|
|
59
|
+
stake_multiple: number;
|
|
60
|
+
base_legs: number;
|
|
61
|
+
};
|
|
62
|
+
/** Share of the (1 − margin) budget that funds the near-miss bets (split evenly across allowed misses). */
|
|
63
|
+
near_miss?: {
|
|
64
|
+
budget_fraction: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
operator_margin?: number;
|
|
68
|
+
jackpot_enabled?: boolean;
|
|
69
|
+
jackpot_amount?: number;
|
|
70
|
+
jackpot_limit?: number | null;
|
|
71
|
+
jackpot_last_won_at?: string | null;
|
|
72
|
+
quick_pick_only?: boolean;
|
|
73
|
+
/** Selection scope supplied by newer APIs. Same Game uses `single_event`. */
|
|
74
|
+
selection_scope?: string | null;
|
|
75
|
+
/** Boolean alias for APIs that expose selection scope as a flag. */
|
|
76
|
+
require_same_event?: boolean;
|
|
77
|
+
require_distinct_events?: boolean;
|
|
78
|
+
allocations?: GameAllocation[];
|
|
79
|
+
rule_expression?: string | RuleExpressionObject | null;
|
|
80
|
+
min_bet?: number | null;
|
|
81
|
+
max_bet?: number | null;
|
|
82
|
+
tier?: number;
|
|
83
|
+
display_order?: number | null;
|
|
84
|
+
category?: string;
|
|
85
|
+
sub_category?: string | null;
|
|
86
|
+
lotto_type?: string;
|
|
87
|
+
jurisdictions?: string[];
|
|
88
|
+
allowed_sports?: string[];
|
|
89
|
+
available_days?: number[];
|
|
90
|
+
available_from?: string | null;
|
|
91
|
+
available_until?: string | null;
|
|
92
|
+
allowed_markets?: string[];
|
|
93
|
+
created_at?: string;
|
|
94
|
+
updated_at?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface GameAllocation {
|
|
97
|
+
id: number;
|
|
98
|
+
game_id: number;
|
|
99
|
+
allocation_type: string;
|
|
100
|
+
percentage: number;
|
|
101
|
+
dollar_amount?: number | null;
|
|
102
|
+
description?: string | null;
|
|
103
|
+
created_at?: string;
|
|
104
|
+
updated_at?: string;
|
|
105
|
+
}
|
|
106
|
+
export type RenderTeamLogo = (teamName: string) => ReactNode;
|
|
107
|
+
export interface Proposition {
|
|
108
|
+
id: number;
|
|
109
|
+
api_key_id?: number;
|
|
110
|
+
selection_id?: string | null;
|
|
111
|
+
sport?: string;
|
|
112
|
+
league?: string;
|
|
113
|
+
eventId?: string | null;
|
|
114
|
+
home_team?: string;
|
|
115
|
+
away_team?: string;
|
|
116
|
+
commence_time?: string;
|
|
117
|
+
propositionType?: string;
|
|
118
|
+
/** Snake_case alias returned by some API serializers. */
|
|
119
|
+
proposition_type?: string;
|
|
120
|
+
/** Hidden `co_*` legs used only inside composites — not bettable standalone. */
|
|
121
|
+
is_composite_component?: boolean;
|
|
122
|
+
proposition?: string;
|
|
123
|
+
description: string;
|
|
124
|
+
outcome?: string | null;
|
|
125
|
+
outcome_description?: string | null;
|
|
126
|
+
points?: number | null;
|
|
127
|
+
result?: string | null;
|
|
128
|
+
is_expired?: boolean;
|
|
129
|
+
is_suspended?: boolean;
|
|
130
|
+
is_voided?: boolean;
|
|
131
|
+
bettable?: boolean;
|
|
132
|
+
category?: string;
|
|
133
|
+
issued_at?: string;
|
|
134
|
+
source_data?: string | null;
|
|
135
|
+
event_id?: string | null;
|
|
136
|
+
user_prediction?: "yes" | "no";
|
|
137
|
+
}
|
|
138
|
+
export interface GameEntry {
|
|
139
|
+
id: number;
|
|
140
|
+
game_id: number;
|
|
141
|
+
user_id?: string | number | null;
|
|
142
|
+
api_key_id?: number;
|
|
143
|
+
proposition_ids?: number[];
|
|
144
|
+
propositions?: Proposition[];
|
|
145
|
+
selections?: Record<number, 'yes' | 'no'>;
|
|
146
|
+
pending: boolean;
|
|
147
|
+
winning?: number;
|
|
148
|
+
expected_correct?: number;
|
|
149
|
+
bet_amount?: number;
|
|
150
|
+
stake?: number;
|
|
151
|
+
payout_status?: 'pending' | 'fulfilled' | 'paid_out' | string;
|
|
152
|
+
paid_out_at?: string | null;
|
|
153
|
+
payout_reward?: number | null;
|
|
154
|
+
payout_jackpot?: number | null;
|
|
155
|
+
created_at?: string;
|
|
156
|
+
entry_date?: string;
|
|
157
|
+
updated_at?: string;
|
|
158
|
+
game_rule?: string;
|
|
159
|
+
color?: string;
|
|
160
|
+
}
|
|
161
|
+
/** Enriched entry data passed to `onSelectEntry` callbacks. */
|
|
162
|
+
export interface ResolvedEntryData {
|
|
163
|
+
entry: GameEntry;
|
|
164
|
+
game: Game | undefined;
|
|
165
|
+
propositions: Proposition[];
|
|
166
|
+
}
|
|
167
|
+
/** Data passed to the `onShare` callback on the success / entries page. */
|
|
168
|
+
export interface ShareData {
|
|
169
|
+
entry: GameEntry;
|
|
170
|
+
game: Game;
|
|
171
|
+
propositions: Proposition[];
|
|
172
|
+
selections: Record<number, 'yes' | 'no'>;
|
|
173
|
+
betAmount: number;
|
|
174
|
+
summary: string;
|
|
175
|
+
}
|
|
176
|
+
export interface TopPayoutEntry {
|
|
177
|
+
proposition_count: number;
|
|
178
|
+
multiplier: number;
|
|
179
|
+
price: number;
|
|
180
|
+
gross_payout: number;
|
|
181
|
+
net_payout: number;
|
|
182
|
+
operator_margin: number;
|
|
183
|
+
bet_amount?: number;
|
|
184
|
+
min_bet?: number;
|
|
185
|
+
}
|
|
186
|
+
export interface TopPayoutsResponse {
|
|
187
|
+
top_payouts: TopPayoutEntry[];
|
|
188
|
+
}
|
|
189
|
+
export interface PlaceEntryFlowProps {
|
|
190
|
+
apiUrl: string;
|
|
191
|
+
apiKey?: string;
|
|
192
|
+
/** Custom fetch for extra headers / auth for specific implementation **/
|
|
193
|
+
fetchImpl?: typeof fetch;
|
|
194
|
+
getAuthHeaders?: () => Promise<Record<string, string>> | Record<string, string>;
|
|
195
|
+
userId?: string | number;
|
|
196
|
+
getUserBalance?: () => Promise<number> | number;
|
|
197
|
+
onRecharge?: () => void;
|
|
198
|
+
onEntryPlaced?: (entry: GameEntry) => void;
|
|
199
|
+
onBeforeSubmit?: (betAmount: number) => void | Promise<void>;
|
|
200
|
+
onCancel?: () => void;
|
|
201
|
+
initialGameId?: number;
|
|
202
|
+
gameCategory?: 'sports' | 'casino' | 'racing';
|
|
203
|
+
jurisdiction?: string;
|
|
204
|
+
/** Supply demo/test data instead of hitting the API */
|
|
205
|
+
demoGames?: Game[];
|
|
206
|
+
/** Supply demo/test propositions instead of hitting the API */
|
|
207
|
+
demoPropositions?: Proposition[];
|
|
208
|
+
/** Supply demo/test entries for the Entries tab */
|
|
209
|
+
demoEntries?: GameEntry[];
|
|
210
|
+
theme?: BladeTheme | BladeThemeSet;
|
|
211
|
+
colorScheme?: ColorScheme;
|
|
212
|
+
/** Render as a modal overlay (default) or as an inline element */
|
|
213
|
+
modal?: boolean;
|
|
214
|
+
initialSport?: string;
|
|
215
|
+
filterSport?: string;
|
|
216
|
+
/** Custom renderer for team or proposition logos. Receives a display name or prop logo key. */
|
|
217
|
+
renderTeamLogo?: RenderTeamLogo;
|
|
218
|
+
/** Show "Home" / "Away" labels under each team name. @default false */
|
|
219
|
+
showHomeAway?: boolean;
|
|
220
|
+
/** Hide the Quick Pick @default false */
|
|
221
|
+
disableQuickPick?: boolean;
|
|
222
|
+
/** Callback when an entry is selected in the Entries tab */
|
|
223
|
+
onSelectEntry?: (data: ResolvedEntryData) => void;
|
|
224
|
+
/** Which view to show initially: 'quick-play' or 'entries' @default 'quick-play' */
|
|
225
|
+
initialView?: 'quick-play' | 'entries';
|
|
226
|
+
/** Callback when "Share" is pressed on the success screen, providing all data to duplicate the entry */
|
|
227
|
+
onShare?: (data: ShareData) => void;
|
|
228
|
+
/** Screen size hint for responsive behaviour (hides nav buttons on mobile). @default 'desktop' */
|
|
229
|
+
screenSize?: ScreenSize;
|
|
230
|
+
howToPlayMarkdown?: string | null;
|
|
231
|
+
}
|
|
232
|
+
export interface GameSelectorProps {
|
|
233
|
+
games: Game[];
|
|
234
|
+
selectedGame: Game | null;
|
|
235
|
+
onSelectGame: (game: Game) => void;
|
|
236
|
+
loading?: boolean;
|
|
237
|
+
error?: string | null;
|
|
238
|
+
theme?: BladeTheme | BladeThemeSet;
|
|
239
|
+
colorScheme?: ColorScheme;
|
|
240
|
+
showTier?: boolean;
|
|
241
|
+
showCategory?: boolean;
|
|
242
|
+
showTierFilter?: boolean;
|
|
243
|
+
/** When the game has allowed_propositions, the currently selected count */
|
|
244
|
+
selectedPropositionCount?: number;
|
|
245
|
+
/** Called when the user picks a proposition count option (before navigating) */
|
|
246
|
+
onPropositionCountChange?: (count: number) => void;
|
|
247
|
+
/** Called when a proposition count option is picked (can be used to auto-advance) */
|
|
248
|
+
onPropositionCountSelected?: () => void;
|
|
249
|
+
onQuickPickGame?: (game: Game, count: number) => void;
|
|
250
|
+
/** Max payout data per game ID (from /max-payout endpoint) */
|
|
251
|
+
maxPayouts?: Record<number, TopPayoutsResponse>;
|
|
252
|
+
}
|
|
253
|
+
export interface SportSelectorProps {
|
|
254
|
+
game: Game;
|
|
255
|
+
propositions: Proposition[];
|
|
256
|
+
selections: Record<number, 'yes' | 'no'>;
|
|
257
|
+
onToggleSelection: (id: number, answer: 'yes' | 'no') => void;
|
|
258
|
+
onNext: () => void;
|
|
259
|
+
onBack: () => void;
|
|
260
|
+
loading?: boolean;
|
|
261
|
+
error?: string | null;
|
|
262
|
+
theme?: BladeTheme | BladeThemeSet;
|
|
263
|
+
colorScheme?: ColorScheme;
|
|
264
|
+
hideActions?: boolean;
|
|
265
|
+
initialSport?: string;
|
|
266
|
+
gameCategory?: 'sports' | 'casino' | 'racing';
|
|
267
|
+
renderTeamLogo?: RenderTeamLogo;
|
|
268
|
+
/** Show "Home" / "Away" labels under each team name. @default false */
|
|
269
|
+
showHomeAway?: boolean;
|
|
270
|
+
/** Hide the Quick Pick button and count input. @default false */
|
|
271
|
+
disableQuickPick?: boolean;
|
|
272
|
+
selectedPropositionCount?: number;
|
|
273
|
+
onPropositionCountChange?: (count: number) => void;
|
|
274
|
+
allowAnswerToggle?: boolean;
|
|
275
|
+
}
|
|
276
|
+
export interface EntrySubmissionProps {
|
|
277
|
+
game: Game;
|
|
278
|
+
propositions: Proposition[];
|
|
279
|
+
selections?: Record<number, 'yes' | 'no'>;
|
|
280
|
+
onToggleSelection?: (id: number, answer: 'yes' | 'no') => void;
|
|
281
|
+
/** Called when a selection is removed (e.g. to navigate back to sport selection) */
|
|
282
|
+
onRemoveSelection?: (id: number) => void;
|
|
283
|
+
onSubmit: () => void;
|
|
284
|
+
onBack: () => void;
|
|
285
|
+
loading?: boolean;
|
|
286
|
+
error?: string | null;
|
|
287
|
+
expectedCorrect: number;
|
|
288
|
+
onExpectedCorrectChange: (value: number) => void;
|
|
289
|
+
betAmount: number;
|
|
290
|
+
onBetAmountChange: (value: number) => void;
|
|
291
|
+
theme?: BladeTheme | BladeThemeSet;
|
|
292
|
+
colorScheme?: ColorScheme;
|
|
293
|
+
hideActions?: boolean;
|
|
294
|
+
winningCounts?: number[];
|
|
295
|
+
payouts?: Record<number, number>;
|
|
296
|
+
renderTeamLogo?: RenderTeamLogo;
|
|
297
|
+
/** Show "Home" / "Away" labels under each team name. @default false */
|
|
298
|
+
showHomeAway?: boolean;
|
|
299
|
+
/** Show the free-text custom amount input. @default false */
|
|
300
|
+
showCustomAmount?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Lock the stake: hides the amount controls and shows the fixed figure with
|
|
303
|
+
* an explanatory note. Used by fixed-dividend games (Pick Your Dividend),
|
|
304
|
+
* where the stake is the rung price and must not drift.
|
|
305
|
+
*/
|
|
306
|
+
betAmountLocked?: boolean;
|
|
307
|
+
/** Note shown beside the locked stake, e.g. "set by your dividend ladder". */
|
|
308
|
+
betAmountLockedNote?: string;
|
|
309
|
+
canSubmit?: boolean;
|
|
310
|
+
/** User Balance number and function for recharging **/
|
|
311
|
+
userBalance?: number;
|
|
312
|
+
onRecharge?: () => void;
|
|
313
|
+
boostBanner?: ReactNode;
|
|
314
|
+
}
|
|
315
|
+
export interface SelectionReviewProps {
|
|
316
|
+
propositions: Proposition[];
|
|
317
|
+
selections: Record<number, 'yes' | 'no'>;
|
|
318
|
+
onToggleSelection: (id: number, answer: 'yes' | 'no') => void;
|
|
319
|
+
onNext: () => void;
|
|
320
|
+
onBack: () => void;
|
|
321
|
+
theme?: BladeTheme | BladeThemeSet;
|
|
322
|
+
colorScheme?: ColorScheme;
|
|
323
|
+
hideActions?: boolean;
|
|
324
|
+
renderTeamLogo?: RenderTeamLogo;
|
|
325
|
+
/** Show "Home" / "Away" labels under each team name. @default false */
|
|
326
|
+
showHomeAway?: boolean;
|
|
327
|
+
allowAnswerToggle?: boolean;
|
|
328
|
+
gameName?: string;
|
|
329
|
+
potentialPayout?: number;
|
|
330
|
+
defaultExpanded?: boolean;
|
|
331
|
+
addMorePicks?: {
|
|
332
|
+
remaining: number;
|
|
333
|
+
max: number;
|
|
334
|
+
potentialPayout?: number;
|
|
335
|
+
betAmount?: number;
|
|
336
|
+
onAdd: () => void;
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
export interface GameEntriesProps {
|
|
340
|
+
apiUrl: string;
|
|
341
|
+
apiKey?: string;
|
|
342
|
+
/** Custom fetch for extra headers / auth for specific implementation **/
|
|
343
|
+
fetchImpl?: typeof fetch;
|
|
344
|
+
getAuthHeaders?: () => Promise<Record<string, string>> | Record<string, string>;
|
|
345
|
+
userId?: string | number;
|
|
346
|
+
demoEntries?: GameEntry[];
|
|
347
|
+
demoGames?: Game[];
|
|
348
|
+
demoPropositions?: Proposition[];
|
|
349
|
+
onSelectEntry?: (data: ResolvedEntryData) => void;
|
|
350
|
+
theme?: BladeTheme | BladeThemeSet;
|
|
351
|
+
colorScheme?: ColorScheme;
|
|
352
|
+
renderTeamLogo?: RenderTeamLogo;
|
|
353
|
+
/** Show "Home" / "Away" labels under each team name. @default false */
|
|
354
|
+
showHomeAway?: boolean;
|
|
355
|
+
filterSport?: string;
|
|
356
|
+
}
|
|
357
|
+
export interface EvaluateRuleRequest {
|
|
358
|
+
actual: number;
|
|
359
|
+
predicted: number;
|
|
360
|
+
total: number;
|
|
361
|
+
}
|
|
362
|
+
export interface EvaluateRuleResponse {
|
|
363
|
+
is_winner: boolean;
|
|
364
|
+
winning_counts: number[];
|
|
365
|
+
rule_expression: string;
|
|
366
|
+
evaluation_details: {
|
|
367
|
+
actual: number;
|
|
368
|
+
predicted: number;
|
|
369
|
+
total: number;
|
|
370
|
+
matches_prediction: boolean;
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
export interface CalculatePayoutRequest {
|
|
374
|
+
correct_count: number;
|
|
375
|
+
bet_amount: number;
|
|
376
|
+
}
|
|
377
|
+
export interface CalculatePayoutResponse {
|
|
378
|
+
gross_payout: number;
|
|
379
|
+
net_payout: number;
|
|
380
|
+
multiplier: number;
|
|
381
|
+
operator_margin: number;
|
|
382
|
+
payout_structure: {
|
|
383
|
+
type: string;
|
|
384
|
+
expression?: string;
|
|
385
|
+
values?: Record<string, number>;
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
export interface EntryPreviewRequest {
|
|
389
|
+
actual: number;
|
|
390
|
+
predicted: number;
|
|
391
|
+
total: number;
|
|
392
|
+
bet_amount: number;
|
|
393
|
+
}
|
|
394
|
+
export interface EntryPreviewResponse {
|
|
395
|
+
winning_counts: number[];
|
|
396
|
+
payouts: Record<string, number>;
|
|
397
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Game, Proposition, QuickPickResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve a price value to a plain number.
|
|
4
|
+
* Handles number, string, or { amount, currency } object forms.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolvePrice(price: number | string | {
|
|
7
|
+
amount: number | string;
|
|
8
|
+
currency?: string;
|
|
9
|
+
} | null | undefined): number;
|
|
10
|
+
export declare function toNumber(value: unknown): number;
|
|
11
|
+
export declare function toBool(value: unknown): boolean;
|
|
12
|
+
export declare function formatYesNo(value: string): string;
|
|
13
|
+
export declare function formatCurrency(value: number): string;
|
|
14
|
+
export declare function formatDate(date: Date | string): string;
|
|
15
|
+
export declare function groupPropositionsBySport(propositions: Proposition[]): Record<string, Proposition[]>;
|
|
16
|
+
/** Resolve the sport bucket for UI grouping (composites inherit from component legs). */
|
|
17
|
+
export declare function getPropositionSportKey(prop: Proposition, pool?: Proposition[]): string;
|
|
18
|
+
/** Collect distinct sport keys from a pool, including composite component legs. */
|
|
19
|
+
export declare function collectPropositionSportKeys(propositions: Proposition[]): string[];
|
|
20
|
+
export declare function groupPropositionsByCategory(propositions: Proposition[]): Record<string, Proposition[]>;
|
|
21
|
+
export type EntryCategory = 'sports' | 'casino' | 'racing';
|
|
22
|
+
export declare const ENTRY_CATEGORY_ORDER: EntryCategory[];
|
|
23
|
+
export declare function getPropositionEntryCategory(prop: Proposition): EntryCategory;
|
|
24
|
+
export declare function groupPropositionsByEntryCategory(propositions: Proposition[]): Partial<Record<EntryCategory, Proposition[]>>;
|
|
25
|
+
export declare function getAvailableEntryCategories(propositions: Proposition[]): EntryCategory[];
|
|
26
|
+
export declare function getCategoryDisplayName(category: string): string;
|
|
27
|
+
export { COMPOSITE_AND_TYPE, COMPOSITE_OR_TYPE, COMPOSITE_PROPOSITION_TYPES, getCompositeOperatorLabel, getCompositeHelperText, parseCompositeDescription, inferCompositeOperatorFromDescription, resolveCompositeOperator, resolveCompositeDisplay, resolveCompositeLegs, parseCompositeComponentIds, collectCompositeComponentIds, formatPropositionEventLabel, isCompositeProposition, getPropositionDescription, getPropositionMarketType, gameAcceptsCompositeMarkets, isCompositeComponentType, isCompositePropositionType, propositionAllowedForGameMarkets, } from './composite';
|
|
28
|
+
export type { CompositeOperator, CompositeLegDisplay } from './composite';
|
|
29
|
+
export { PICKER_BRAND, SPORT_SHORT_CODES, getCategoryTagline, getSportShortCode, getSportPickerTagline, getSportSummaryTagline, gameLogoTileFontSize, } from './picker-brand';
|
|
30
|
+
export { resolveGameIconId, resolveGameIconUrl, isGameIconUrl, resolveGameIconMarkup, GAME_ICON_SCHEME, GAME_ICON_SVG, } from './game-icons';
|
|
31
|
+
export type { GameIconId } from './game-icons';
|
|
32
|
+
export declare function getSportPickerTitle(selectedCategory: string | null | undefined): string;
|
|
33
|
+
export declare function isValidSelectionCount(count: number, min?: number, max?: number, options?: number[]): boolean;
|
|
34
|
+
export declare function getEffectivePropositionLimits(game: Game, selectedCount?: number): {
|
|
35
|
+
min: number;
|
|
36
|
+
max: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Derive jackpot information from a Game object.
|
|
40
|
+
*
|
|
41
|
+
* The live API can expose jackpot data in several ways:
|
|
42
|
+
* • `jackpot_enabled: true` with a fixed `jackpot_amount > 0`
|
|
43
|
+
* • `jackpot_enabled: true` with a progressive pool — `jackpot_amount` may
|
|
44
|
+
* be 0 while `jackpot_limit` holds the cap and `allocations` contains a
|
|
45
|
+
* `jackpot` entry with a percentage (funded per entry)
|
|
46
|
+
* • An `allocations` entry with `allocation_type === 'jackpot'` and a
|
|
47
|
+
* `dollar_amount > 0` (fixed allocation)
|
|
48
|
+
*/
|
|
49
|
+
export declare function getJackpotInfo(game: Game): {
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
amount: number;
|
|
52
|
+
limit: number;
|
|
53
|
+
progressive: boolean;
|
|
54
|
+
};
|
|
55
|
+
export declare function isRacingCategory(gameCategory?: 'sports' | 'casino' | 'racing', propositions?: Proposition[], sportBaseKey?: string | null): boolean;
|
|
56
|
+
export declare function getSportDisplayName(sport: string, sportBaseKey?: string | null): string;
|
|
57
|
+
/** Host-supplied UI labels keyed by sport key (e.g. `basketball_nba` → `NBA`). */
|
|
58
|
+
export type SportDisplayNameOverrides = Record<string, string>;
|
|
59
|
+
/** Host-supplied UI labels keyed by entry category (e.g. `sports`, `casino`, `racing`). */
|
|
60
|
+
export type CategoryDisplayNameOverrides = Record<string, string>;
|
|
61
|
+
export declare function resolveSportDisplayName(sport: string, overrides?: SportDisplayNameOverrides | null, sportBaseKey?: string | null): string;
|
|
62
|
+
export declare function resolveCategoryDisplayName(category: string, overrides?: CategoryDisplayNameOverrides | null): string;
|
|
63
|
+
/**
|
|
64
|
+
* Filter propositions to only those allowed by a game's constraints.
|
|
65
|
+
* Applies `allowed_sports` and `allowed_markets` filters.
|
|
66
|
+
* `available_days` controls when the game card is playable (handled by `isGameAvailableToday`)
|
|
67
|
+
* and does not affect which propositions are visible.
|
|
68
|
+
*/
|
|
69
|
+
export interface PropositionPoolFilters {
|
|
70
|
+
category?: string | null;
|
|
71
|
+
sport?: string | null;
|
|
72
|
+
sportBaseKey?: string | null;
|
|
73
|
+
}
|
|
74
|
+
export declare function normalizeGamesSport(sport: string | null | undefined, sportBaseKey?: string | null): string | undefined;
|
|
75
|
+
/** True when a requested sport matches an allowed sport (exact or base/variant pair). */
|
|
76
|
+
export declare function sportKeysCompatible(requested: string, allowed: string, sportBaseKey?: string | null): boolean;
|
|
77
|
+
export declare function propositionSportMatches(propositionSport: string | null | undefined, filterSport: string | null | undefined, sportBaseKey?: string | null): boolean;
|
|
78
|
+
/** True when a composite row matches a sport filter via its own sport or any component leg. */
|
|
79
|
+
export declare function compositePropositionMatchesSport(prop: Proposition, filterSport: string, sportBaseKey?: string | null, pool?: Proposition[]): boolean;
|
|
80
|
+
/** True when a composite row is eligible for a game's allowed_sports list. */
|
|
81
|
+
export declare function compositePropositionMatchesGameSports(prop: Proposition, allowedSports: string[], sportBaseKey?: string | null, pool?: Proposition[]): boolean;
|
|
82
|
+
/** Narrow a proposition pool by in-flow category and/or sport selection. */
|
|
83
|
+
export declare function filterPropositionPool(propositions: Proposition[], filters?: PropositionPoolFilters): Proposition[];
|
|
84
|
+
export declare function getGameEntryCategory(game: Game): EntryCategory;
|
|
85
|
+
export declare function gameMatchesEntryCategory(game: Game, category: string | null | undefined): boolean;
|
|
86
|
+
export declare function gamePermitsSport(game: Game, sport: string | null | undefined, sportBaseKey?: string | null): boolean;
|
|
87
|
+
/** True when a game has at least one matching proposition after game-level filters. */
|
|
88
|
+
export declare function gameHasPropositionsInPool(game: Game, propositions: Proposition[], filters?: PropositionPoolFilters): boolean;
|
|
89
|
+
export declare function filterGamesByPropositionPool(games: Game[], propositions: Proposition[], filters?: PropositionPoolFilters): Game[];
|
|
90
|
+
export declare function filterGamesByEntryCategory(games: Game[], filters?: PropositionPoolFilters): Game[];
|
|
91
|
+
export declare function filterPropositionsForGame(propositions: Proposition[], game: Game, sportBaseKey?: string | null): Proposition[];
|
|
92
|
+
/**
|
|
93
|
+
* Check if a game is available today based on its `available_days` constraint.
|
|
94
|
+
* Days are 0-indexed from Monday: 0 = Monday, 1 = Tuesday … 6 = Sunday.
|
|
95
|
+
* An empty or undefined `available_days` means the game is always available.
|
|
96
|
+
*/
|
|
97
|
+
export declare function isGameAvailableToday(game: Game, now?: Date): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Get a human-readable string of the days a game is available.
|
|
100
|
+
* Returns e.g. "Mon & Tue" or "Mon, Wed & Fri".
|
|
101
|
+
* Returns null if the game is always available.
|
|
102
|
+
*/
|
|
103
|
+
export declare function getAvailableDaysLabel(game: Game): string | null;
|
|
104
|
+
export declare function contrastTextColour(bgColor: string | undefined | null, lightText?: string, darkText?: string): string;
|
|
105
|
+
export declare function readableColor(bg: string | undefined | null, desired: string | undefined | null, fallback: string, minRatio?: number): string;
|
|
106
|
+
/** Group propositions by matchup (home_team vs away_team). */
|
|
107
|
+
export declare function groupByMatchup(props: Proposition[]): Record<string, Proposition[]>;
|
|
108
|
+
export declare function groupByRace(props: Proposition[]): Record<string, Proposition[]>;
|
|
109
|
+
export declare function groupPropositionsForDisplay(props: Proposition[], gameCategory?: 'sports' | 'casino' | 'racing', sportBaseKey?: string | null): Record<string, Proposition[]>;
|
|
110
|
+
/** Returns all integer counts from min to max inclusive. */
|
|
111
|
+
export declare function buildRangeLegOptions(min: number, max: number): number[];
|
|
112
|
+
/** Returns the net payout for a given count from a game's payout_structure. */
|
|
113
|
+
export declare function getPayoutForCount(game: Game, count: number, price: number): number;
|
|
114
|
+
/**
|
|
115
|
+
* Generate a quick pick: randomly select and assign yes/no to propositions.
|
|
116
|
+
* Returns the picks without side effects — callers apply them via onToggleSelection.
|
|
117
|
+
*/
|
|
118
|
+
export declare function generateQuickPick(propositions: Proposition[], totalToAnswer: number): QuickPickResult;
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@simple-parlay/components",
|
|
3
|
+
"version": "1.29.0",
|
|
4
|
+
"description": "UI components, hooks, and utilities for React and React Native",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./react": {
|
|
16
|
+
"types": "./dist/react/index.d.ts",
|
|
17
|
+
"import": "./dist/react/index.mjs",
|
|
18
|
+
"require": "./dist/react/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./react-native": {
|
|
21
|
+
"types": "./dist/react-native/index.d.ts",
|
|
22
|
+
"import": "./dist/react-native/index.mjs",
|
|
23
|
+
"require": "./dist/react-native/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "vite --config vite.config.dev.js",
|
|
33
|
+
"dev:native": "vite --config vite.config.dev-rn.js",
|
|
34
|
+
"refresh:dummy": "node scripts/refresh-dummy-data.mjs",
|
|
35
|
+
"build": "npm run clean && npm run build:main && npm run build:react && npm run build:react-native",
|
|
36
|
+
"build:main": "vite build --config vite.config.js",
|
|
37
|
+
"build:react": "vite build --config vite.config.react.js",
|
|
38
|
+
"build:react-native": "vite build --config vite.config.react-native.js",
|
|
39
|
+
"clean": "rm -rf dist",
|
|
40
|
+
"test": "vitest run --project integration",
|
|
41
|
+
"test:watch": "vitest --project integration",
|
|
42
|
+
"test:integration": "vitest run --project integration --reporter=verbose",
|
|
43
|
+
"test:live": "vitest run --project live --reporter=verbose",
|
|
44
|
+
"test:native": "vitest run --project react-native --reporter=verbose",
|
|
45
|
+
"test:parity": "vitest run --project parity --reporter=verbose",
|
|
46
|
+
"test:e2e": "playwright test",
|
|
47
|
+
"test:e2e:ui": "playwright test --ui",
|
|
48
|
+
"test:visual": "playwright test --config playwright.visual.config.ts",
|
|
49
|
+
"dev:expo": "npm run start --prefix dev-expo",
|
|
50
|
+
"prepublishOnly": "npm run build",
|
|
51
|
+
"generate:how-to-play-logo": "node scripts/embed-how-to-play-logo.mjs",
|
|
52
|
+
"generate:game-icons": "node scripts/embed-game-icons.mjs"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"components",
|
|
56
|
+
"react",
|
|
57
|
+
"ui"
|
|
58
|
+
],
|
|
59
|
+
"author": "Simple Parlay",
|
|
60
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "https://github.com/Simple-Parlay/components.git"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public",
|
|
67
|
+
"registry": "https://registry.npmjs.org"
|
|
68
|
+
},
|
|
69
|
+
"peerDependencies": {
|
|
70
|
+
"react": ">=18.0.0",
|
|
71
|
+
"react-dom": ">=18.0.0",
|
|
72
|
+
"react-native-svg": ">=13.0.0",
|
|
73
|
+
"react-native-webview": ">=13.0.0"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"react-native-webview": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@playwright/test": "^1.59.1",
|
|
82
|
+
"@testing-library/dom": "^10.4.1",
|
|
83
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
84
|
+
"@testing-library/react": "^16.3.2",
|
|
85
|
+
"@types/node": "^20.10.0",
|
|
86
|
+
"@types/react": "^18.2.45",
|
|
87
|
+
"@types/react-dom": "^18.2.18",
|
|
88
|
+
"@vitejs/plugin-react": "^5.2.0",
|
|
89
|
+
"happy-dom": "^20.6.1",
|
|
90
|
+
"msw": "^2.12.10",
|
|
91
|
+
"react": "^18.2.0",
|
|
92
|
+
"react-dom": "^18.2.0",
|
|
93
|
+
"react-native-svg": "^15.15.4",
|
|
94
|
+
"react-native-web": "^0.21.2",
|
|
95
|
+
"terser": "^5.46.1",
|
|
96
|
+
"typescript": "^5.3.3",
|
|
97
|
+
"vite": "^8.0.3",
|
|
98
|
+
"vite-plugin-dts": "^5.0.2",
|
|
99
|
+
"vitest": "^4.1.2"
|
|
100
|
+
}
|
|
101
|
+
}
|