@nukleus-sports/ui-patterns 0.3.1 → 0.5.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/team.d.ts ADDED
@@ -0,0 +1,271 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { EntityImageResolver } from './index.js';
4
+ import { StaffMember, StaffSort, TeamSeasonStatsResult, SeasonSummary, SeasonSelectorOption, TeamFactKey, TeamFactsSectionLayout, TeamFactsWidgetData, TeamVenue, TeamFactsWidgetState, StatRanking, TeamSeasonSummaryRecord, RecentGameRow } from '@nukleus-sports/core';
5
+
6
+ interface TeamInfoCardSocialLink {
7
+ platform: string;
8
+ handle?: string;
9
+ url?: string;
10
+ }
11
+ interface TeamInfoCardTeam {
12
+ team: string | null;
13
+ nickname: string | null;
14
+ teamLogoUrl: string | null;
15
+ leagueAbbreviation: string | null;
16
+ /** Also carries the venue/facility fields `getTeamPlaceSummaries` reads. */
17
+ specificData: {
18
+ conference?: string | null;
19
+ division?: string | null;
20
+ socials?: TeamInfoCardSocialLink[];
21
+ [key: string]: unknown;
22
+ } | null;
23
+ officialWebsite: string | null;
24
+ }
25
+ interface TeamInfoCardProps {
26
+ team: TeamInfoCardTeam;
27
+ resolveImageUrl?: EntityImageResolver;
28
+ className?: string;
29
+ }
30
+ declare function TeamInfoCard({ team, resolveImageUrl, className }: TeamInfoCardProps): react.JSX.Element;
31
+
32
+ interface TeamStaffMember extends StaffMember {
33
+ position_group: string | null;
34
+ coach_image_url: string | null;
35
+ }
36
+ interface TeamStaffTableProps {
37
+ staff: TeamStaffMember[];
38
+ loading: boolean;
39
+ isError?: boolean;
40
+ /** Gates row interactivity (coach profile navigation) -- replaces an app-local feature flag. */
41
+ interactive?: boolean;
42
+ onStaffClick?: (id: number) => void;
43
+ /** Opt-in -- nukleus-clientapp's table has no sorting today; nukleus-app's does. */
44
+ sortable?: boolean;
45
+ sorting?: StaffSort[];
46
+ onSortingChange?: (sorting: StaffSort[]) => void;
47
+ /** Opt-in client-side infinite scroll, backed by `@nukleus-sports/ui-web`'s `useInfiniteList`. */
48
+ virtualized?: boolean;
49
+ /** True below the layout's split-table breakpoint; the caller determines this however it
50
+ * already detects breakpoints (media query, container query, etc.). */
51
+ isSplitLayout?: boolean;
52
+ /** True on a narrow/mobile viewport -- shrinks the Name column and its avatar. */
53
+ isCompact?: boolean;
54
+ resolveImageUrl?: EntityImageResolver;
55
+ className?: string;
56
+ }
57
+ declare function TeamStaffTable({ staff, loading, isError, interactive, onStaffClick, sortable, sorting, onSortingChange, virtualized, isSplitLayout, isCompact, resolveImageUrl, className, }: TeamStaffTableProps): react.JSX.Element;
58
+
59
+ interface StatColumnProps {
60
+ label: string;
61
+ value: string;
62
+ suffix?: string;
63
+ rankBadge?: ReactNode;
64
+ }
65
+ /** A single labeled stat value, used by the Team season summary panels. */
66
+ declare function StatColumn({ label, value, suffix, rankBadge }: StatColumnProps): react.JSX.Element;
67
+
68
+ interface TeamSeasonStatsSummaryPanelProps {
69
+ sportId: number;
70
+ selectedYear: number | null;
71
+ selectedType: number | null;
72
+ stats: TeamSeasonStatsResult | null;
73
+ loading: boolean;
74
+ /** A failed fetch, as distinct from "no stats for this season" -- see RECONCILIATION.md. */
75
+ isError?: boolean;
76
+ className?: string;
77
+ }
78
+ /** Season stats summary panel for the Stats tab header -- no season selectors of its own. */
79
+ declare function TeamSeasonStatsSummaryPanel({ sportId, selectedYear, selectedType, stats, loading, isError, className, }: TeamSeasonStatsSummaryPanelProps): react.JSX.Element;
80
+
81
+ interface TeamSeasonScheduleSummaryPanelProps {
82
+ selectedYear: number | null;
83
+ selectedType: number | null;
84
+ summary: SeasonSummary | null;
85
+ loading: boolean;
86
+ /** A failed fetch, as distinct from "no games for this season" -- see RECONCILIATION.md. */
87
+ isError?: boolean;
88
+ className?: string;
89
+ }
90
+ /** Season summary panel for the Schedule tab header -- `summary` is already computed by the caller. */
91
+ declare function TeamSeasonScheduleSummaryPanel({ selectedYear, selectedType, summary, loading, isError, className, }: TeamSeasonScheduleSummaryPanelProps): react.JSX.Element;
92
+
93
+ interface SeasonSelectorProps {
94
+ years: SeasonSelectorOption[];
95
+ types: SeasonSelectorOption[];
96
+ selectedYear: number | null;
97
+ selectedType: number | null;
98
+ onYearChange: (year: number) => void;
99
+ onTypeChange: (type: number) => void;
100
+ /** Show only the year picker below the `sm` breakpoint (the compact Team Stats card). */
101
+ hideTypeOnMobile?: boolean;
102
+ className?: string;
103
+ }
104
+ /** Year/type dropdown pair shared by the Schedule and Stats tabs' season pickers. */
105
+ declare function SeasonSelector({ years, types, selectedYear, selectedType, onYearChange, onTypeChange, hideTypeOnMobile, className, }: SeasonSelectorProps): react.JSX.Element;
106
+
107
+ interface FactPillsProps {
108
+ items: (string | number)[];
109
+ /** Cap the list at two rows with an inline "Show More" toggle (Trophy Case). */
110
+ capped?: boolean;
111
+ }
112
+ /**
113
+ * Grey pills for year and name lists. When `capped`, the list is measured after layout: pills that
114
+ * would spill past the second row are hidden and a "Show More" link takes the last free slot. Row
115
+ * height and gap are read from the rendered pills, so larger text never clips the second row.
116
+ */
117
+ declare function FactPills({ items, capped }: FactPillsProps): react.JSX.Element;
118
+
119
+ declare function EmptyValue({ children }: {
120
+ children?: ReactNode;
121
+ }): react.JSX.Element;
122
+ /** Field labels always come from the league config (`config.labels`), unchanged. */
123
+ declare function FieldLabel({ children }: {
124
+ children: ReactNode;
125
+ }): react.JSX.Element;
126
+ interface FactFieldProps {
127
+ factKey: TeamFactKey;
128
+ layout: TeamFactsSectionLayout;
129
+ data: TeamFactsWidgetData;
130
+ resolveImageUrl?: EntityImageResolver;
131
+ /** Omit to render the rival's name as plain text instead of a link. */
132
+ getRivalHref?: (rivalId: number) => string;
133
+ }
134
+ /** One fact with its league label, drawn by its kind (count, number, pills, rival or text). */
135
+ declare function FactField({ factKey, layout, data, resolveImageUrl, getRivalHref, }: FactFieldProps): react.JSX.Element;
136
+
137
+ interface VenuePhotoProps {
138
+ venue: TeamVenue;
139
+ /** "Stadium" or "Arena" -- labels the venue name when there's no photo, and is the photo's fallback alt text. */
140
+ label: string;
141
+ /** Resolves a stored facility-image path to a renderable URL, resized to `width` when given. Omit to
142
+ * render the venue name only -- the stored `path` is never itself a renderable URL. */
143
+ resolveImageUrl?: (path: string, width?: number) => string | null;
144
+ }
145
+ /**
146
+ * The venue photo with its name, photographer/license credit and source links. Without a photo the
147
+ * venue name is still shown, as a labelled fact. Loads a resized copy; if this environment can't
148
+ * resize images, falls back to the original file.
149
+ */
150
+ declare function VenuePhoto({ venue, label, resolveImageUrl }: VenuePhotoProps): react.JSX.Element;
151
+
152
+ interface TeamFactsContentProps {
153
+ data: TeamFactsWidgetData;
154
+ resolveImageUrl?: EntityImageResolver;
155
+ resolveVenuePhotoUrl?: VenuePhotoProps["resolveImageUrl"];
156
+ /** Omit to render the rival's name as plain text instead of a link. */
157
+ getRivalHref?: (rivalId: number) => string;
158
+ }
159
+ /** One layout for every screen size: stacked section cards, Trophy Case in two columns, the profile
160
+ * facts in one row, Tradition as a column. The widget decides the card width and height. */
161
+ declare function TeamFactsContent({ data, resolveImageUrl, resolveVenuePhotoUrl, getRivalHref, }: TeamFactsContentProps): react.JSX.Element;
162
+
163
+ interface TeamFactsWidgetProps {
164
+ state: TeamFactsWidgetState;
165
+ resolveImageUrl?: EntityImageResolver;
166
+ resolveVenuePhotoUrl?: TeamFactsContentProps["resolveVenuePhotoUrl"];
167
+ /** Omit to render the rival's name as plain text instead of a link. */
168
+ getRivalHref?: (rivalId: number) => string;
169
+ className?: string;
170
+ }
171
+ /**
172
+ * Team page Dashboard widget: the team's facts (Trophy Case, Tradition, Franchise/School Profile),
173
+ * labelled per league, with the venue photo in the profile section.
174
+ *
175
+ * Mobile/tablet: grows with its content. Desktop (>=1280px, where it sits in the right-hand column):
176
+ * the card takes the height of the dashboard column beside it (`contain: size` stops its own content
177
+ * from stretching the row) and the sections scroll inside it with the scrollbar hidden.
178
+ */
179
+ declare function TeamFactsWidget({ state, resolveImageUrl, resolveVenuePhotoUrl, getRivalHref, className, }: TeamFactsWidgetProps): react.JSX.Element;
180
+
181
+ interface StatLeaderboardRow {
182
+ entityId: number;
183
+ entityName: string;
184
+ rank: number;
185
+ tied: boolean;
186
+ value: number | null;
187
+ }
188
+ interface StatRankingLeaderboardDialogProps {
189
+ open: boolean;
190
+ onOpenChange: (open: boolean) => void;
191
+ title: string;
192
+ /** The season line under the title, e.g. "2025 Regular Season". */
193
+ subtitle?: string;
194
+ /** Names the first data column: "Player" or "Team". */
195
+ entityLabel: string;
196
+ /** Names the value column (the stat's description). */
197
+ statLabel: string;
198
+ rows: StatLeaderboardRow[];
199
+ /** Turns a row's value into display text. Memoize it: it is a column dependency. */
200
+ formatValue: (value: number | null) => string;
201
+ footnotes?: string[];
202
+ highlightEntityId?: number;
203
+ /** 1-based. Controlled by the caller, which also owns resetting it when the dialog reopens. */
204
+ page: number;
205
+ onPageChange: (page: number) => void;
206
+ /** Total rows across all pages; omit while unknown (e.g. a page failed before any count loaded). */
207
+ totalCount?: number;
208
+ pageSize: number;
209
+ loading?: boolean;
210
+ /** The stat's config failed to load, so its title/format can't be trusted: rows are withheld. */
211
+ isConfigError?: boolean;
212
+ /** The rows request failed. Any rows already shown are kept, with a notice. */
213
+ isError?: boolean;
214
+ /** At or above the app's desktop breakpoint: a centered dialog; below it, a full-screen modal. */
215
+ isSm: boolean;
216
+ }
217
+ /**
218
+ * A stat's ranked leaderboard (players or teams) as a dialog on desktop and a full-screen modal
219
+ * below it. Presentational: the caller fetches the rows, owns the current page, and decides how
220
+ * values are formatted (including whether a stat is a percentage).
221
+ */
222
+ declare function StatRankingLeaderboardDialog(props: StatRankingLeaderboardDialogProps): react.JSX.Element;
223
+
224
+ type TeamSeasonStatsRanking = Pick<StatRanking, "config_id" | "rank" | "tied">;
225
+ interface TeamSeasonStatsWidgetProps {
226
+ sportId: number | null | undefined;
227
+ leagueId: number | null | undefined;
228
+ /** The year/type pickers' state. Omit, or pass no years, while the team's seasons aren't known. */
229
+ seasons?: Omit<SeasonSelectorProps, "className" | "hideTypeOnMobile">;
230
+ /** Whole-card loader while the team's season list loads. */
231
+ seasonsLoading?: boolean;
232
+ summary: TeamSeasonSummaryRecord | null | undefined;
233
+ /** The team's league rankings for the selected season; only those for the 4 headline stats are used. */
234
+ rankings: TeamSeasonStatsRanking[] | undefined;
235
+ /** No stats to show yet (neither a current summary nor current rankings). */
236
+ statsLoading?: boolean;
237
+ isSummaryError?: boolean;
238
+ isRankingsError?: boolean;
239
+ /** Called with a ranking config id when its rank is clicked; omit and ranks render as plain text. */
240
+ onRankClick?: (configId: number) => void;
241
+ className?: string;
242
+ }
243
+ /**
244
+ * Team page Dashboard card: a team's 4 headline season stats with the season pickers and each
245
+ * stat's league rank. Presentational: the caller fetches the season list, summary and rankings, owns
246
+ * the selected season, and renders the leaderboard dialog that `onRankClick` opens.
247
+ */
248
+ declare function TeamSeasonStatsWidget({ sportId, leagueId, seasons, seasonsLoading, summary, rankings, statsLoading, isSummaryError, isRankingsError, onRankClick, className, }: TeamSeasonStatsWidgetProps): react.JSX.Element;
249
+
250
+ type RecentGamesStatus = "ready" | "loading" | "no-team" | "team-error" | "games-error";
251
+ interface RecentGamesWidgetProps {
252
+ /** What to show instead of the list; "ready" shows the rows (or the empty message). */
253
+ status: RecentGamesStatus;
254
+ rows: RecentGameRow[];
255
+ /** Turns a stored team-logo path into a URL. Omit and stored logos show `defaultLogoUrl`. */
256
+ resolveImageUrl?: (path: string) => string;
257
+ /** Shown for a team with no logo, and when a logo fails to load. */
258
+ defaultLogoUrl: string;
259
+ /** Opens the full schedule. Omit to hide the header button. */
260
+ onExpand?: () => void;
261
+ className?: string;
262
+ }
263
+ /**
264
+ * Team page Dashboard card: a team's last few results and next few fixtures. Presentational: the
265
+ * caller fetches the games and teams, turns them into rows with `buildRecentGameRows`, and decides
266
+ * which status applies. "Loading" means "no current data yet", not "a fetch is in flight", so a
267
+ * background refetch never flashes the loader over games already on screen.
268
+ */
269
+ declare function RecentGamesWidget({ status, rows, resolveImageUrl, defaultLogoUrl, onExpand, className, }: RecentGamesWidgetProps): react.JSX.Element;
270
+
271
+ export { EmptyValue, FactField, type FactFieldProps, FactPills, type FactPillsProps, FieldLabel, type RecentGamesStatus, RecentGamesWidget, type RecentGamesWidgetProps, SeasonSelector, type SeasonSelectorProps, StatColumn, type StatColumnProps, type StatLeaderboardRow, StatRankingLeaderboardDialog, type StatRankingLeaderboardDialogProps, TeamFactsContent, type TeamFactsContentProps, TeamFactsWidget, type TeamFactsWidgetProps, TeamInfoCard, type TeamInfoCardProps, type TeamInfoCardSocialLink, type TeamInfoCardTeam, TeamSeasonScheduleSummaryPanel, type TeamSeasonScheduleSummaryPanelProps, type TeamSeasonStatsRanking, TeamSeasonStatsSummaryPanel, type TeamSeasonStatsSummaryPanelProps, TeamSeasonStatsWidget, type TeamSeasonStatsWidgetProps, type TeamStaffMember, TeamStaffTable, type TeamStaffTableProps, VenuePhoto, type VenuePhotoProps };