@sensiblestats/widget-react 0.164.0 → 0.165.1
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/CHANGELOG.md +17 -0
- package/README.md +12 -10
- package/dist/index.cjs +58 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +58 -32
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @sensiblestats/widget-react
|
|
2
2
|
|
|
3
|
+
## 0.165.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6d6939e: Live facts: a second live moment with a market leads under the first one instead of sitting in Earlier.
|
|
8
|
+
|
|
9
|
+
## 0.165.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Live facts carry Market Moments: the `moment` fact kind with `progressCount` and `progressLine`. The fact block leads with up to two moments, each with its own chip and never in Earlier, and shows a history line only when the server sends one.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @sensiblestats/widget-sdk@0.121.0
|
|
19
|
+
|
|
3
20
|
## 0.164.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ export const widgetHost = createWidgetHost()
|
|
|
89
89
|
```tsx
|
|
90
90
|
// Module scope too: a new function or array on every render makes the widget rebuild its slip handling.
|
|
91
91
|
const addToMySlip = (selection: SlipSelection) => mySlip.add(selection)
|
|
92
|
-
const SLIP_SPORTS = ['basketball'] as const
|
|
92
|
+
const SLIP_SPORTS = ['basketball', 'americanfootball', 'tennis'] as const
|
|
93
93
|
|
|
94
94
|
<StatsWidget
|
|
95
95
|
host={widgetHost}
|
|
@@ -107,14 +107,15 @@ widgetHost.slipRemoved({ matchOddsId }) // a leg left your slip
|
|
|
107
107
|
widgetHost.betPlaced({ selections: [{ matchOddsId }] }) // the bet was placed
|
|
108
108
|
widgetHost.matchOpened({ matchId }) // your match page opened
|
|
109
109
|
|
|
110
|
-
//
|
|
110
|
+
// a non-football leg also carries sport; the type is { matchOddsId: number; sport?: SlipSport }
|
|
111
111
|
widgetHost.slipRemoved({ matchOddsId, sport: 'basketball' })
|
|
112
112
|
widgetHost.betPlaced({ selections: [{ matchOddsId, sport: 'basketball' }] })
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
What each one does:
|
|
116
116
|
|
|
117
|
-
- `onAddToSlip`. Called when the user taps "Add to slip", with `{ matchOddsId, matchId, oddsDecimal, odds?, sport? }`, where `sport` is the optional `'basketball'
|
|
117
|
+
- `onAddToSlip`. Called when the user taps "Add to slip", with `{ matchOddsId, matchId, oddsDecimal, odds?, sport? }`, where `sport` is the optional `SlipSport` (`'basketball'`, `'americanfootball'` or `'tennis'`).
|
|
118
|
+
Besides `added`, `duplicate` and `rejected`, a result can be `{ status: 'price_changed', newOdds, accepted }`, where `newOdds` is a string.
|
|
118
119
|
`oddsDecimal` is always set. `odds`, when present, is `{ format, text }` in your configured `oddsFormat`, never the visitor's own pick; it is left out when the widget has no text in that format, so if `odds` is absent, use `oddsDecimal`.
|
|
119
120
|
Add that selection to your slip. Return nothing, or a result such as `{ status: 'added' }`,
|
|
120
121
|
`{ status: 'duplicate' }` or `{ status: 'rejected', reason }`. The widget shows "In slip" for an
|
|
@@ -126,11 +127,11 @@ What each one does:
|
|
|
126
127
|
`message` for a market that is suspended or closed on your side. "Add all" follows the same rule
|
|
127
128
|
when every leg comes back `closed` (your first `message`, else the neutral line); a mix of `closed`
|
|
128
129
|
and any other refusal keeps "Couldn't add to slip. Try again." because a retry may help.
|
|
129
|
-
- `slipSports`. Sports your `onAddToSlip` understands beyond football
|
|
130
|
+
- `slipSports`. Sports your `onAddToSlip` understands beyond football: `'basketball'`, `'americanfootball'` and `'tennis'`. A price for one of them is an "Add to
|
|
130
131
|
slip" button only when all three hold: the card arrives with the slip enabled for your operator
|
|
131
|
-
account (`addToSlipEnabled`), you set `onAddToSlip`, and `slipSports` includes
|
|
132
|
-
Otherwise the price is plain text. The selection then carries `sport
|
|
133
|
-
it: a basketball id can equal a football id. Keep `onAddToSlip` and `slipSports` referentially
|
|
132
|
+
account (`addToSlipEnabled`), you set `onAddToSlip`, and `slipSports` includes that sport.
|
|
133
|
+
Otherwise the price is plain text. The selection then carries that sport in `sport`, so branch on
|
|
134
|
+
it: a basketball id can equal a football id. NFL odds-card and insight-card selections close at kickoff: once the game has started, the widget refuses the add itself. Live fact prices on the NFL monitor card are in-play prices and still add. Keep `onAddToSlip` and `slipSports` referentially
|
|
134
135
|
stable, a module-level constant or a memoised value. The widget rebuilds its slip handling
|
|
135
136
|
whenever either changes identity, and an inline function or array literal changes it every render.
|
|
136
137
|
- `onOpenMatch` (deprecated). Ignored since 0.72.1: the widget no longer opens matches from any
|
|
@@ -140,7 +141,7 @@ What each one does:
|
|
|
140
141
|
leaves your slip for any reason, a "clear all" included. A leg the widget still believes is in
|
|
141
142
|
the slip can be reported as bet later.
|
|
142
143
|
- `betPlaced`. Pass every leg of the bet, with the leg's `sport` when you got one. The widget reports the legs it added itself, at most 25
|
|
143
|
-
per call, and ignores the rest, so you do not filter.
|
|
144
|
+
per call, and ignores the rest, so you do not filter. `stake`, `currency`, `betId`, `betType` and `totalOdds` are optional, and a field of the wrong type is dropped.
|
|
144
145
|
- `matchOpened`. Call it from your match page. A view counts only for a visitor who has opened the
|
|
145
146
|
widget in that tab, and at most once per match every 30 minutes.
|
|
146
147
|
|
|
@@ -148,8 +149,8 @@ Rules for the three host methods:
|
|
|
148
149
|
|
|
149
150
|
- `matchOddsId` and `matchId` are the numbers `onAddToSlip` gave you. Anything that is not a
|
|
150
151
|
positive integer is ignored, a numeric string included.
|
|
151
|
-
- `sport` is optional and
|
|
152
|
-
integrations are unchanged. Echo it back on `slipRemoved` and `betPlaced` for
|
|
152
|
+
- `sport` is optional and is a `SlipSport`: `'basketball'`, `'americanfootball'` or `'tennis'`. A football selection omits it, so existing
|
|
153
|
+
integrations are unchanged. Echo it back on `slipRemoved` and `betPlaced` for a non-football leg: a basketball
|
|
153
154
|
id and a football id can be equal, and `sport` tells the widget which row to clear.
|
|
154
155
|
- No method throws, and each is safe to call twice.
|
|
155
156
|
- A call made while no widget is mounted is queued, the last 20, and replayed when one mounts. The
|
|
@@ -218,6 +219,7 @@ Rules:
|
|
|
218
219
|
Without it the price is plain text and none fire.
|
|
219
220
|
- Prices in tracking events (`odds`, `total`) are always decimal numbers, whatever format the visitor sees or your
|
|
220
221
|
`oddsFormat` config sends to `onAddToSlip`.
|
|
222
|
+
- Before the panel opens, the launcher bubble shows a greeting line and, for the dynamic popup, one price.
|
|
221
223
|
- Tapping a question in the popup fires `bubble_ask_click` and also `dashboard_tile_click`. A static
|
|
222
224
|
`greeting` bubble fires `bubble_click` when tapped but never `bubble_shown`.
|
|
223
225
|
|
package/dist/index.cjs
CHANGED
|
@@ -1422,7 +1422,7 @@ function parseCustomTotal(text2, format2) {
|
|
|
1422
1422
|
}
|
|
1423
1423
|
|
|
1424
1424
|
// src/version.generated.ts
|
|
1425
|
-
var WIDGET_REACT_VERSION = "0.
|
|
1425
|
+
var WIDGET_REACT_VERSION = "0.165.1";
|
|
1426
1426
|
|
|
1427
1427
|
// src/config.ts
|
|
1428
1428
|
var COLOR_KEYS = ["accent", "cta", "surface", "ink"];
|
|
@@ -7487,14 +7487,64 @@ function evidenceText(f, ui) {
|
|
|
7487
7487
|
if (e.since) parts2.push(ui.liveFactSince(e.since));
|
|
7488
7488
|
return parts2.length > 0 ? parts2.join(" \xB7 ") : void 0;
|
|
7489
7489
|
}
|
|
7490
|
+
function secondLine(f, ui) {
|
|
7491
|
+
if (f.kind === "moment") return f.evidence && f.basis ? f.basis : void 0;
|
|
7492
|
+
return evidenceText(f, ui) ?? f.basis;
|
|
7493
|
+
}
|
|
7494
|
+
function Lead({ fact, match, ui, slip, sport, scope }) {
|
|
7495
|
+
const { oddsFormat } = useOddsSettings();
|
|
7496
|
+
const m = fact.market;
|
|
7497
|
+
const open = fact.marketState === "open" && !!m && !m.isSuspended;
|
|
7498
|
+
const chipPrice = m ? chipPriceText(m, oddsFormat) : void 0;
|
|
7499
|
+
const kickoff = fact.kickoffPrice != null && fact.kickoffPriceFormats ? ui.liveFactKickoff(formatOdds(fact.kickoffPriceFormats, oddsFormat)) : void 0;
|
|
7500
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
7501
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "ss-w-fact-text", children: fact.text }),
|
|
7502
|
+
secondLine(fact, ui) !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "ss-w-fact-basis", children: secondLine(fact, ui) }),
|
|
7503
|
+
m && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "ss-w-fact-mkt", children: [
|
|
7504
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "ss-w-fact-mkt-row", children: [
|
|
7505
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
|
|
7506
|
+
m.marketLabel,
|
|
7507
|
+
" \xB7 ",
|
|
7508
|
+
chipSelectionText(m)
|
|
7509
|
+
] }),
|
|
7510
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7511
|
+
SlipButton,
|
|
7512
|
+
{
|
|
7513
|
+
selection: slipOpenFor(slip, sport) ? chipSelection(m, match, slip.conversationId, scope) : null,
|
|
7514
|
+
marketDeveloperName: m.marketDeveloperName,
|
|
7515
|
+
selectionLabel: m.selectionLabel,
|
|
7516
|
+
slip,
|
|
7517
|
+
ui,
|
|
7518
|
+
fact: { id: fact.id, factKey: fact.factKey },
|
|
7519
|
+
price: { ariaLabel: `${chipSelectionText(m)}, ${chipPrice}`, valueClass: "ss-w-fact-price" }
|
|
7520
|
+
}
|
|
7521
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "ss-w-fact-state", children: fact.marketState === "held" ? ui.liveFactHeld : ui.liveFactSuspended })
|
|
7522
|
+
] }),
|
|
7523
|
+
kickoff && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "ss-w-fact-kick", children: kickoff })
|
|
7524
|
+
] })
|
|
7525
|
+
] });
|
|
7526
|
+
}
|
|
7527
|
+
function SecondLead({ sportFields, ...p }) {
|
|
7528
|
+
const ref = (0, import_react45.useRef)(null);
|
|
7529
|
+
const m = p.fact.market;
|
|
7530
|
+
const entity2 = m ? { entityType: "market", entityId: (0, import_widget_sdk21.qualifiedId)(p.sport, "market", m.marketDeveloperName), ...sportFields } : { entityType: "match", entityId: (0, import_widget_sdk21.qualifiedId)(p.sport, "game", (0, import_widget_sdk21.localIdOf)(p.sport, p.match.matchId, p.scope?.tour)), ...sportFields };
|
|
7531
|
+
useFactView(ref, p.fact, entity2);
|
|
7532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { ref, className: "ss-w-fact-lead2", children: [
|
|
7533
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "ss-w-fact-k", children: [
|
|
7534
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "ss-w-fact-min", children: p.fact.minuteLabel }),
|
|
7535
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "ss-w-fact-subj", children: p.fact.subjectLabel })
|
|
7536
|
+
] }),
|
|
7537
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Lead, { ...p })
|
|
7538
|
+
] });
|
|
7539
|
+
}
|
|
7490
7540
|
function LiveFactBlock({ facts, match, ui, slip, onAsk, scope }) {
|
|
7491
7541
|
const [expanded, setExpanded] = (0, import_react45.useState)(false);
|
|
7492
|
-
const { oddsFormat } = useOddsSettings();
|
|
7493
7542
|
const log = useEventLog();
|
|
7494
7543
|
const record2 = useRecord();
|
|
7495
7544
|
const sectionRef = (0, import_react45.useRef)(null);
|
|
7496
|
-
const current = facts.find((f) => f.marketState);
|
|
7497
|
-
const
|
|
7545
|
+
const current = facts.find((f) => f.kind === "moment" && f.marketState) ?? facts.find((f) => f.marketState);
|
|
7546
|
+
const secondLead = current?.kind === "moment" ? facts.find((f) => f !== current && f.kind === "moment" && f.marketState && f.market) : void 0;
|
|
7547
|
+
const earlier = facts.filter((f) => f.marketState && f !== current && f !== secondLead);
|
|
7498
7548
|
const background = facts.filter((f) => !f.marketState).slice(0, BACKGROUND_MAX);
|
|
7499
7549
|
const m = current?.market;
|
|
7500
7550
|
const sport = scope?.sport;
|
|
@@ -7503,9 +7553,6 @@ function LiveFactBlock({ facts, match, ui, slip, onAsk, scope }) {
|
|
|
7503
7553
|
const entity2 = current?.marketState && m ? { entityType: "market", entityId: (0, import_widget_sdk21.qualifiedId)(sport, "market", m.marketDeveloperName), ...sportFields } : { entityType: "match", entityId: (0, import_widget_sdk21.qualifiedId)(sport, "game", (0, import_widget_sdk21.localIdOf)(sport, match.matchId, scope?.tour)), ...sportFields };
|
|
7504
7554
|
useFactView(sectionRef, current, entity2);
|
|
7505
7555
|
if (facts.length === 0) return null;
|
|
7506
|
-
const open = current?.marketState === "open" && !!m && !m.isSuspended;
|
|
7507
|
-
const chipPrice = m ? chipPriceText(m, oddsFormat) : void 0;
|
|
7508
|
-
const kickoff = current?.kickoffPrice != null && current.kickoffPriceFormats ? ui.liveFactKickoff(formatOdds(current.kickoffPriceFormats, oddsFormat)) : void 0;
|
|
7509
7556
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SlipSurfaceProvider, { surface: "live_fact", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("section", { ref: sectionRef, className: "ss-w-fact", "aria-label": ui.liveFactLabel, children: [
|
|
7510
7557
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "ss-w-fact-k", children: [
|
|
7511
7558
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: ui.liveFactLabel }),
|
|
@@ -7516,30 +7563,8 @@ function LiveFactBlock({ facts, match, ui, slip, onAsk, scope }) {
|
|
|
7516
7563
|
current && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "ss-w-fact-subj", children: current.subjectLabel })
|
|
7517
7564
|
] }),
|
|
7518
7565
|
current && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
7519
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7520
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7521
|
-
m && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "ss-w-fact-mkt", children: [
|
|
7522
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "ss-w-fact-mkt-row", children: [
|
|
7523
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
|
|
7524
|
-
m.marketLabel,
|
|
7525
|
-
" \xB7 ",
|
|
7526
|
-
chipSelectionText(m)
|
|
7527
|
-
] }),
|
|
7528
|
-
open ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7529
|
-
SlipButton,
|
|
7530
|
-
{
|
|
7531
|
-
selection: slipOpenFor(slip, sport) ? chipSelection(m, match, slip.conversationId, scope) : null,
|
|
7532
|
-
marketDeveloperName: m.marketDeveloperName,
|
|
7533
|
-
selectionLabel: m.selectionLabel,
|
|
7534
|
-
slip,
|
|
7535
|
-
ui,
|
|
7536
|
-
fact: { id: current.id, factKey: current.factKey },
|
|
7537
|
-
price: { ariaLabel: `${chipSelectionText(m)}, ${chipPrice}`, valueClass: "ss-w-fact-price" }
|
|
7538
|
-
}
|
|
7539
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "ss-w-fact-state", children: current.marketState === "held" ? ui.liveFactHeld : ui.liveFactSuspended })
|
|
7540
|
-
] }),
|
|
7541
|
-
kickoff && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "ss-w-fact-kick", children: kickoff })
|
|
7542
|
-
] })
|
|
7566
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Lead, { fact: current, match, ui, slip, sport, scope }),
|
|
7567
|
+
secondLead && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SecondLead, { fact: secondLead, match, ui, slip, sport, scope, sportFields })
|
|
7543
7568
|
] }),
|
|
7544
7569
|
background.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("ul", { className: "ss-w-fact-bg", children: background.map((f) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { children: [
|
|
7545
7570
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "ss-w-fact-hmin", children: f.minuteLabel }),
|
|
@@ -7549,7 +7574,7 @@ function LiveFactBlock({ facts, match, ui, slip, onAsk, scope }) {
|
|
|
7549
7574
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "ss-w-fact-hmin", children: f.minuteLabel }),
|
|
7550
7575
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { children: [
|
|
7551
7576
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "ss-w-fact-htext", children: f.text }),
|
|
7552
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "ss-w-fact-basis", children:
|
|
7577
|
+
secondLine(f, ui) !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "ss-w-fact-basis", children: secondLine(f, ui) })
|
|
7553
7578
|
] })
|
|
7554
7579
|
] }, f.id)) }),
|
|
7555
7580
|
current && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "ss-w-fact-foot", children: [
|
|
@@ -22707,6 +22732,7 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
|
|
|
22707
22732
|
.ss-w-fact-subj { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 650; color: var(--ss-w-faint); }
|
|
22708
22733
|
.ss-w-fact-text { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ss-w-ink); }
|
|
22709
22734
|
.ss-w-fact-basis { font-size: 10.5px; color: var(--ss-w-faint); }
|
|
22735
|
+
.ss-w-fact-lead2 { display: flex; flex-direction: column; gap: 7px; min-width: 0; padding-top: 8px; border-top: 1px solid var(--ss-w-line); }
|
|
22710
22736
|
.ss-w-fact-mkt { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; border: 1px solid var(--ss-w-line); border-radius: 8px; padding: 6px 8px; }
|
|
22711
22737
|
.ss-w-fact-mkt-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
22712
22738
|
.ss-w-fact-mkt-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
|