fansunited-frontend-components 0.0.52 → 0.0.53

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/Betslip.js CHANGED
@@ -1,4 +1,4 @@
1
- import { M as o } from "./chunks/main-DDb9jezz.js";
1
+ import { M as o } from "./chunks/main-C7QFqjXA.js";
2
2
  const i = o;
3
3
  export {
4
4
  i as Betslip
package/Predictor.js CHANGED
@@ -4,7 +4,7 @@ import we, { createContext as _t, useContext as _e, useState as F, useCallback a
4
4
  import { l as ue, a as he, e as le, B as u, f as Re, b as xe, c as ye, g as Ut, C as Kt, i as Gr, u as hl, k as fs, d as fl } from "./chunks/PrizeCard-DgHyperX.js";
5
5
  import { P as ml } from "./chunks/Portal-BQilulgu.js";
6
6
  import { createPortal as gl } from "react-dom";
7
- import { b as Vn, M as xl } from "./chunks/main-DDb9jezz.js";
7
+ import { b as Vn, M as xl } from "./chunks/main-C7QFqjXA.js";
8
8
  import { u as yl, d as bl, b as vl, e as Sl, o as Cl } from "./chunks/index-5MPtbA_r.js";
9
9
  import { S as wl } from "./chunks/Stack-INH9bhkC.js";
10
10
  import { F as kl, C as Tl } from "./chunks/FormControl-COjw1gQd.js";
package/README.md CHANGED
@@ -3459,8 +3459,7 @@ A floating betslip component that collects selections from any external source a
3459
3459
 
3460
3460
  ```tsx
3461
3461
  import React from "react";
3462
- import { Betslip } from "fansunited-frontend-components";
3463
- import { betslipApi } from "fansunited-frontend-core";
3462
+ import { Betslip, betslipApi } from "fansunited-frontend-components";
3464
3463
  import { FansUnitedSDK } from "fansunited-sdk-esm";
3465
3464
 
3466
3465
  const sdk = FansUnitedSDK({ /* your config */ });
@@ -3532,10 +3531,12 @@ type BetslipPosition =
3532
3531
 
3533
3532
  #### Command Bus (`betslipApi`)
3534
3533
 
3535
- The betslip exposes a singleton command bus for external code to manage selections without needing a direct reference to the React component.
3534
+ The betslip exposes a singleton command bus for external code to manage selections and read betslip state without needing a direct reference to the React component.
3535
+
3536
+ > **Important:** Always import `betslipApi` from `fansunited-frontend-components`. The component bundles its own singleton instance — importing from the components package guarantees your code and the widget share the same bus.
3536
3537
 
3537
3538
  ```tsx
3538
- import { betslipApi } from "fansunited-frontend-core";
3539
+ import { betslipApi } from "fansunited-frontend-components";
3539
3540
 
3540
3541
  // Add or replace a selection (same eventId + market = outcome replaced)
3541
3542
  betslipApi.setSelection("fb:m:451678:FT_1X2:1");
@@ -3556,11 +3557,43 @@ betslipApi.removeSelection("fb:m:451678:FT_1X2:1");
3556
3557
  | `market` | `FT_1X2`, `DOUBLE_CHANCE`, `OVER_GOALS_2_5`, `CORRECT_SCORE`, `PLAYER_SCORE_FIRST_GOAL` |
3557
3558
  | `outcome` | `1` (home), `x` (draw), `2` (away), `1x`, `yes`, `no`, `1-2` (correct score) |
3558
3559
 
3560
+ **Reading state:**
3561
+
3562
+ `betslipApi.getState()` returns a snapshot of the current betslip state. `betslipApi.subscribe()` lets you react to every change — useful for syncing a selection count badge, enabling a custom CTA elsewhere on the page, or forwarding stake changes to your own backend.
3563
+
3564
+ ```tsx
3565
+ import { betslipApi } from "fansunited-frontend-components";
3566
+ import type { BetslipState } from "fansunited-frontend-components";
3567
+
3568
+ // One-shot read
3569
+ const { selections, stake, totalOdds } = betslipApi.getState();
3570
+
3571
+ // Reactive — fires on every selection, stake, or odds change; returns unsubscribe
3572
+ const unsubscribe = betslipApi.subscribe((state: BetslipState) => {
3573
+ setBadgeCount(state.selections.length);
3574
+ });
3575
+
3576
+ // Stop listening
3577
+ unsubscribe();
3578
+ ```
3579
+
3580
+ **`BetslipState` shape:**
3581
+
3582
+ ```ts
3583
+ interface BetslipState {
3584
+ selections: BetslipSelectionInput[]; // raw inputs (same shape as setSelection input)
3585
+ stake: number; // parsed numeric stake (0 when empty)
3586
+ totalOdds: number; // product of all selection decimal odds (0 when no selections)
3587
+ }
3588
+ ```
3589
+
3559
3590
  **Pre-mount queuing:**
3560
3591
 
3561
3592
  Calls to `betslipApi.setSelection` made before the `<Betslip />` component has mounted are queued and automatically replayed once the widget finishes initializing. There is no need to delay external code to wait for the widget.
3562
3593
 
3563
3594
  ```tsx
3595
+ import { betslipApi } from "fansunited-frontend-components";
3596
+
3564
3597
  // Safe to call before <Betslip /> is rendered
3565
3598
  betslipApi.setSelection("fb:m:451678:FT_1X2:1");
3566
3599