@nukleus-sports/ui-patterns 0.5.0 → 0.6.2

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/team.cjs CHANGED
@@ -31,10 +31,12 @@ __export(team_exports, {
31
31
  TeamFactsContent: () => TeamFactsContent,
32
32
  TeamFactsWidget: () => TeamFactsWidget,
33
33
  TeamInfoCard: () => TeamInfoCard,
34
+ TeamScheduleTable: () => TeamScheduleTable,
34
35
  TeamSeasonScheduleSummaryPanel: () => TeamSeasonScheduleSummaryPanel,
35
36
  TeamSeasonStatsSummaryPanel: () => TeamSeasonStatsSummaryPanel,
36
37
  TeamSeasonStatsWidget: () => TeamSeasonStatsWidget,
37
38
  TeamStaffTable: () => TeamStaffTable,
39
+ TeamStatsTable: () => TeamStatsTable,
38
40
  VenuePhoto: () => VenuePhoto
39
41
  });
40
42
  module.exports = __toCommonJS(team_exports);
@@ -273,6 +275,15 @@ function EntityAvatar({
273
275
 
274
276
  // src/team/team-info-card.tsx
275
277
  var import_jsx_runtime2 = require("react/jsx-runtime");
278
+ function PlaceValueCell({ place }) {
279
+ if (!place.name) {
280
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No address available" });
281
+ }
282
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "text-text-primary body-text", children: [
283
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: place.name }),
284
+ place.address ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: place.address }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "No address available" })
285
+ ] });
286
+ }
276
287
  var TAB_TRIGGER_CLASS = "flex-1 bg-card text-[13px] text-text-primary data-[state=active]:bg-card data-[state=active]:text-primary-color-nuk-text data-[state=active]:shadow-none border-b border-greys-grey-strokes-tables data-[state=active]:border-primary-color-nuk-ui-elem rounded-none px-0 pb-2 mb-[-1px] relative after:absolute after:left-0 after:-bottom-[1px] after:w-full after:h-[2px] after:content-[''] after:bg-transparent data-[state=active]:after:bg-primary-color-nuk-ui-elem";
277
288
  function TeamInfoCard({ team, resolveImageUrl, className }) {
278
289
  const teamDisplayName = (0, import_core.formatTeamName)(team.team, team.nickname) || "Team not found";
@@ -321,18 +332,12 @@ function TeamInfoCard({ team, resolveImageUrl, className }) {
321
332
  venueInfo.label,
322
333
  ":"
323
334
  ] }) }),
324
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: venueInfo.name ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "text-text-primary body-text", children: [
325
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: venueInfo.name }),
326
- venueInfo.address && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: venueInfo.address })
327
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No address available" }) }),
335
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PlaceValueCell, { place: venueInfo }) }),
328
336
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "text-text-primary body-text", children: [
329
337
  facilityInfo.label,
330
338
  ":"
331
339
  ] }) }),
332
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: facilityInfo.name ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "text-text-primary body-text", children: [
333
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: facilityInfo.name }),
334
- facilityInfo.address && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: facilityInfo.address })
335
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "No address available" }) }),
340
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PlaceValueCell, { place: facilityInfo }) }),
336
341
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-text-primary body-text", children: "Website:" }) }),
337
342
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex flex-col text-right", children: team.officialWebsite ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
338
343
  "a",
@@ -552,10 +557,10 @@ function TeamStaffTable({
552
557
  splitLayout: isSplitLayout,
553
558
  numberOfColumns: 1,
554
559
  splitLayoutGridCols: isCompact ? "!grid-cols-[minmax(120px,120px)_1fr]" : isSplitLayout ? "sm:!grid-cols-[minmax(220px,220px)_1fr]" : "",
555
- containerClassName: (0, import_ui_web3.cn)("border-0 rounded-none", effectiveVirtualized && "h-full"),
560
+ containerClassName: (0, import_ui_web3.cn)("border-0 rounded-none xl:h-full", effectiveVirtualized && "h-full"),
556
561
  className: (0, import_ui_web3.cn)(
557
- "border-none",
558
- effectiveVirtualized && "h-full min-h-0 w-full xl:flex-1 xl:overflow-hidden",
562
+ "border-none xl:flex-1 xl:min-h-0 xl:overflow-hidden",
563
+ effectiveVirtualized && "h-full min-h-0 w-full",
559
564
  className
560
565
  ),
561
566
  bottomContent: effectiveVirtualized && hasMore ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: sentinelRef, className: "h-px w-full" }) : null,
@@ -1619,6 +1624,681 @@ function RecentGamesWidget({
1619
1624
  }
1620
1625
  );
1621
1626
  }
1627
+
1628
+ // src/team/team-stats-table.tsx
1629
+ var import_react6 = require("react");
1630
+ var import_ui_web14 = require("@nukleus-sports/ui-web");
1631
+ var import_core9 = require("@nukleus-sports/core");
1632
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1633
+ function stripLeadingSlash(path) {
1634
+ return path.startsWith("/") ? path.slice(1) : path;
1635
+ }
1636
+ function isDefinedStatType(value) {
1637
+ return Boolean(value);
1638
+ }
1639
+ function getAvailableStatCategories(stats) {
1640
+ return Array.from(
1641
+ new Set(
1642
+ stats.flatMap(
1643
+ (stat) => (stat.stat_details?.stats ?? []).map((s) => s.stat_type).filter(isDefinedStatType)
1644
+ )
1645
+ )
1646
+ );
1647
+ }
1648
+ function deriveSelectedStatCategory(requested, available) {
1649
+ if (requested && available.includes(requested)) return requested;
1650
+ if (available.includes("offense")) return "offense";
1651
+ return available[0] ?? "offense";
1652
+ }
1653
+ function getStatsEmptyMessage(seasons, statsCount) {
1654
+ if (!seasons.selectedYear || seasons.selectedType === null) {
1655
+ return "Select a season to view stats.";
1656
+ }
1657
+ if (statsCount === 0) {
1658
+ const yearLabel = seasons.years.find((y) => y.value === seasons.selectedYear)?.label;
1659
+ const typeLabel = seasons.types.find((t) => t.value === seasons.selectedType)?.label;
1660
+ return `No stats available for ${yearLabel} - ${typeLabel}.`;
1661
+ }
1662
+ return "No stats found for this season";
1663
+ }
1664
+ function formatTeamStatDate(stat) {
1665
+ const dateStr = stat.stat_details?.game_details?.date;
1666
+ const date = dateStr ? new Date(dateStr) : null;
1667
+ if (!date || Number.isNaN(date.getTime())) {
1668
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: "--" });
1669
+ }
1670
+ const formatted = date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
1671
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-13.5 font-normal text-text-primary", children: formatted });
1672
+ }
1673
+ function getTeamStatResult(stat) {
1674
+ const gameDetails = stat.stat_details?.game_details;
1675
+ if (gameDetails?.home_team_score === void 0 || gameDetails?.away_team_score === void 0) {
1676
+ return "--";
1677
+ }
1678
+ const isHome = stat.team_id === gameDetails.home_team_id;
1679
+ const homeScore = gameDetails.home_team_score;
1680
+ const awayScore = gameDetails.away_team_score;
1681
+ let winLoss = "T";
1682
+ if (homeScore !== awayScore) {
1683
+ const teamWon = isHome ? homeScore > awayScore : awayScore > homeScore;
1684
+ winLoss = teamWon ? "W" : "L";
1685
+ }
1686
+ const teamScore = isHome ? homeScore : awayScore;
1687
+ const opponentScore = isHome ? awayScore : homeScore;
1688
+ const score = `${teamScore}-${opponentScore}${gameDetails.status_alt_details ? ` ${gameDetails.status_alt_details}` : ""}`;
1689
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
1690
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-baseline gap-1 leading-tight", children: [
1691
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: (0, import_ui_web14.cn)(colorClass, "body-text"), children: winLoss }),
1692
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: score })
1693
+ ] });
1694
+ }
1695
+ function StatOpponentCell({
1696
+ stat,
1697
+ resolveOpponentLogoUrl,
1698
+ defaultLogoUrl,
1699
+ showName
1700
+ }) {
1701
+ const [failedUrl, setFailedUrl] = (0, import_react6.useState)(null);
1702
+ const gameDetails = stat.stat_details?.game_details;
1703
+ const isHome = stat.team_id === gameDetails?.home_team_id;
1704
+ const opponentName = isHome ? gameDetails?.away_team_name : gameDetails?.home_team_name;
1705
+ const opponentLogoPath = isHome ? gameDetails?.away_team_logo : gameDetails?.home_team_logo;
1706
+ if (!opponentName) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, { children: "--" });
1707
+ const prefix = isHome ? "vs" : "@";
1708
+ const resolved = opponentLogoPath ? resolveOpponentLogoUrl(stripLeadingSlash(opponentLogoPath)) : null;
1709
+ const logoSrc = resolved && resolved !== failedUrl ? resolved : defaultLogoUrl;
1710
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "h-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "flex items-center h-full", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex max-sm:gap-1 gap-2 items-center font-normal leading-tight text-12", children: [
1711
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-text-primary body-text", children: prefix }),
1712
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1713
+ "img",
1714
+ {
1715
+ src: logoSrc,
1716
+ alt: showName ? "" : opponentName,
1717
+ className: "max-sm:w-5 max-sm:h-5 w-4 h-4 rounded-full flex-shrink-0",
1718
+ onError: () => {
1719
+ if (resolved) setFailedUrl(resolved);
1720
+ }
1721
+ }
1722
+ ),
1723
+ showName && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentName })
1724
+ ] }) }) });
1725
+ }
1726
+ function buildStatsColumns({
1727
+ filteredStatTypes,
1728
+ selectedStatCategory,
1729
+ resolveOpponentLogoUrl,
1730
+ defaultLogoUrl,
1731
+ isSm,
1732
+ isSmallLaptop
1733
+ }) {
1734
+ return [
1735
+ {
1736
+ id: "game_date",
1737
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "w-[50px] shrink-0", children: "Date" }),
1738
+ cell: ({ row }) => formatTeamStatDate(row.original),
1739
+ meta: { cellSize: isSm ? "xs" : "xxs", headerClassName: "h-auto" }
1740
+ },
1741
+ {
1742
+ id: "opponent",
1743
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { children: isSm ? "Opponent" : "Opp" }),
1744
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1745
+ StatOpponentCell,
1746
+ {
1747
+ stat: row.original,
1748
+ resolveOpponentLogoUrl,
1749
+ defaultLogoUrl,
1750
+ showName: isSm
1751
+ }
1752
+ ),
1753
+ meta: {
1754
+ cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse",
1755
+ headerClassName: "h-auto"
1756
+ }
1757
+ },
1758
+ {
1759
+ id: "result",
1760
+ header: "Result",
1761
+ cell: ({ row }) => getTeamStatResult(row.original),
1762
+ meta: { cellSize: "xs", headerClassName: "h-auto", rowCellClassName: "!min-w-[70px]" }
1763
+ },
1764
+ ...filteredStatTypes.map((statType) => ({
1765
+ id: statType.name,
1766
+ header: statType.label || statType.name,
1767
+ cell: ({ row }) => {
1768
+ const value = row.original.stat_details?.stats?.find(
1769
+ (s) => s.stat_id === statType.id && s.stat_type === selectedStatCategory
1770
+ )?.stat_value;
1771
+ return value !== void 0 ? value : "--";
1772
+ },
1773
+ meta: {
1774
+ cellSize: "xxs",
1775
+ headerClassName: "h-auto py-0 !whitespace-normal !overflow-visible !text-clip !break-words !line-clamp-2"
1776
+ }
1777
+ }))
1778
+ ];
1779
+ }
1780
+ function StatsBody2({
1781
+ seasons,
1782
+ showsCategoryPicker,
1783
+ selectedStatCategory,
1784
+ availableStatCategories,
1785
+ onStatCategoryChange,
1786
+ isStatTypesError,
1787
+ hasVisibleStatTypes,
1788
+ columns,
1789
+ stats,
1790
+ statsLoading,
1791
+ isStatsError,
1792
+ isSm,
1793
+ isSmallLaptop,
1794
+ emptyMessage
1795
+ }) {
1796
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
1797
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2 min-[360px]:gap-3", children: [
1798
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
1799
+ showsCategoryPicker && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1800
+ import_ui_web14.Select,
1801
+ {
1802
+ value: selectedStatCategory,
1803
+ onValueChange: onStatCategoryChange,
1804
+ disabled: !seasons.selectedYear || seasons.selectedType === null,
1805
+ children: [
1806
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Stat category", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectValue, { placeholder: "Select stat category" }) }),
1807
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1808
+ import_ui_web14.SelectContent,
1809
+ {
1810
+ className: "bg-popover border-border z-50 [&_.checkbox]:!flex",
1811
+ classNameViewPort: "gap-2",
1812
+ children: availableStatCategories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.SelectItem, { value: category, className: "capitalize min-h-8", children: category.charAt(0).toUpperCase() + category.slice(1) }, category))
1813
+ }
1814
+ )
1815
+ ]
1816
+ }
1817
+ )
1818
+ ] }),
1819
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "space-y-4 xl:flex-1 xl:min-h-0 xl:overflow-hidden", children: [
1820
+ isStatTypesError && !hasVisibleStatTypes && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-text-secondary text-13.5", children: "Couldn't load stat categories -- showing limited columns." }),
1821
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1822
+ import_ui_web14.BaseTable,
1823
+ {
1824
+ columns,
1825
+ data: stats,
1826
+ pageSize: stats.length || 10,
1827
+ hidePagination: true,
1828
+ stickyHeader: true,
1829
+ splitLayout: isSmallLaptop || !isSm,
1830
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
1831
+ loading: statsLoading,
1832
+ containerClassName: "border-0 rounded-none h-full",
1833
+ className: "border-none xl:h-full xl:min-h-0",
1834
+ numberOfColumns: 2,
1835
+ emptyMessage: isStatsError && stats.length === 0 ? "Couldn't load stats. Please try again." : emptyMessage
1836
+ }
1837
+ )
1838
+ ] })
1839
+ ] });
1840
+ }
1841
+ function TeamStatsTable({
1842
+ stats,
1843
+ statsLoading = false,
1844
+ isStatsError = false,
1845
+ statTypes,
1846
+ isStatTypesError = false,
1847
+ sportId,
1848
+ isTeamError = false,
1849
+ resolveOpponentLogoUrl,
1850
+ defaultLogoUrl,
1851
+ seasons,
1852
+ seasonsLoading = false,
1853
+ isSeasonsError = false,
1854
+ isSm,
1855
+ isSmallLaptop,
1856
+ className
1857
+ }) {
1858
+ const [requestedStatCategory, setRequestedStatCategory] = (0, import_react6.useState)(null);
1859
+ const availableStatCategories = getAvailableStatCategories(stats);
1860
+ const selectedStatCategory = deriveSelectedStatCategory(
1861
+ requestedStatCategory,
1862
+ availableStatCategories
1863
+ );
1864
+ if (isTeamError) {
1865
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
1866
+ }
1867
+ if (seasonsLoading || sportId === null) {
1868
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_ui_web14.CardContent, { className: "space-y-4 pt-6", children: [
1869
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-3 sm:flex-row justify-start", children: [
1870
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[68px] bg-form rounded-[5px]" }),
1871
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[142px] bg-form rounded-[5px]" }),
1872
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-7 w-[102px] bg-form rounded-[5px]" })
1873
+ ] }),
1874
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Skeleton, { className: "h-40 w-full bg-form !mt-3" })
1875
+ ] }) });
1876
+ }
1877
+ if (!seasons || seasons.years.length === 0) {
1878
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.Card, { className: (0, import_ui_web14.cn)("border-none", className), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "pt-6", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "text-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-text-primary text-14.5 font-normal leading-normal", children: isSeasonsError ? "Couldn't load stats. Please try again." : "There are no stats for this team at this time." }) }) }) });
1879
+ }
1880
+ const visibleStatTypes = (0, import_core9.getVisibleTeamStatTypes)(statTypes, sportId);
1881
+ const filteredStatTypes = (0, import_core9.getOrderedTeamStatTypesForCategory)(
1882
+ visibleStatTypes,
1883
+ sportId,
1884
+ selectedStatCategory
1885
+ );
1886
+ const showsCategoryPicker = availableStatCategories.length > 0 && (0, import_core9.showsTeamStatCategoryPicker)(sportId);
1887
+ const columns = buildStatsColumns({
1888
+ filteredStatTypes,
1889
+ selectedStatCategory,
1890
+ resolveOpponentLogoUrl,
1891
+ defaultLogoUrl,
1892
+ isSm,
1893
+ isSmallLaptop
1894
+ });
1895
+ const emptyMessage = getStatsEmptyMessage(seasons, stats.length);
1896
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1897
+ import_ui_web14.Card,
1898
+ {
1899
+ className: (0, import_ui_web14.cn)(
1900
+ "border-none p-4 flex flex-col gap-3 xl:h-full xl:min-h-0 xl:flex-1 xl:overflow-hidden",
1901
+ className
1902
+ ),
1903
+ children: [
1904
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardHeader, { className: "p-0", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardTitle, { children: "Stats" }) }),
1905
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_ui_web14.CardContent, { className: "space-y-0 p-0 flex flex-col gap-3 xl:flex-1 xl:min-h-0", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1906
+ StatsBody2,
1907
+ {
1908
+ seasons,
1909
+ showsCategoryPicker,
1910
+ selectedStatCategory,
1911
+ availableStatCategories,
1912
+ onStatCategoryChange: setRequestedStatCategory,
1913
+ isStatTypesError,
1914
+ hasVisibleStatTypes: visibleStatTypes.length > 0,
1915
+ columns,
1916
+ stats,
1917
+ statsLoading,
1918
+ isStatsError,
1919
+ isSm,
1920
+ isSmallLaptop,
1921
+ emptyMessage
1922
+ }
1923
+ ) })
1924
+ ]
1925
+ }
1926
+ );
1927
+ }
1928
+
1929
+ // src/team/team-schedule-table.tsx
1930
+ var import_ui_web15 = require("@nukleus-sports/ui-web");
1931
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1932
+ var SPECIAL_LOGO_LEAGUES = ["NFL", "NBA", "NHL", "MLB", "WNBA"];
1933
+ var COLLEGE_LEAGUE_IDS = [2, 6, 13];
1934
+ var COMPLETED_STATUS_ID = "3";
1935
+ var DATE_FORMAT2 = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" });
1936
+ function firstCompetition(game) {
1937
+ return game.game_details?.competitions?.[0];
1938
+ }
1939
+ function formatScore(score) {
1940
+ if (score?.displayValue) return score.displayValue;
1941
+ if (typeof score?.value === "number") return String(score.value);
1942
+ return "0";
1943
+ }
1944
+ function findCompetitor(competitors, teamEspnId) {
1945
+ if (!competitors || competitors.length !== 2 || !teamEspnId) return null;
1946
+ const [first, second] = competitors;
1947
+ if (!first || !second) return null;
1948
+ if (first.id === teamEspnId) return { own: first, other: second };
1949
+ if (second.id === teamEspnId) return { own: second, other: first };
1950
+ return null;
1951
+ }
1952
+ function findLeader(competitors, leaderType) {
1953
+ if (!competitors || competitors.length !== 2) return null;
1954
+ for (const competitor of competitors) {
1955
+ const leader = competitor?.leaders?.find((entry) => entry.name === leaderType);
1956
+ const top = leader?.leaders?.[0];
1957
+ if (top?.athlete) {
1958
+ return {
1959
+ displayName: top.athlete.displayName || "--",
1960
+ displayValue: top.displayValue || "--"
1961
+ };
1962
+ }
1963
+ }
1964
+ return null;
1965
+ }
1966
+ function showsFootballLeaders(leagueId) {
1967
+ return leagueId !== null && [1, 2, 13].includes(leagueId);
1968
+ }
1969
+ function showsBasketballLeaders(leagueId) {
1970
+ return leagueId !== null && [4, 5, 6].includes(leagueId);
1971
+ }
1972
+ function showsHockeyLeaders(leagueId) {
1973
+ return leagueId === 14;
1974
+ }
1975
+ function showsMlbLeaders(leagueId) {
1976
+ return leagueId === 7;
1977
+ }
1978
+ function leaderCell(leader, small = false) {
1979
+ if (!leader) return "--";
1980
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col leading-tight", children: [
1981
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: leader.displayName }),
1982
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1983
+ "span",
1984
+ {
1985
+ className: (0, import_ui_web15.cn)(
1986
+ small ? "text-text-secondary text-11" : "text-text-primary body-text",
1987
+ "truncate"
1988
+ ),
1989
+ children: leader.displayValue
1990
+ }
1991
+ )
1992
+ ] });
1993
+ }
1994
+ function formatScheduleDate(game) {
1995
+ if (!game.game_details) return "--";
1996
+ try {
1997
+ const { timeValid, date: rawDate } = game.game_details;
1998
+ const date = timeValid ? new Date(rawDate) : (() => {
1999
+ const [year, month, day] = rawDate.split("T")[0].split("-").map(Number);
2000
+ return new Date(year, month - 1, day);
2001
+ })();
2002
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text", children: DATE_FORMAT2.format(date) });
2003
+ } catch {
2004
+ return "--";
2005
+ }
2006
+ }
2007
+ function getScheduleResult(game, teamEspnId) {
2008
+ const competition = firstCompetition(game);
2009
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return null;
2010
+ const match = findCompetitor(competition.competitors, teamEspnId);
2011
+ if (!match) return null;
2012
+ const { own, other } = match;
2013
+ const ownValue = own.score?.value;
2014
+ const otherValue = other.score?.value;
2015
+ const scoresKnown = typeof ownValue === "number" && typeof otherValue === "number";
2016
+ const tied = scoresKnown && ownValue === otherValue;
2017
+ const winLoss = tied ? "T" : own.winner === true ? "W" : "L";
2018
+ const score = `${formatScore(own.score)}-${formatScore(other.score)}`;
2019
+ const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
2020
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-baseline gap-1 leading-tight", children: [
2021
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: (0, import_ui_web15.cn)(colorClass, "body-text"), children: winLoss }),
2022
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text", children: score })
2023
+ ] });
2024
+ }
2025
+ function getScheduleRecord(game, teamEspnId) {
2026
+ const competition = firstCompetition(game);
2027
+ if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return "--";
2028
+ return findCompetitor(competition.competitors, teamEspnId)?.own.record?.[0]?.displayValue || "--";
2029
+ }
2030
+ function getWinningGoalie(game) {
2031
+ const athlete = firstCompetition(game)?.featuredAthletes?.[0]?.athlete;
2032
+ if (!athlete?.lastName) return "--";
2033
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex flex-col leading-tight", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }) });
2034
+ }
2035
+ function getHockeyTopPlayer(game) {
2036
+ const competitors = firstCompetition(game)?.competitors;
2037
+ const competitor = competitors?.find((c) => c?.leaders?.[0]?.leaders?.length);
2038
+ const top = competitor?.leaders?.[0]?.leaders?.[0];
2039
+ if (!top?.athlete?.lastName) return "--";
2040
+ return leaderCell(
2041
+ { displayName: top.athlete.lastName, displayValue: top.displayValue || "--" },
2042
+ true
2043
+ );
2044
+ }
2045
+ function getMlbPitcher(game, pitcherType) {
2046
+ const pitcher = firstCompetition(game)?.featuredAthletes?.find((a) => a.name === pitcherType);
2047
+ const athlete = pitcher?.athlete;
2048
+ if (!athlete?.lastName) return "--";
2049
+ const stat = pitcherType === "savingPitcher" ? athlete.saves : athlete.record;
2050
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col leading-tight", children: [
2051
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }),
2052
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-secondary text-11 truncate", children: stat || "--" })
2053
+ ] });
2054
+ }
2055
+ function OpponentCell({
2056
+ game,
2057
+ teamEspnId,
2058
+ leagueId,
2059
+ leagueAbbreviation,
2060
+ resolveLogoUrl,
2061
+ defaultLogoUrl,
2062
+ showName
2063
+ }) {
2064
+ const match = findCompetitor(firstCompetition(game)?.competitors, teamEspnId);
2065
+ if (!match || leagueId === null || !leagueAbbreviation) return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children: "--" });
2066
+ const prefix = match.own.homeAway === "home" ? "vs" : "@";
2067
+ const opponentTeam = match.other.team;
2068
+ const isSpecialLeague = SPECIAL_LOGO_LEAGUES.includes(leagueAbbreviation);
2069
+ const identifier = isSpecialLeague ? opponentTeam.abbreviation : opponentTeam.id;
2070
+ const folder = COLLEGE_LEAGUE_IDS.includes(leagueId) ? "NCAA" : leagueAbbreviation;
2071
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center gap-1 sm:gap-2 h-full overflow-hidden", children: [
2072
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-text-primary body-text shrink-0 sm:w-4", children: prefix }),
2073
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2074
+ "img",
2075
+ {
2076
+ src: resolveLogoUrl(folder, identifier),
2077
+ alt: showName ? "" : opponentTeam.displayName,
2078
+ loading: "lazy",
2079
+ className: "h-5 w-5 shrink-0 inline sm:h-6 sm:w-6 sm:mr-2",
2080
+ onError: (event) => {
2081
+ event.currentTarget.src = defaultLogoUrl;
2082
+ }
2083
+ }
2084
+ ),
2085
+ showName && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentTeam.displayName })
2086
+ ] });
2087
+ }
2088
+ function buildScheduleColumns({
2089
+ leagueId,
2090
+ leagueAbbreviation,
2091
+ teamEspnId,
2092
+ resolveLogoUrl,
2093
+ defaultLogoUrl,
2094
+ isSm,
2095
+ isSmallLaptop
2096
+ }) {
2097
+ const showsHockey = showsHockeyLeaders(leagueId);
2098
+ return [
2099
+ {
2100
+ id: "game_date",
2101
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "w-[50px] shrink-0", children: "Date" }),
2102
+ accessorFn: (row) => row.game_date,
2103
+ cell: ({ row }) => formatScheduleDate(row.original),
2104
+ meta: { cellSize: isSm ? "xs" : "xxs" }
2105
+ },
2106
+ {
2107
+ id: "opponent",
2108
+ header: () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: isSm ? "Opponent" : "Opp" }),
2109
+ cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2110
+ OpponentCell,
2111
+ {
2112
+ game: row.original,
2113
+ teamEspnId,
2114
+ leagueId,
2115
+ leagueAbbreviation,
2116
+ resolveLogoUrl,
2117
+ defaultLogoUrl,
2118
+ showName: isSm
2119
+ }
2120
+ ),
2121
+ meta: { cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse" }
2122
+ },
2123
+ {
2124
+ id: "result",
2125
+ header: "Result",
2126
+ cell: ({ row }) => getScheduleResult(row.original, teamEspnId) ?? "--",
2127
+ meta: { cellSize: "xs" }
2128
+ },
2129
+ {
2130
+ id: "record",
2131
+ header: showsHockey ? "W-L-OTL" : "W-L",
2132
+ cell: ({ row }) => getScheduleRecord(row.original, teamEspnId),
2133
+ meta: { cellSize: "xs" }
2134
+ },
2135
+ ...showsMlbLeaders(leagueId) ? [
2136
+ {
2137
+ id: "win",
2138
+ header: "Win",
2139
+ cell: ({ row }) => getMlbPitcher(row.original, "winningPitcher"),
2140
+ meta: { cellSize: "s" }
2141
+ },
2142
+ {
2143
+ id: "loss",
2144
+ header: "Loss",
2145
+ cell: ({ row }) => getMlbPitcher(row.original, "losingPitcher"),
2146
+ meta: { cellSize: "s" }
2147
+ },
2148
+ {
2149
+ id: "save",
2150
+ header: "Save",
2151
+ cell: ({ row }) => getMlbPitcher(row.original, "savingPitcher"),
2152
+ meta: { cellSize: "s" }
2153
+ }
2154
+ ] : [],
2155
+ ...showsBasketballLeaders(leagueId) ? [
2156
+ {
2157
+ id: "topPts",
2158
+ header: "Top Pts",
2159
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "points"), true),
2160
+ meta: { cellSize: "s" }
2161
+ },
2162
+ {
2163
+ id: "topReb",
2164
+ header: "Top Reb",
2165
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rebounds"), true),
2166
+ meta: { cellSize: "s" }
2167
+ },
2168
+ {
2169
+ id: "topAst",
2170
+ header: "Top Ast",
2171
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "assists"), true),
2172
+ meta: { cellSize: "s" }
2173
+ }
2174
+ ] : [],
2175
+ ...showsHockey ? [
2176
+ {
2177
+ id: "wGoalie",
2178
+ header: "W Goalie",
2179
+ cell: ({ row }) => getWinningGoalie(row.original),
2180
+ meta: { cellSize: "s" }
2181
+ },
2182
+ {
2183
+ id: "topPlayer",
2184
+ header: "Top Player",
2185
+ cell: ({ row }) => getHockeyTopPlayer(row.original),
2186
+ meta: { cellSize: "s" }
2187
+ }
2188
+ ] : [],
2189
+ ...showsFootballLeaders(leagueId) ? [
2190
+ {
2191
+ id: "topPass",
2192
+ header: "Top Pass",
2193
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "passingLeader")),
2194
+ meta: { cellSize: "l" }
2195
+ },
2196
+ {
2197
+ id: "topRush",
2198
+ header: "Top Rush",
2199
+ cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rushingLeader")),
2200
+ meta: { cellSize: "l" }
2201
+ },
2202
+ {
2203
+ id: "topRec",
2204
+ header: "Top Rec",
2205
+ cell: ({ row }) => leaderCell(
2206
+ findLeader(firstCompetition(row.original)?.competitors, "receivingLeader")
2207
+ ),
2208
+ meta: { cellSize: "l" }
2209
+ }
2210
+ ] : []
2211
+ ];
2212
+ }
2213
+ function ScheduleBody({
2214
+ seasonsLoading,
2215
+ seasons,
2216
+ isSeasonsError,
2217
+ columns,
2218
+ games,
2219
+ gamesLoading,
2220
+ isGamesError,
2221
+ isSm,
2222
+ isSmallLaptop
2223
+ }) {
2224
+ if (seasonsLoading) {
2225
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "flex justify-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "text-sm text-text-primary", children: "Loading seasons..." }) });
2226
+ }
2227
+ if (!seasons || seasons.years.length === 0) {
2228
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "text-center py-8", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-primary", children: isSeasonsError ? "Couldn't load seasons. Please try again." : "No seasons found" }) });
2229
+ }
2230
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col gap-3", children: [
2231
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
2232
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2233
+ import_ui_web15.BaseTable,
2234
+ {
2235
+ columns,
2236
+ data: games,
2237
+ pageSize: games.length || 10,
2238
+ splitLayout: isSmallLaptop || !isSm,
2239
+ splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
2240
+ loading: gamesLoading,
2241
+ containerClassName: "border-0 rounded-none h-full",
2242
+ className: "h-full border-none",
2243
+ numberOfColumns: 2,
2244
+ emptyMessage: isGamesError ? "Couldn't load games. Please try again." : "No games found for this season"
2245
+ }
2246
+ ) })
2247
+ ] });
2248
+ }
2249
+ function TeamScheduleTable({
2250
+ games,
2251
+ gamesLoading = false,
2252
+ isGamesError = false,
2253
+ leagueId,
2254
+ leagueAbbreviation,
2255
+ isTeamError = false,
2256
+ teamEspnId,
2257
+ resolveLogoUrl,
2258
+ defaultLogoUrl,
2259
+ seasons,
2260
+ seasonsLoading = false,
2261
+ isSeasonsError = false,
2262
+ isSm,
2263
+ isSmallLaptop,
2264
+ className
2265
+ }) {
2266
+ const columns = buildScheduleColumns({
2267
+ leagueId,
2268
+ leagueAbbreviation,
2269
+ teamEspnId,
2270
+ resolveLogoUrl,
2271
+ defaultLogoUrl,
2272
+ isSm,
2273
+ isSmallLaptop
2274
+ });
2275
+ if (isTeamError) {
2276
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardContent, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
2277
+ }
2278
+ if (leagueId === null) {
2279
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-0", className), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_web15.CardContent, { className: "p-4 flex justify-center items-center gap-2", children: [
2280
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.IconLoader, {}),
2281
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-text-secondary", children: "Loading team information..." })
2282
+ ] }) });
2283
+ }
2284
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_ui_web15.Card, { className: (0, import_ui_web15.cn)("border-none p-4 flex flex-col gap-3", className), children: [
2285
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardHeader, { className: "p-0 flex flex-row items-center justify-between space-y-0", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardTitle, { children: "Schedule" }) }),
2286
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_ui_web15.CardContent, { className: "space-y-0 p-0 flex flex-col gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2287
+ ScheduleBody,
2288
+ {
2289
+ seasonsLoading,
2290
+ seasons,
2291
+ isSeasonsError,
2292
+ columns,
2293
+ games,
2294
+ gamesLoading,
2295
+ isGamesError,
2296
+ isSm,
2297
+ isSmallLaptop
2298
+ }
2299
+ ) })
2300
+ ] });
2301
+ }
1622
2302
  // Annotate the CommonJS export names for ESM import in node:
1623
2303
  0 && (module.exports = {
1624
2304
  EmptyValue,
@@ -1632,10 +2312,12 @@ function RecentGamesWidget({
1632
2312
  TeamFactsContent,
1633
2313
  TeamFactsWidget,
1634
2314
  TeamInfoCard,
2315
+ TeamScheduleTable,
1635
2316
  TeamSeasonScheduleSummaryPanel,
1636
2317
  TeamSeasonStatsSummaryPanel,
1637
2318
  TeamSeasonStatsWidget,
1638
2319
  TeamStaffTable,
2320
+ TeamStatsTable,
1639
2321
  VenuePhoto
1640
2322
  });
1641
2323
  //# sourceMappingURL=team.cjs.map