@sensiblestats/widget-react 0.124.3 → 0.125.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/dist/index.js CHANGED
@@ -824,7 +824,13 @@ var BUNDLED_EN_GB = {
824
824
  "widget.tennis.movedSince": "Moved since {date}",
825
825
  "widget.tennis.unchangedSince": "Unchanged since {date}",
826
826
  "widget.tennis.updated": "updated {time}",
827
- "widget.tennis.vs": "vs"
827
+ "widget.tennis.vs": "vs",
828
+ "widget.tennis.favKindPlayer": "player",
829
+ "widget.tennis.favKindTournament": "tournament",
830
+ "widget.tennis.favPlayers": "Tennis players",
831
+ "widget.tennis.favTournaments": "Tennis tournaments",
832
+ "widget.tennis.favSearchPlaceholder": "Search a player or tournament",
833
+ "widget.tennis.favEmpty": "Tap a player or tournament and this page builds around it."
828
834
  };
829
835
 
830
836
  // src/strings/fill.ts
@@ -1179,7 +1185,7 @@ function parseOddsFormat(value) {
1179
1185
  }
1180
1186
 
1181
1187
  // src/version.generated.ts
1182
- var WIDGET_REACT_VERSION = "0.124.3";
1188
+ var WIDGET_REACT_VERSION = "0.125.0";
1183
1189
 
1184
1190
  // src/config.ts
1185
1191
  function hostTag(cfg) {
@@ -6493,11 +6499,23 @@ function FavouritesInvite({ ui, onOpen }) {
6493
6499
 
6494
6500
  // src/components/dashboard/v8/useFollow.ts
6495
6501
  import { useState as useState25 } from "react";
6502
+
6503
+ // src/favouriteKinds.ts
6504
+ function favouriteKinds(sport) {
6505
+ if (sport === "football") return ["competition", "team", "player"];
6506
+ if (sport === "tennis") return ["competition", "player"];
6507
+ return ["team", "player"];
6508
+ }
6509
+ var hasCompetitions = (sport) => favouriteKinds(sport).includes("competition");
6510
+ var hasTeams = (sport) => favouriteKinds(sport).includes("team");
6511
+ function favouriteKindLabel(ui, sport, kind) {
6512
+ if (sport === "tennis") return kind === "competition" ? ui.tennis.favKindTournament : ui.tennis.favKindPlayer;
6513
+ return kind === "competition" ? ui.favKindLeague : kind === "team" ? ui.favKindTeam : ui.favKindPlayer;
6514
+ }
6515
+
6516
+ // src/components/dashboard/v8/useFollow.ts
6496
6517
  var isFavouriteKind = (kind) => kind === "team" || kind === "player" || kind === "competition";
6497
6518
  var keyOf2 = (sport, t) => `${sport}:${t.kind}:${t.id}`;
6498
- function kindLabel(kind, ui) {
6499
- return kind === "competition" ? ui.favKindLeague : kind === "player" ? ui.favKindPlayer : ui.favKindTeam;
6500
- }
6501
6519
  function useFollow(controller, ui, holds, sport) {
6502
6520
  const [notice, setNotice] = useState25(null);
6503
6521
  const isOpen = (t) => isFavouriteKind(t.kind) && !holds.followed.has(keyOf2(sport, t)) && !controller.isStarred(t.kind, t.id);
@@ -6506,7 +6524,7 @@ function useFollow(controller, ui, holds, sport) {
6506
6524
  setNotice(null);
6507
6525
  const outcome = await controller.toggle(t.kind, t.id);
6508
6526
  if (outcome === "starred") holds.follow(keyOf2(sport, t));
6509
- else if (outcome === "at_cap") setNotice(ui.favAtCap(kindLabel(t.kind, ui)));
6527
+ else if (outcome === "at_cap") setNotice(ui.favAtCap(favouriteKindLabel(ui, sport, t.kind)));
6510
6528
  else if (outcome === "failed" || outcome === "unstarred") setNotice(ui.favError);
6511
6529
  };
6512
6530
  return { isOpen, follow, ready: controller.status === "ready", notice };
@@ -6520,7 +6538,7 @@ function FollowSuggestions({ chips, ui, controller, holds, sport }) {
6520
6538
  if (open.length === 0) return null;
6521
6539
  return /* @__PURE__ */ jsxs15("section", { className: "ss-w-v8-sec ss-w-v8-pick", children: [
6522
6540
  /* @__PURE__ */ jsx17("b", { className: "ss-w-v8-pick-title", children: ui.v8FollowWho }),
6523
- /* @__PURE__ */ jsx17("p", { className: "ss-w-v8-pick-line", children: ui.favEmpty }),
6541
+ /* @__PURE__ */ jsx17("p", { className: "ss-w-v8-pick-line", children: sport === "tennis" ? ui.tennis.favEmpty : ui.favEmpty }),
6524
6542
  /* @__PURE__ */ jsx17("div", { className: "ss-w-v8-chips", children: open.map((chip) => /* @__PURE__ */ jsxs15("button", { type: "button", className: "ss-w-v8-chip ss-w-v8-star", "aria-label": ui.favStar(chip.label), disabled: !ready, onClick: () => {
6525
6543
  void follow(chip);
6526
6544
  }, children: [
@@ -9630,7 +9648,7 @@ function FanDashboardCard({ card, onTap, ui, goalEvents }) {
9630
9648
 
9631
9649
  // src/components/ChatMessage.tsx
9632
9650
  import { jsx as jsx63, jsxs as jsxs59 } from "react/jsx-runtime";
9633
- function ChatMessage({ message, disabled, onAct, onTap, ui, slip, monitor }) {
9651
+ function ChatMessage({ message, disabled, onAct, onTap, ui, slip, monitor, onGreetingSport }) {
9634
9652
  const [sport, setSport] = useState42(null);
9635
9653
  if (message.role === "user") {
9636
9654
  return /* @__PURE__ */ jsx63("div", { className: "ss-w-msg ss-w-user", "data-msg-id": message.id, children: /* @__PURE__ */ jsx63("div", { className: "ss-w-bubble", children: message.text }) });
@@ -9644,7 +9662,10 @@ function ChatMessage({ message, disabled, onAct, onTap, ui, slip, monitor }) {
9644
9662
  const actions = setChips ? setChips.map((c) => toActionVM({ ...c })) : message.actions;
9645
9663
  return /* @__PURE__ */ jsxs59("div", { className: "ss-w-msg ss-w-bot", "data-msg-id": message.id, children: [
9646
9664
  message.text && !message.greetingDashboard && !message.clubFanDashboard ? /* @__PURE__ */ jsx63(Markdown, { text: message.text }) : null,
9647
- message.greetingDashboard && !message.clubFanDashboard ? /* @__PURE__ */ jsx63(GreetingDashboard, { dashboard: message.greetingDashboard, dashboards: message.greetingDashboards, defaultSport: message.defaultSport, onTap, onSportChange: setSport, ui, slip, onAct }) : null,
9665
+ message.greetingDashboard && !message.clubFanDashboard ? /* @__PURE__ */ jsx63(GreetingDashboard, { dashboard: message.greetingDashboard, dashboards: message.greetingDashboards, defaultSport: message.defaultSport, onTap, onSportChange: (s) => {
9666
+ setSport(s);
9667
+ onGreetingSport?.(s);
9668
+ }, ui, slip, onAct }) : null,
9648
9669
  message.clubFanDashboard ? /* @__PURE__ */ jsx63(ClubFanDashboard, { dashboard: message.clubFanDashboard, onTap: onFanDashboardTap, ui }) : null,
9649
9670
  /* @__PURE__ */ jsx63(EntityCardList, { cards: message.cards, disabled, showLessLabel: ui.showLess, showMoreLabel: ui.showMore }),
9650
9671
  /* @__PURE__ */ jsx63(BettingInsightList, { insights: message.insights, ui, slip, monitor }),
@@ -9678,7 +9699,7 @@ function turnAnchor(messages) {
9678
9699
  const prev = messages[messages.length - 2];
9679
9700
  return { turnId: last.id, anchorId: prev && prev.role === "user" ? prev.id : last.id };
9680
9701
  }
9681
- function MessageList({ controller, ui, slip, onDashboardTap, monitor }) {
9702
+ function MessageList({ controller, ui, slip, onDashboardTap, monitor, onGreetingSport }) {
9682
9703
  const { state, send } = controller;
9683
9704
  const { oddsFormat } = useOddsSettings();
9684
9705
  const listRef = useRef25(null);
@@ -9724,7 +9745,8 @@ function MessageList({ controller, ui, slip, onDashboardTap, monitor }) {
9724
9745
  },
9725
9746
  ui,
9726
9747
  slip,
9727
- monitor
9748
+ monitor,
9749
+ onGreetingSport
9728
9750
  },
9729
9751
  m.id
9730
9752
  )),
@@ -15663,8 +15685,9 @@ function FavCrest({ entity: entity2, sport }) {
15663
15685
  const url = sport === "football" && entity2.kind !== "player" ? entity2.imageUrl : void 0;
15664
15686
  return /* @__PURE__ */ jsx132(Crest, { url, name: entity2.name, kind: entity2.kind === "competition" ? "comp" : "team" });
15665
15687
  }
15666
- function PlayerTeam({ entity: entity2, ui }) {
15688
+ function PlayerTeam({ entity: entity2, ui, sport }) {
15667
15689
  if (entity2.kind !== "player") return null;
15690
+ if (sport === "tennis") return entity2.teamName ? /* @__PURE__ */ jsx132("span", { className: "ss-w-fav-sub", children: entity2.teamName }) : null;
15668
15691
  return /* @__PURE__ */ jsx132("span", { className: "ss-w-fav-sub", children: entity2.teamName || ui.favNoTeam });
15669
15692
  }
15670
15693
  function Chip2({ entity: entity2, sport, ui, busy, onRemove }) {
@@ -15672,7 +15695,7 @@ function Chip2({ entity: entity2, sport, ui, busy, onRemove }) {
15672
15695
  /* @__PURE__ */ jsx132(FavCrest, { entity: entity2, sport }),
15673
15696
  /* @__PURE__ */ jsxs117("span", { className: "ss-w-fav-name", children: [
15674
15697
  /* @__PURE__ */ jsx132("span", { className: "ss-w-fav-title", children: entity2.name }),
15675
- /* @__PURE__ */ jsx132(PlayerTeam, { entity: entity2, ui })
15698
+ /* @__PURE__ */ jsx132(PlayerTeam, { entity: entity2, ui, sport })
15676
15699
  ] }),
15677
15700
  /* @__PURE__ */ jsx132("button", { type: "button", className: "ss-w-fav-x", "aria-label": ui.favRemove(entity2.name), disabled: busy, onClick: onRemove, children: "\xD7" })
15678
15701
  ] });
@@ -15718,17 +15741,17 @@ function FavouriteChips({ controller, ui, sport, sportLabel: sportLabel2, onNoti
15718
15741
  else onNotice(null);
15719
15742
  };
15720
15743
  return /* @__PURE__ */ jsxs117(Fragment38, { children: [
15721
- total === 0 ? /* @__PURE__ */ jsx132("p", { className: "ss-w-fav-empty", children: ui.favEmpty }) : null,
15722
- sport === "football" ? /* @__PURE__ */ jsx132(Group, { title: ui.favLeagues, entities: data.competitions, sport, ui, controller, onNotice }) : null,
15723
- /* @__PURE__ */ jsx132(Group, { title: ui.favTeams, entities: data.teams, sport, ui, controller, onNotice }),
15724
- /* @__PURE__ */ jsx132(Group, { title: ui.favPlayers, entities: data.players, sport, ui, controller, onNotice }),
15744
+ total === 0 ? /* @__PURE__ */ jsx132("p", { className: "ss-w-fav-empty", children: sport === "tennis" ? ui.tennis.favEmpty : ui.favEmpty }) : null,
15745
+ hasCompetitions(sport) ? /* @__PURE__ */ jsx132(Group, { title: sport === "tennis" ? ui.tennis.favTournaments : ui.favLeagues, entities: data.competitions, sport, ui, controller, onNotice }) : null,
15746
+ hasTeams(sport) ? /* @__PURE__ */ jsx132(Group, { title: ui.favTeams, entities: data.teams, sport, ui, controller, onNotice }) : null,
15747
+ /* @__PURE__ */ jsx132(Group, { title: sport === "tennis" ? ui.tennis.favPlayers : ui.favPlayers, entities: data.players, sport, ui, controller, onNotice }),
15725
15748
  data.suggestions.length > 0 ? /* @__PURE__ */ jsxs117("section", { className: "ss-w-fav-group", children: [
15726
15749
  /* @__PURE__ */ jsx132("h3", { className: "ss-w-fav-h", children: ui.favFromActivity }),
15727
15750
  /* @__PURE__ */ jsx132("ul", { className: "ss-w-fav-chips", children: data.suggestions.map((e) => /* @__PURE__ */ jsxs117("li", { className: "ss-w-fav-chip ss-w-fav-chip--suggest", children: [
15728
15751
  /* @__PURE__ */ jsx132(FavCrest, { entity: e, sport }),
15729
15752
  /* @__PURE__ */ jsxs117("span", { className: "ss-w-fav-name", children: [
15730
15753
  /* @__PURE__ */ jsx132("span", { className: "ss-w-fav-title", children: e.name }),
15731
- /* @__PURE__ */ jsx132(PlayerTeam, { entity: e, ui })
15754
+ /* @__PURE__ */ jsx132(PlayerTeam, { entity: e, ui, sport })
15732
15755
  ] }),
15733
15756
  /* @__PURE__ */ jsx132(
15734
15757
  "button",
@@ -15774,7 +15797,7 @@ function FavouritesSearch({ controller, ui, sport, onNotice }) {
15774
15797
  setAnswer(null);
15775
15798
  if (trimmed.length < MIN_LETTERS) return;
15776
15799
  let cancelled = false;
15777
- const kinds = sport === "football" ? ["competition", "team", "player"] : ["team", "player"];
15800
+ const kinds = favouriteKinds(sport);
15778
15801
  const timer = setTimeout(() => {
15779
15802
  void Promise.all(kinds.map((k) => controllerRef.current.search(trimmed, k))).then((lists) => {
15780
15803
  if (cancelled) return;
@@ -15786,6 +15809,7 @@ function FavouritesSearch({ controller, ui, sport, onNotice }) {
15786
15809
  clearTimeout(timer);
15787
15810
  };
15788
15811
  }, [trimmed, sport, queryKey]);
15812
+ const placeholder = sport === "tennis" ? ui.tennis.favSearchPlaceholder : ui.favSearchPlaceholder;
15789
15813
  return /* @__PURE__ */ jsxs118("div", { className: "ss-w-fav-search", children: [
15790
15814
  /* @__PURE__ */ jsx133(
15791
15815
  "input",
@@ -15794,8 +15818,8 @@ function FavouritesSearch({ controller, ui, sport, onNotice }) {
15794
15818
  className: "ss-w-fav-input",
15795
15819
  value: query,
15796
15820
  maxLength: MAX_LENGTH,
15797
- placeholder: ui.favSearchPlaceholder,
15798
- "aria-label": ui.favSearchPlaceholder,
15821
+ placeholder,
15822
+ "aria-label": placeholder,
15799
15823
  autoComplete: "off",
15800
15824
  onChange: (e) => setQuery(e.target.value)
15801
15825
  }
@@ -15808,7 +15832,7 @@ function FavouritesSearch({ controller, ui, sport, onNotice }) {
15808
15832
  /* @__PURE__ */ jsx133(FavCrest, { entity: e, sport }),
15809
15833
  /* @__PURE__ */ jsxs118("span", { className: "ss-w-fav-name", children: [
15810
15834
  /* @__PURE__ */ jsx133("span", { className: "ss-w-fav-title", children: e.name }),
15811
- e.kind === "player" ? /* @__PURE__ */ jsx133(PlayerTeam, { entity: e, ui }) : /* @__PURE__ */ jsx133("span", { className: "ss-w-fav-kind", children: e.kind === "competition" ? ui.favKindLeague : ui.favKindTeam })
15835
+ e.kind === "player" ? /* @__PURE__ */ jsx133(PlayerTeam, { entity: e, ui, sport }) : /* @__PURE__ */ jsx133("span", { className: "ss-w-fav-kind", children: favouriteKindLabel(ui, sport, e.kind) })
15812
15836
  ] }),
15813
15837
  /* @__PURE__ */ jsx133(
15814
15838
  "button",
@@ -15842,8 +15866,7 @@ function FavouritesPanel({ controller, ui, sport, sports, onSportChange }) {
15842
15866
  setNotice(null);
15843
15867
  }, [sport]);
15844
15868
  const sportLabel2 = sports.find((s) => s.sport === sport)?.label ?? sportLabel(ui, sport);
15845
- const kindLabel2 = (kind) => kind === "competition" ? ui.favKindLeague : kind === "team" ? ui.favKindTeam : ui.favKindPlayer;
15846
- const noticeText = notice === null ? null : notice.type === "cap" ? ui.favAtCap(kindLabel2(notice.kind)) : ui.favError;
15869
+ const noticeText = notice === null ? null : notice.type === "cap" ? ui.favAtCap(favouriteKindLabel(ui, sport, notice.kind)) : ui.favError;
15847
15870
  return /* @__PURE__ */ jsxs119("div", { className: "ss-w-mon-list ss-w-fav", children: [
15848
15871
  sports.length > 1 ? /* @__PURE__ */ jsx134("div", { className: "ss-w-dash-sports", role: "group", "aria-label": ui.sportGroupLabel, children: sports.map((s) => /* @__PURE__ */ jsx134(
15849
15872
  "button",
@@ -16943,7 +16966,7 @@ function ChatPanel({ controller, ui, slip, onDashboardTap, monitor, discovery, s
16943
16966
  }
16944
16967
  ),
16945
16968
  /* @__PURE__ */ jsxs130("div", { className: "ss-w-chat-layer", style: onChatTab ? void 0 : HIDDEN_LAYER_STYLE, children: [
16946
- /* @__PURE__ */ jsx147(PresetToolsContext.Provider, { value: toolsValue, children: /* @__PURE__ */ jsx147(MessageList, { controller, ui, slip, onDashboardTap, monitor }) }),
16969
+ /* @__PURE__ */ jsx147(PresetToolsContext.Provider, { value: toolsValue, children: /* @__PURE__ */ jsx147(MessageList, { controller, ui, slip, onDashboardTap, monitor, onGreetingSport: favourites?.onSportChange }) }),
16947
16970
  tool && presetGrid && onChatTab && !paused ? /* @__PURE__ */ jsx147(BuildComboTool, { grid: presetGrid, strings: ui.presets, streaming: state.isStreaming, formatKickoff, initialTotal: tool.total, initialLegs: tool.legs, onSend: sendAsk, onClose: closeTool }) : null
16948
16971
  ] }),
16949
16972
  monitor && discovery && schedule && monitor.activeTab === "live" && /* @__PURE__ */ jsx147(