@sensiblestats/widget-react 0.29.3 → 0.29.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.js CHANGED
@@ -839,7 +839,7 @@ function ChatFab({ label, greeting, popupText, onOpen, onDismissPopup, dismissLa
839
839
  }
840
840
 
841
841
  // src/components/ChatPanel.tsx
842
- import { useEffect as useEffect7, useState as useState12 } from "react";
842
+ import { useEffect as useEffect7, useState as useState13 } from "react";
843
843
 
844
844
  // src/components/ChatHeader.tsx
845
845
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
@@ -1432,17 +1432,20 @@ function resultClass(result) {
1432
1432
  function FormStrip({ form }) {
1433
1433
  return /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-form", children: form.map((r, i) => /* @__PURE__ */ jsx17("span", { className: `ss-w-fandash-form-pill ${resultClass(r)}`, children: r }, `${r}-${i}`)) });
1434
1434
  }
1435
- function FormRow({ name, form }) {
1435
+ function FormRow({ name, form, crestUrl }) {
1436
1436
  return /* @__PURE__ */ jsxs13("div", { className: "ss-w-fandash-formrow", children: [
1437
- /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-formrow-name", children: name }),
1437
+ /* @__PURE__ */ jsxs13("span", { className: "ss-w-fandash-formrow-team", children: [
1438
+ /* @__PURE__ */ jsx17(Crest2, { url: crestUrl ?? void 0, name, kind: "team" }),
1439
+ /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-formrow-name", children: name })
1440
+ ] }),
1438
1441
  /* @__PURE__ */ jsx17(FormStrip, { form })
1439
1442
  ] });
1440
1443
  }
1441
- function FixtureCard({ card, onTap }) {
1444
+ function FixtureCard({ card }) {
1442
1445
  const { data } = card;
1443
1446
  const h2h = data.h2H;
1444
1447
  return /* @__PURE__ */ jsxs13(Fragment5, { children: [
1445
- /* @__PURE__ */ jsxs13("button", { type: "button", className: "ss-w-fandash-card ss-w-fandash-card--tap ss-w-fandash-fixture", onClick: () => onTap(card), children: [
1448
+ /* @__PURE__ */ jsxs13("div", { className: "ss-w-fandash-card ss-w-fandash-fixture", children: [
1446
1449
  /* @__PURE__ */ jsxs13("span", { className: "ss-w-fandash-eyebrow", children: [
1447
1450
  card.title,
1448
1451
  " \xB7 ",
@@ -1460,22 +1463,18 @@ function FixtureCard({ card, onTap }) {
1460
1463
  ] })
1461
1464
  ] }),
1462
1465
  /* @__PURE__ */ jsxs13("div", { className: "ss-w-fandash-fixture-meta", children: [
1463
- /* @__PURE__ */ jsxs13("div", { className: "ss-w-fandash-fixture-metarow", children: [
1464
- /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-fixture-metakey", children: data.dateLabel }),
1465
- /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-fixture-metaval", children: data.kickoffLabel })
1466
- ] }),
1467
- data.venue ? /* @__PURE__ */ jsxs13("div", { className: "ss-w-fandash-fixture-metarow", children: [
1468
- /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-fixture-metakey", children: data.venueLabel }),
1469
- /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-fixture-metaval", children: data.venue })
1466
+ /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-fixture-kickoff", children: data.kickoffLabel }),
1467
+ data.venue ? /* @__PURE__ */ jsxs13("span", { className: "ss-w-fandash-fixture-venue", children: [
1468
+ " \xB7 ",
1469
+ data.venue
1470
1470
  ] }) : null
1471
- ] }),
1472
- /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-card-cta", children: card.actionLabel })
1471
+ ] })
1473
1472
  ] }),
1474
1473
  /* @__PURE__ */ jsxs13("div", { className: "ss-w-fandash-card ss-w-fandash-lastfive", children: [
1475
1474
  /* @__PURE__ */ jsx17("span", { className: "ss-w-fandash-eyebrow", children: data.formLabel }),
1476
1475
  /* @__PURE__ */ jsxs13("div", { className: "ss-w-fandash-fixture-form", children: [
1477
- /* @__PURE__ */ jsx17(FormRow, { name: data.homeName, form: data.homeForm }),
1478
- /* @__PURE__ */ jsx17(FormRow, { name: data.awayName, form: data.awayForm })
1476
+ /* @__PURE__ */ jsx17(FormRow, { name: data.homeName, form: data.homeForm, crestUrl: data.homeCrestUrl }),
1477
+ /* @__PURE__ */ jsx17(FormRow, { name: data.awayName, form: data.awayForm, crestUrl: data.awayCrestUrl })
1479
1478
  ] })
1480
1479
  ] }),
1481
1480
  h2h || data.fact ? /* @__PURE__ */ jsxs13("div", { className: "ss-w-fandash-card ss-w-fandash-h2h", children: [
@@ -1545,16 +1544,19 @@ function CountdownCard({ card }) {
1545
1544
  }
1546
1545
 
1547
1546
  // src/components/dashboard/InjuriesCard.tsx
1547
+ import { useState as useState7 } from "react";
1548
1548
  import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
1549
+ var SHOWN = 3;
1549
1550
  function ColHead({ name, crestUrl }) {
1550
1551
  return /* @__PURE__ */ jsxs15("span", { className: "ss-w-fandash-injuries-col-head", children: [
1551
1552
  /* @__PURE__ */ jsx19(Crest2, { url: crestUrl ?? void 0, name, kind: "team" }),
1552
1553
  /* @__PURE__ */ jsx19("span", { className: "ss-w-fandash-injuries-col-head-name", children: name })
1553
1554
  ] });
1554
1555
  }
1555
- function InjuryList({ rows, emptyLabel }) {
1556
+ function InjuryList({ rows, emptyLabel, limit }) {
1556
1557
  if (rows.length === 0) return /* @__PURE__ */ jsx19("span", { className: "ss-w-fandash-injuries-empty", children: emptyLabel });
1557
- return /* @__PURE__ */ jsx19("ul", { className: "ss-w-fandash-injury-list", children: rows.map((r, i) => /* @__PURE__ */ jsxs15("li", { className: "ss-w-fandash-injury-row", children: [
1558
+ const shown = limit === void 0 ? rows : rows.slice(0, limit);
1559
+ return /* @__PURE__ */ jsx19("ul", { className: "ss-w-fandash-injury-list", children: shown.map((r, i) => /* @__PURE__ */ jsxs15("li", { className: "ss-w-fandash-injury-row", children: [
1558
1560
  /* @__PURE__ */ jsx19("span", { className: "ss-w-fandash-injury-name", children: r.playerName }),
1559
1561
  /* @__PURE__ */ jsxs15("span", { className: "ss-w-fandash-injury-meta", children: [
1560
1562
  /* @__PURE__ */ jsx19("span", { className: "ss-w-fandash-injury-status", children: r.status }),
@@ -1563,21 +1565,36 @@ function InjuryList({ rows, emptyLabel }) {
1563
1565
  ] })
1564
1566
  ] }, `${r.playerName}-${i}`)) });
1565
1567
  }
1566
- function InjuriesCard({ card }) {
1568
+ function InjuriesCard({ card, ui }) {
1567
1569
  const { data } = card;
1570
+ const [expanded, setExpanded] = useState7(false);
1571
+ const hidden = Math.max(0, data.ours.length - SHOWN) + Math.max(0, data.theirs.length - SHOWN);
1572
+ const limit = expanded ? void 0 : SHOWN;
1573
+ const showMore = ui?.showMore ?? ((n) => `Show ${n} more`);
1574
+ const showLess = ui?.showLess ?? "Show less";
1568
1575
  return /* @__PURE__ */ jsxs15("div", { className: "ss-w-fandash-card ss-w-fandash-injuries", children: [
1569
1576
  card.title ? /* @__PURE__ */ jsx19("span", { className: "ss-w-fandash-eyebrow", children: card.title }) : null,
1570
1577
  /* @__PURE__ */ jsxs15("div", { className: "ss-w-fandash-injuries-cols", children: [
1571
1578
  /* @__PURE__ */ jsxs15("div", { className: "ss-w-fandash-injuries-col", children: [
1572
1579
  /* @__PURE__ */ jsx19(ColHead, { name: data.oursName, crestUrl: data.oursCrestUrl }),
1573
- /* @__PURE__ */ jsx19(InjuryList, { rows: data.ours, emptyLabel: data.emptyLabel })
1580
+ /* @__PURE__ */ jsx19(InjuryList, { rows: data.ours, emptyLabel: data.emptyLabel, limit })
1574
1581
  ] }),
1575
1582
  /* @__PURE__ */ jsx19("div", { className: "ss-w-fandash-injuries-divider" }),
1576
1583
  /* @__PURE__ */ jsxs15("div", { className: "ss-w-fandash-injuries-col", children: [
1577
1584
  /* @__PURE__ */ jsx19(ColHead, { name: data.theirsName, crestUrl: data.theirsCrestUrl }),
1578
- /* @__PURE__ */ jsx19(InjuryList, { rows: data.theirs, emptyLabel: data.emptyLabel })
1585
+ /* @__PURE__ */ jsx19(InjuryList, { rows: data.theirs, emptyLabel: data.emptyLabel, limit })
1579
1586
  ] })
1580
- ] })
1587
+ ] }),
1588
+ hidden > 0 ? /* @__PURE__ */ jsx19(
1589
+ "button",
1590
+ {
1591
+ type: "button",
1592
+ className: "ss-w-fandash-injuries-more",
1593
+ "aria-expanded": expanded,
1594
+ onClick: () => setExpanded((v) => !v),
1595
+ children: expanded ? showLess : showMore(hidden)
1596
+ }
1597
+ ) : null
1581
1598
  ] });
1582
1599
  }
1583
1600
 
@@ -1654,7 +1671,7 @@ function LinksCard({ card }) {
1654
1671
  }
1655
1672
 
1656
1673
  // src/components/dashboard/PostMatchResultCard.tsx
1657
- import { useState as useState7 } from "react";
1674
+ import { useState as useState8 } from "react";
1658
1675
  import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
1659
1676
  function initials3(name) {
1660
1677
  return name.trim().slice(0, 3).toUpperCase();
@@ -1664,7 +1681,7 @@ function PostMatchCrest({
1664
1681
  name,
1665
1682
  side
1666
1683
  }) {
1667
- const [failed, setFailed] = useState7(false);
1684
+ const [failed, setFailed] = useState8(false);
1668
1685
  const cls = `ss-w-fandash-postmatch-crest ss-w-fandash-postmatch-crest--${side}`;
1669
1686
  if (url && !failed) {
1670
1687
  return /* @__PURE__ */ jsx25("img", { className: cls, src: url, alt: "", "aria-hidden": "true", onError: () => setFailed(true) });
@@ -1863,10 +1880,10 @@ function RestingFormCard({ card }) {
1863
1880
  }
1864
1881
 
1865
1882
  // src/components/dashboard/LiveScoreCard.tsx
1866
- import { useRef as useRef3, useState as useState9 } from "react";
1883
+ import { useRef as useRef3, useState as useState10 } from "react";
1867
1884
 
1868
1885
  // src/useLiveClock.ts
1869
- import { useEffect as useEffect5, useState as useState8 } from "react";
1886
+ import { useEffect as useEffect5, useState as useState9 } from "react";
1870
1887
  var TICK_MS = 6e4;
1871
1888
  var MAX_LIVE_TICK_MINUTES = 15;
1872
1889
  function computeDisplayMinute(minute, clockRunning, receivedAtMs) {
@@ -1875,7 +1892,7 @@ function computeDisplayMinute(minute, clockRunning, receivedAtMs) {
1875
1892
  return minute + Math.min(Math.max(0, elapsedMinutes), MAX_LIVE_TICK_MINUTES);
1876
1893
  }
1877
1894
  function useLiveClock(minute, clockRunning, receivedAtMs) {
1878
- const [displayMinute, setDisplayMinute] = useState8(
1895
+ const [displayMinute, setDisplayMinute] = useState9(
1879
1896
  () => computeDisplayMinute(minute, clockRunning, receivedAtMs)
1880
1897
  );
1881
1898
  useEffect5(() => {
@@ -1895,7 +1912,7 @@ function initials5(name) {
1895
1912
  return name.trim().slice(0, 3).toUpperCase();
1896
1913
  }
1897
1914
  function LiveCrest({ url, name, side }) {
1898
- const [failed, setFailed] = useState9(false);
1915
+ const [failed, setFailed] = useState10(false);
1899
1916
  const cls = `ss-w-fandash-live-crest ss-w-fandash-live-crest--${side}`;
1900
1917
  if (url && !failed) {
1901
1918
  return /* @__PURE__ */ jsx34("img", { className: cls, src: url, alt: "", "aria-hidden": "true", onError: () => setFailed(true) });
@@ -1954,9 +1971,9 @@ function LiveScoreCard({
1954
1971
  }
1955
1972
 
1956
1973
  // src/components/dashboard/LiveTimelineCard.tsx
1957
- import { useState as useState10 } from "react";
1974
+ import { useState as useState11 } from "react";
1958
1975
  import { jsx as jsx35, jsxs as jsxs31 } from "react/jsx-runtime";
1959
- var SHOWN = 3;
1976
+ var SHOWN2 = 3;
1960
1977
  function EventIcon({ type }) {
1961
1978
  if (type === "goal") {
1962
1979
  return /* @__PURE__ */ jsx35("span", { className: "ss-w-fandash-live-tl-ico ss-w-fandash-live-tl-ico--goal", "aria-hidden": "true", children: /* @__PURE__ */ jsx35("span", { className: "ss-w-fandash-live-tl-ball" }) });
@@ -1996,12 +2013,12 @@ function EventRow({ e }) {
1996
2013
  ] });
1997
2014
  }
1998
2015
  function LiveTimelineCard({ card, ui }) {
1999
- const [expanded, setExpanded] = useState10(false);
2016
+ const [expanded, setExpanded] = useState11(false);
2000
2017
  const events = card.data.events;
2001
2018
  if (!events || events.length === 0) return null;
2002
2019
  const sorted = [...events].sort((a, b) => b.minute - a.minute);
2003
- const rest = sorted.length - SHOWN;
2004
- const shown = expanded ? sorted : sorted.slice(0, SHOWN);
2020
+ const rest = sorted.length - SHOWN2;
2021
+ const shown = expanded ? sorted : sorted.slice(0, SHOWN2);
2005
2022
  const showMore = ui?.showMore ?? ((n) => `Show ${n} more`);
2006
2023
  const showLess = ui?.showLess ?? "Show less";
2007
2024
  return /* @__PURE__ */ jsxs31("div", { className: "ss-w-fandash-card ss-w-fandash-live-timeline", children: [
@@ -2138,11 +2155,11 @@ function ClubFanDashboard({ dashboard, onTap, ui }) {
2138
2155
  function FanDashboardCard({ card, onTap, ui, goalEvents }) {
2139
2156
  switch (card.cardType) {
2140
2157
  case "fixture":
2141
- return /* @__PURE__ */ jsx38(FixtureCard, { card, onTap });
2158
+ return /* @__PURE__ */ jsx38(FixtureCard, { card });
2142
2159
  case "countdown":
2143
2160
  return /* @__PURE__ */ jsx38(CountdownCard, { card });
2144
2161
  case "injuries":
2145
- return /* @__PURE__ */ jsx38(InjuriesCard, { card });
2162
+ return /* @__PURE__ */ jsx38(InjuriesCard, { card, ui });
2146
2163
  case "reasonToBet":
2147
2164
  return /* @__PURE__ */ jsx38(ReasonToBetCard, { card });
2148
2165
  case "whereToWatch":
@@ -2285,10 +2302,10 @@ function MessageList({ controller, ui, slip, onDashboardTap }) {
2285
2302
  }
2286
2303
 
2287
2304
  // src/components/ChatInput.tsx
2288
- import { useState as useState11 } from "react";
2305
+ import { useState as useState12 } from "react";
2289
2306
  import { jsx as jsx42, jsxs as jsxs37 } from "react/jsx-runtime";
2290
2307
  function ChatInput({ placeholder, streaming, onSend, onStop, stopLabel = "Stop response", sendLabel = "Send message" }) {
2291
- const [value, setValue] = useState11("");
2308
+ const [value, setValue] = useState12("");
2292
2309
  const submit = () => {
2293
2310
  const t = value.trim();
2294
2311
  if (!t) return;
@@ -2311,7 +2328,7 @@ function ChatInput({ placeholder, streaming, onSend, onStop, stopLabel = "Stop r
2311
2328
  import { jsx as jsx43, jsxs as jsxs38 } from "react/jsx-runtime";
2312
2329
  var FULLSCREEN_QUERY = "(max-width: 639px)";
2313
2330
  function useIsModal() {
2314
- const [modal, setModal] = useState12(false);
2331
+ const [modal, setModal] = useState13(false);
2315
2332
  useEffect7(() => {
2316
2333
  if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
2317
2334
  const mql = window.matchMedia(FULLSCREEN_QUERY);
@@ -2738,10 +2755,9 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
2738
2755
  .ss-w-fandash-fixture-team--away .ss-w-fandash-fixture-name { text-align: right; }
2739
2756
  .ss-w-fandash-fixture-vs { flex: none; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ss-w-faint); }
2740
2757
  /* date + venue as labelled rows, so a long stadium name gets its own line to ellipsis in */
2741
- .ss-w-fandash-fixture-meta { display: flex; flex-direction: column; gap: 1px; border-top: 1px solid var(--ss-w-line); padding-top: 8px; }
2742
- .ss-w-fandash-fixture-metarow { display: flex; align-items: baseline; gap: 9px; }
2743
- .ss-w-fandash-fixture-metakey { flex: none; width: 44px; font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ss-w-faint); }
2744
- .ss-w-fandash-fixture-metaval { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--ss-w-ink); }
2758
+ .ss-w-fandash-fixture-meta { border-top: 1px solid var(--ss-w-line); padding-top: 10px; text-align: center; font-size: 12.5px; color: var(--ss-w-faint); }
2759
+ .ss-w-fandash-fixture-kickoff { font-weight: 700; color: var(--ss-w-ink); }
2760
+ .ss-w-fandash-fixture-venue { font-weight: 600; }
2745
2761
  .ss-w-fandash-fact { font-size: 12px; color: var(--ss-w-ink); background: var(--ss-w-bubble); border-radius: 8px; padding: 6px 8px; }
2746
2762
  /* each head-to-head figure sits on its own shaded tile, so the grid gap separates wins/draws/losses */
2747
2763
  .ss-w-fandash-h2h .ss-w-fandash-split-cell { background: var(--ss-w-bubble); border-radius: 10px; padding: 12px 6px; }
@@ -2751,7 +2767,12 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
2751
2767
  /* last-five: one row per side, team name left, form pills right */
2752
2768
  .ss-w-fandash-fixture-form { display: flex; flex-direction: column; gap: 5px; }
2753
2769
  .ss-w-fandash-formrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
2770
+ .ss-w-fandash-formrow-team { display: flex; align-items: center; gap: 8px; min-width: 0; }
2771
+ .ss-w-fandash-formrow-team .ss-w-bi-crest { width: 20px; height: 20px; }
2772
+ .ss-w-fandash-formrow-team .ss-w-bi-crest-mono { font-size: 9px; }
2754
2773
  .ss-w-fandash-formrow-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
2774
+ .ss-w-fandash-injuries-more { margin-top: 10px; width: 100%; background: var(--ss-w-bubble); border: 1px solid var(--ss-w-line); border-radius: 9px; padding: 7px; font: inherit; font-size: 11.5px; font-weight: 700; color: var(--ss-w-accent); cursor: pointer; }
2775
+ .ss-w-fandash-injuries-more:focus-visible { outline: 2px solid var(--ss-w-accent); outline-offset: 2px; }
2755
2776
  .ss-w-fandash-form { display: inline-flex; gap: 3px; flex: none; }
2756
2777
  .ss-w-fandash-form-pill {
2757
2778
  display: inline-grid; place-items: center; width: 16px; height: 16px;