@nukleus-sports/ui-patterns 0.4.0 → 0.6.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/{chunk-JDVXTCUB.js → chunk-4N2GUEA7.js} +11 -6
- package/dist/chunk-4N2GUEA7.js.map +1 -0
- package/dist/client.cjs +8 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +1 -1
- package/dist/index.cjs +10 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/marketing.cjs +8 -4
- package/dist/marketing.cjs.map +1 -1
- package/dist/marketing.js +1 -1
- package/dist/team.cjs +2320 -0
- package/dist/team.cjs.map +1 -0
- package/dist/team.d.cts +424 -0
- package/dist/team.d.ts +424 -0
- package/dist/team.js +2147 -0
- package/dist/team.js.map +1 -0
- package/package.json +9 -3
- package/dist/chunk-JDVXTCUB.js.map +0 -1
package/dist/team.js
ADDED
|
@@ -0,0 +1,2147 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EntityAvatar
|
|
3
|
+
} from "./chunk-4N2GUEA7.js";
|
|
4
|
+
|
|
5
|
+
// src/team/team-info-card.tsx
|
|
6
|
+
import {
|
|
7
|
+
Card,
|
|
8
|
+
CardContent,
|
|
9
|
+
Tabs,
|
|
10
|
+
TabsContent,
|
|
11
|
+
TabsList,
|
|
12
|
+
TabsTrigger,
|
|
13
|
+
cn
|
|
14
|
+
} from "@nukleus-sports/ui-web";
|
|
15
|
+
import { formatTeamName, getTeamPlaceSummaries } from "@nukleus-sports/core";
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
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";
|
|
18
|
+
function TeamInfoCard({ team, resolveImageUrl, className }) {
|
|
19
|
+
const teamDisplayName = formatTeamName(team.team, team.nickname) || "Team not found";
|
|
20
|
+
const conferenceInfo = team.specificData?.conference || team.specificData?.division ? `${team.specificData.conference || ""} ${team.specificData.division || ""}`.trim() : "";
|
|
21
|
+
const { venue: venueInfo, facility: facilityInfo } = getTeamPlaceSummaries(
|
|
22
|
+
team.specificData,
|
|
23
|
+
team.leagueAbbreviation
|
|
24
|
+
);
|
|
25
|
+
const socials = team.specificData?.socials ?? [];
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
Card,
|
|
28
|
+
{
|
|
29
|
+
className: cn(
|
|
30
|
+
"p-4 sm:py-4 sm:px-9 w-full xl:w-[420px] flex flex-col overflow-hidden border-none h-full md:min-h-[612px]",
|
|
31
|
+
className
|
|
32
|
+
),
|
|
33
|
+
children: /* @__PURE__ */ jsxs(CardContent, { className: "flex flex-col gap-4 items-center p-0", children: [
|
|
34
|
+
/* @__PURE__ */ jsxs("div", { className: "flex sm:flex-col sm:items-center sm:gap-4", children: [
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
EntityAvatar,
|
|
37
|
+
{
|
|
38
|
+
entityType: "team",
|
|
39
|
+
entityData: {
|
|
40
|
+
team: team.team,
|
|
41
|
+
nickname: team.nickname,
|
|
42
|
+
team_logo_url: team.teamLogoUrl
|
|
43
|
+
},
|
|
44
|
+
resolveImageUrl,
|
|
45
|
+
size: "3xl",
|
|
46
|
+
className: "rounded-none",
|
|
47
|
+
fallbackClassName: "text-2xl font-bold"
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 justify-center px-4 sm:items-center", children: [
|
|
51
|
+
/* @__PURE__ */ jsx("div", { className: "text-text-primary text-[24px] font-black sm:player-card-name", children: teamDisplayName }),
|
|
52
|
+
conferenceInfo && /* @__PURE__ */ jsx("p", { className: "text-sm text-text-primary", children: conferenceInfo })
|
|
53
|
+
] })
|
|
54
|
+
] }),
|
|
55
|
+
/* @__PURE__ */ jsxs(Tabs, { defaultValue: "info", className: "w-full", children: [
|
|
56
|
+
/* @__PURE__ */ jsxs(TabsList, { className: "grid w-full grid-cols-2 bg-transparent border-b rounded-none h-auto p-0 text-text-primary", children: [
|
|
57
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "info", className: TAB_TRIGGER_CLASS, children: "Info" }),
|
|
58
|
+
/* @__PURE__ */ jsx(TabsTrigger, { value: "social", className: TAB_TRIGGER_CLASS, children: "Social" })
|
|
59
|
+
] }),
|
|
60
|
+
/* @__PURE__ */ jsx(TabsContent, { value: "info", className: "mt-3", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[auto_1fr] gap-4", children: [
|
|
61
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsxs("p", { className: "text-text-primary body-text", children: [
|
|
62
|
+
venueInfo.label,
|
|
63
|
+
":"
|
|
64
|
+
] }) }),
|
|
65
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col text-right", children: venueInfo.name ? /* @__PURE__ */ jsxs("div", { className: "text-text-primary body-text", children: [
|
|
66
|
+
/* @__PURE__ */ jsx("p", { children: venueInfo.name }),
|
|
67
|
+
venueInfo.address && /* @__PURE__ */ jsx("p", { children: venueInfo.address })
|
|
68
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "No address available" }) }),
|
|
69
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsxs("p", { className: "text-text-primary body-text", children: [
|
|
70
|
+
facilityInfo.label,
|
|
71
|
+
":"
|
|
72
|
+
] }) }),
|
|
73
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col text-right", children: facilityInfo.name ? /* @__PURE__ */ jsxs("div", { className: "text-text-primary body-text", children: [
|
|
74
|
+
/* @__PURE__ */ jsx("p", { children: facilityInfo.name }),
|
|
75
|
+
facilityInfo.address && /* @__PURE__ */ jsx("p", { children: facilityInfo.address })
|
|
76
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "No address available" }) }),
|
|
77
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "Website:" }) }),
|
|
78
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col text-right", children: team.officialWebsite ? /* @__PURE__ */ jsxs(
|
|
79
|
+
"a",
|
|
80
|
+
{
|
|
81
|
+
href: /^https?:\/\//.test(team.officialWebsite) ? team.officialWebsite : `http://${team.officialWebsite}`,
|
|
82
|
+
target: "_blank",
|
|
83
|
+
rel: "noopener noreferrer",
|
|
84
|
+
className: "text-primary-color-nuk-text body-text inline-flex items-center justify-end gap-1",
|
|
85
|
+
children: [
|
|
86
|
+
team.officialWebsite.replace(/^https?:\/\//, ""),
|
|
87
|
+
/* @__PURE__ */ jsx("svg", { className: "w-3 h-3", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx(
|
|
88
|
+
"path",
|
|
89
|
+
{
|
|
90
|
+
strokeLinecap: "round",
|
|
91
|
+
strokeLinejoin: "round",
|
|
92
|
+
strokeWidth: 2,
|
|
93
|
+
d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
|
|
94
|
+
}
|
|
95
|
+
) })
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
) : /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "No website available" }) })
|
|
99
|
+
] }) }),
|
|
100
|
+
/* @__PURE__ */ jsx(TabsContent, { value: "social", className: "mt-3", children: socials.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-text-primary body-text", children: "No social networks yet." }) : /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3", children: socials.map((social) => {
|
|
101
|
+
const handle = social.handle || social.url?.split("/").pop() || "";
|
|
102
|
+
const url = social.url || `https://${social.platform.toLowerCase()}.com/${handle}`;
|
|
103
|
+
const displayHandle = handle.startsWith("@") ? handle : `@${handle}`;
|
|
104
|
+
return /* @__PURE__ */ jsxs(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
className: "flex items-center justify-between gap-2",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsx("span", { className: "text-text-primary body-text", children: social.platform }),
|
|
110
|
+
/* @__PURE__ */ jsx(
|
|
111
|
+
"a",
|
|
112
|
+
{
|
|
113
|
+
href: url,
|
|
114
|
+
target: "_blank",
|
|
115
|
+
rel: "noopener noreferrer",
|
|
116
|
+
className: "text-primary-color-nuk-text body-text hover:underline line-clamp-2 break-words",
|
|
117
|
+
children: displayHandle
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
`${social.platform}:${social.handle ?? ""}:${social.url ?? ""}`
|
|
123
|
+
);
|
|
124
|
+
}) }) })
|
|
125
|
+
] })
|
|
126
|
+
] })
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/team/team-staff-table.tsx
|
|
132
|
+
import { useMemo, useState } from "react";
|
|
133
|
+
import {
|
|
134
|
+
BaseTable,
|
|
135
|
+
createClickableSortableHeader,
|
|
136
|
+
useInfiniteList,
|
|
137
|
+
cn as cn2
|
|
138
|
+
} from "@nukleus-sports/ui-web";
|
|
139
|
+
import { sortTeamStaff } from "@nukleus-sports/core";
|
|
140
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
141
|
+
var CATEGORY_ORDER = [
|
|
142
|
+
"Head Coaches",
|
|
143
|
+
"Assistant Coaches",
|
|
144
|
+
"Offensive Coaches",
|
|
145
|
+
"Defensive Coaches",
|
|
146
|
+
"Special Teams Coaches"
|
|
147
|
+
];
|
|
148
|
+
var UNCATEGORIZED_LABEL = "Other Coaches";
|
|
149
|
+
var DEFAULT_SORT = [{ id: "display_order", desc: false }];
|
|
150
|
+
function TeamStaffTable({
|
|
151
|
+
staff,
|
|
152
|
+
loading,
|
|
153
|
+
isError,
|
|
154
|
+
interactive = false,
|
|
155
|
+
onStaffClick,
|
|
156
|
+
sortable = false,
|
|
157
|
+
sorting,
|
|
158
|
+
onSortingChange,
|
|
159
|
+
virtualized = false,
|
|
160
|
+
isSplitLayout = false,
|
|
161
|
+
isCompact = false,
|
|
162
|
+
resolveImageUrl,
|
|
163
|
+
className
|
|
164
|
+
}) {
|
|
165
|
+
const [internalSorting, setInternalSorting] = useState(DEFAULT_SORT);
|
|
166
|
+
const activeSorting = sorting ?? internalSorting;
|
|
167
|
+
const handleSortingChange = onSortingChange ?? setInternalSorting;
|
|
168
|
+
const effectiveVirtualized = virtualized && !isSplitLayout;
|
|
169
|
+
const rows = useMemo(() => {
|
|
170
|
+
if (staff.length === 0) return [];
|
|
171
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
172
|
+
for (const member of staff) {
|
|
173
|
+
const key = member.position_group || UNCATEGORIZED_LABEL;
|
|
174
|
+
if (!grouped.has(key)) grouped.set(key, []);
|
|
175
|
+
grouped.get(key).push(member);
|
|
176
|
+
}
|
|
177
|
+
grouped.forEach((list, key) => {
|
|
178
|
+
grouped.set(key, sortTeamStaff(list, activeSorting));
|
|
179
|
+
});
|
|
180
|
+
const orderedKeys = [
|
|
181
|
+
...CATEGORY_ORDER.filter((k) => grouped.has(k)),
|
|
182
|
+
...Array.from(grouped.keys()).filter((k) => !CATEGORY_ORDER.includes(k))
|
|
183
|
+
];
|
|
184
|
+
const result = [];
|
|
185
|
+
for (const key of orderedKeys) {
|
|
186
|
+
result.push({
|
|
187
|
+
id: -1 * (result.length + 1),
|
|
188
|
+
first_name: "",
|
|
189
|
+
last_name: "",
|
|
190
|
+
position: null,
|
|
191
|
+
position_group: key,
|
|
192
|
+
coach_image_url: null,
|
|
193
|
+
display_order: 0,
|
|
194
|
+
__isCategoryRow: true,
|
|
195
|
+
__categoryLabel: key
|
|
196
|
+
});
|
|
197
|
+
result.push(...grouped.get(key));
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
}, [staff, activeSorting]);
|
|
201
|
+
const { visibleItems, sentinelRef, hasMore } = useInfiniteList(rows, {
|
|
202
|
+
resetKey: `${staff.length}|${JSON.stringify(activeSorting)}`
|
|
203
|
+
});
|
|
204
|
+
const displayedRows = effectiveVirtualized ? visibleItems : rows;
|
|
205
|
+
const columns = useMemo(() => {
|
|
206
|
+
const activate = (id) => onStaffClick?.(id);
|
|
207
|
+
const interactionProps = (id, ariaLabel) => interactive ? {
|
|
208
|
+
onClick: () => activate(id),
|
|
209
|
+
onKeyDown: (e) => {
|
|
210
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
activate(id);
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
tabIndex: 0,
|
|
216
|
+
role: "button",
|
|
217
|
+
"aria-label": ariaLabel
|
|
218
|
+
} : {};
|
|
219
|
+
const nameHeader = sortable ? createClickableSortableHeader("Name") : "Name";
|
|
220
|
+
const positionHeader = sortable ? createClickableSortableHeader("Position") : "Position";
|
|
221
|
+
return [
|
|
222
|
+
{
|
|
223
|
+
id: "name",
|
|
224
|
+
header: nameHeader,
|
|
225
|
+
accessorFn: (row) => `${row.first_name} ${row.last_name}`,
|
|
226
|
+
cell: ({ row }) => {
|
|
227
|
+
const member = row.original;
|
|
228
|
+
const fullName = `${member.first_name} ${member.last_name}`.trim();
|
|
229
|
+
const labelText = `View ${fullName}'s profile`;
|
|
230
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex gap-2 items-center w-full line-clamp-2", children: [
|
|
231
|
+
/* @__PURE__ */ jsx2(
|
|
232
|
+
"div",
|
|
233
|
+
{
|
|
234
|
+
className: cn2("flex items-center justify-center", interactive && "cursor-pointer"),
|
|
235
|
+
...interactionProps(member.id, labelText),
|
|
236
|
+
children: /* @__PURE__ */ jsx2(
|
|
237
|
+
EntityAvatar,
|
|
238
|
+
{
|
|
239
|
+
entityType: "coach",
|
|
240
|
+
entityData: {
|
|
241
|
+
first_name: member.first_name,
|
|
242
|
+
last_name: member.last_name,
|
|
243
|
+
coach_image_url: member.coach_image_url
|
|
244
|
+
},
|
|
245
|
+
resolveImageUrl,
|
|
246
|
+
size: isCompact ? "xs" : "lg"
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
/* @__PURE__ */ jsx2(
|
|
252
|
+
"div",
|
|
253
|
+
{
|
|
254
|
+
className: cn2("line-clamp-2", interactive && "cursor-pointer"),
|
|
255
|
+
...interactionProps(member.id, labelText),
|
|
256
|
+
children: fullName
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
] });
|
|
260
|
+
},
|
|
261
|
+
meta: { cellSize: isCompact ? "teamMobile" : "xl" }
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
id: "position",
|
|
265
|
+
header: positionHeader,
|
|
266
|
+
accessorFn: (row) => row.position || "-",
|
|
267
|
+
cell: ({ row }) => /* @__PURE__ */ jsx2("div", { className: "flex items-center h-full min-h-[46px]", children: /* @__PURE__ */ jsx2(
|
|
268
|
+
"span",
|
|
269
|
+
{
|
|
270
|
+
className: cn2("line-clamp-2 break-words", interactive && "cursor-pointer"),
|
|
271
|
+
...interactionProps(
|
|
272
|
+
row.original.id,
|
|
273
|
+
`View ${row.original.first_name} ${row.original.last_name}'s position`
|
|
274
|
+
),
|
|
275
|
+
children: row.original.position || "-"
|
|
276
|
+
}
|
|
277
|
+
) }),
|
|
278
|
+
meta: { cellSize: "l" }
|
|
279
|
+
}
|
|
280
|
+
];
|
|
281
|
+
}, [interactive, onStaffClick, sortable, isCompact, resolveImageUrl]);
|
|
282
|
+
return /* @__PURE__ */ jsx2("div", { className: "w-full xl:flex xl:h-full xl:flex-1 xl:min-h-0 xl:flex-col xl:overflow-hidden", children: /* @__PURE__ */ jsx2(
|
|
283
|
+
BaseTable,
|
|
284
|
+
{
|
|
285
|
+
columns,
|
|
286
|
+
data: displayedRows,
|
|
287
|
+
sorting: sortable ? activeSorting : void 0,
|
|
288
|
+
onSortingChange: sortable ? ((updater) => {
|
|
289
|
+
const next = typeof updater === "function" ? updater(activeSorting) : updater;
|
|
290
|
+
handleSortingChange(next);
|
|
291
|
+
}) : void 0,
|
|
292
|
+
manualSorting: sortable,
|
|
293
|
+
loading,
|
|
294
|
+
emptyMessage: isError ? "Failed to load coaching staff. Please try again." : "No coaches found.",
|
|
295
|
+
pageSize: Math.max(displayedRows.length, 25),
|
|
296
|
+
hidePagination: effectiveVirtualized,
|
|
297
|
+
stickyHeader: true,
|
|
298
|
+
splitLayout: isSplitLayout,
|
|
299
|
+
numberOfColumns: 1,
|
|
300
|
+
splitLayoutGridCols: isCompact ? "!grid-cols-[minmax(120px,120px)_1fr]" : isSplitLayout ? "sm:!grid-cols-[minmax(220px,220px)_1fr]" : "",
|
|
301
|
+
containerClassName: cn2("border-0 rounded-none", effectiveVirtualized && "h-full"),
|
|
302
|
+
className: cn2(
|
|
303
|
+
"border-none",
|
|
304
|
+
effectiveVirtualized && "h-full min-h-0 w-full xl:flex-1 xl:overflow-hidden",
|
|
305
|
+
className
|
|
306
|
+
),
|
|
307
|
+
bottomContent: effectiveVirtualized && hasMore ? /* @__PURE__ */ jsx2("div", { ref: sentinelRef, className: "h-px w-full" }) : null,
|
|
308
|
+
getRowBanner: (row) => row.__isCategoryRow ? row.__categoryLabel : null,
|
|
309
|
+
bannerRowClassName: "bg-greys-background-hover hover:bg-greys-background-hover",
|
|
310
|
+
getRowClassName: (row) => row.__isCategoryRow ? "hidden" : ""
|
|
311
|
+
}
|
|
312
|
+
) });
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// src/team/stat-column.tsx
|
|
316
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
317
|
+
function StatColumn({ label, value, suffix, rankBadge }) {
|
|
318
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex flex-col items-center h-full justify-center flex-1 gap-1 sm:gap-3 w-full", children: [
|
|
319
|
+
/* @__PURE__ */ jsx3("span", { className: "label-xs-medium text-text-secondary leading-normal opacity-[0.8] ss05", children: label }),
|
|
320
|
+
/* @__PURE__ */ jsxs3("span", { className: "text-[19px] font-semibold sm:text-[32px] sm:font-bold text-text-primary leading-normal title-text opacity-[0.8]", children: [
|
|
321
|
+
value,
|
|
322
|
+
suffix || ""
|
|
323
|
+
] }),
|
|
324
|
+
rankBadge
|
|
325
|
+
] });
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// src/team/team-season-stats-summary-panel.tsx
|
|
329
|
+
import { Card as Card2, CardContent as CardContent2, CardHeader, CardTitle, Skeleton, cn as cn3 } from "@nukleus-sports/ui-web";
|
|
330
|
+
import {
|
|
331
|
+
getTeamStatColumns,
|
|
332
|
+
isSupportedTeamStatsSport
|
|
333
|
+
} from "@nukleus-sports/core";
|
|
334
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
335
|
+
function getStatusMessage({
|
|
336
|
+
isSupportedSport,
|
|
337
|
+
selectedYear,
|
|
338
|
+
selectedType,
|
|
339
|
+
isError,
|
|
340
|
+
stats
|
|
341
|
+
}) {
|
|
342
|
+
if (!isSupportedSport) return "Team season stats coming soon.";
|
|
343
|
+
if (!selectedYear || selectedType === null) return "Select a season to view stats.";
|
|
344
|
+
if (isError && !stats) return "Couldn't load season stats. Please try again.";
|
|
345
|
+
if (!stats) return "No season stats for the current season.";
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
function TeamSeasonStatsSummaryPanel({
|
|
349
|
+
sportId,
|
|
350
|
+
selectedYear,
|
|
351
|
+
selectedType,
|
|
352
|
+
stats,
|
|
353
|
+
loading,
|
|
354
|
+
isError,
|
|
355
|
+
className
|
|
356
|
+
}) {
|
|
357
|
+
const columns = getTeamStatColumns(sportId);
|
|
358
|
+
const statusMessage = loading ? null : getStatusMessage({
|
|
359
|
+
isSupportedSport: isSupportedTeamStatsSport(sportId),
|
|
360
|
+
selectedYear,
|
|
361
|
+
selectedType,
|
|
362
|
+
isError,
|
|
363
|
+
stats
|
|
364
|
+
});
|
|
365
|
+
return /* @__PURE__ */ jsxs4(Card2, { className: cn3("border-0 p-4 flex flex-col gap-4", className), children: [
|
|
366
|
+
/* @__PURE__ */ jsx4(CardHeader, { className: "p-0", children: /* @__PURE__ */ jsx4(CardTitle, { className: "text-base text-text-primary font-medium leading-normal", children: "Season Stats" }) }),
|
|
367
|
+
/* @__PURE__ */ jsx4(CardContent2, { className: "p-0 flex-1 flex justify-center items-center", children: loading ? /* @__PURE__ */ jsx4("div", { className: "flex items-center justify-center w-full", children: /* @__PURE__ */ jsx4(Skeleton, { className: "h-4 w-3/4" }) }) : statusMessage ? /* @__PURE__ */ jsx4("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: statusMessage }) : stats && /* @__PURE__ */ jsx4("div", { className: "w-full flex flex-col sm:flex-row gap-6 sm:gap-3 justify-between items-center", children: columns.map((col, i) => /* @__PURE__ */ jsx4(
|
|
368
|
+
StatColumn,
|
|
369
|
+
{
|
|
370
|
+
label: col.label,
|
|
371
|
+
value: stats.values[i],
|
|
372
|
+
suffix: col.suffix
|
|
373
|
+
},
|
|
374
|
+
col.label
|
|
375
|
+
)) }) })
|
|
376
|
+
] });
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/team/team-season-schedule-summary-panel.tsx
|
|
380
|
+
import { Card as Card3, CardContent as CardContent3, CardHeader as CardHeader2, CardTitle as CardTitle2, Skeleton as Skeleton2, cn as cn4 } from "@nukleus-sports/ui-web";
|
|
381
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
382
|
+
function TeamSeasonScheduleSummaryPanel({
|
|
383
|
+
selectedYear,
|
|
384
|
+
selectedType,
|
|
385
|
+
summary,
|
|
386
|
+
loading,
|
|
387
|
+
isError,
|
|
388
|
+
className
|
|
389
|
+
}) {
|
|
390
|
+
return /* @__PURE__ */ jsxs5(Card3, { className: cn4("border-0 p-4 flex flex-col gap-4", className), children: [
|
|
391
|
+
/* @__PURE__ */ jsx5(CardHeader2, { className: "p-0", children: /* @__PURE__ */ jsx5(CardTitle2, { className: "text-base text-text-primary font-medium leading-normal", children: "Season Summary" }) }),
|
|
392
|
+
/* @__PURE__ */ jsx5(CardContent3, { className: "p-0 flex-1 flex justify-center items-center", children: loading ? /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center w-full", children: /* @__PURE__ */ jsx5(Skeleton2, { className: "h-4 w-3/4" }) }) : !selectedYear || selectedType === null ? /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "Select a season to view summary." }) : isError && !summary ? /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "Couldn't load the schedule summary. Please try again." }) : !summary ? /* @__PURE__ */ jsx5("div", { className: "flex items-center justify-center w-full text-14.5 text-text-secondary", children: "No schedule data for the current season." }) : /* @__PURE__ */ jsxs5("div", { className: "w-full flex flex-col sm:flex-row gap-6 sm:gap-3 justify-between items-center", children: [
|
|
393
|
+
/* @__PURE__ */ jsx5(StatColumn, { label: "Record", value: summary.record }),
|
|
394
|
+
/* @__PURE__ */ jsx5(
|
|
395
|
+
StatColumn,
|
|
396
|
+
{
|
|
397
|
+
label: "Games Played",
|
|
398
|
+
value: `${summary.gamesPlayed} of ${summary.totalGames}`
|
|
399
|
+
}
|
|
400
|
+
)
|
|
401
|
+
] }) })
|
|
402
|
+
] });
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/team/season-selector.tsx
|
|
406
|
+
import {
|
|
407
|
+
Select,
|
|
408
|
+
SelectContent,
|
|
409
|
+
SelectItem,
|
|
410
|
+
SelectTrigger,
|
|
411
|
+
SelectValue,
|
|
412
|
+
cn as cn5
|
|
413
|
+
} from "@nukleus-sports/ui-web";
|
|
414
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
415
|
+
function SeasonSelector({
|
|
416
|
+
years,
|
|
417
|
+
types,
|
|
418
|
+
selectedYear,
|
|
419
|
+
selectedType,
|
|
420
|
+
onYearChange,
|
|
421
|
+
onTypeChange,
|
|
422
|
+
hideTypeOnMobile = false,
|
|
423
|
+
className
|
|
424
|
+
}) {
|
|
425
|
+
return /* @__PURE__ */ jsxs6("div", { className: cn5("flex gap-3", className), children: [
|
|
426
|
+
/* @__PURE__ */ jsxs6(
|
|
427
|
+
Select,
|
|
428
|
+
{
|
|
429
|
+
value: selectedYear?.toString() ?? "",
|
|
430
|
+
onValueChange: (value) => onYearChange(Number(value)),
|
|
431
|
+
children: [
|
|
432
|
+
/* @__PURE__ */ jsx6(SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Season year", children: /* @__PURE__ */ jsx6(SelectValue, { placeholder: "Select year" }) }),
|
|
433
|
+
/* @__PURE__ */ jsx6(
|
|
434
|
+
SelectContent,
|
|
435
|
+
{
|
|
436
|
+
className: "bg-card border-border z-50 [&_.checkbox]:!flex",
|
|
437
|
+
classNameViewPort: "gap-2",
|
|
438
|
+
children: years.map((year) => /* @__PURE__ */ jsx6(SelectItem, { value: year.value.toString(), className: "min-h-8", children: year.label }, year.value))
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
/* @__PURE__ */ jsx6("div", { className: cn5(hideTypeOnMobile && "hidden sm:block"), children: /* @__PURE__ */ jsxs6(
|
|
445
|
+
Select,
|
|
446
|
+
{
|
|
447
|
+
value: selectedType?.toString() ?? "",
|
|
448
|
+
onValueChange: (value) => onTypeChange(Number(value)),
|
|
449
|
+
disabled: selectedYear === null,
|
|
450
|
+
children: [
|
|
451
|
+
/* @__PURE__ */ jsx6(SelectTrigger, { variant: "widget", size: "widget", "aria-label": "Season type", children: /* @__PURE__ */ jsx6(SelectValue, { placeholder: "Select type" }) }),
|
|
452
|
+
/* @__PURE__ */ jsx6(
|
|
453
|
+
SelectContent,
|
|
454
|
+
{
|
|
455
|
+
className: "bg-card border-border z-50 [&_.checkbox]:!flex",
|
|
456
|
+
classNameViewPort: "gap-2",
|
|
457
|
+
children: types.map((type) => /* @__PURE__ */ jsx6(SelectItem, { value: type.value.toString(), className: "min-h-8", children: type.label }, type.value))
|
|
458
|
+
}
|
|
459
|
+
)
|
|
460
|
+
]
|
|
461
|
+
}
|
|
462
|
+
) })
|
|
463
|
+
] });
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// src/team/fact-pills.tsx
|
|
467
|
+
import { useId, useLayoutEffect, useRef, useState as useState2 } from "react";
|
|
468
|
+
import { cn as cn6 } from "@nukleus-sports/ui-web";
|
|
469
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
470
|
+
var MAX_ROWS = 2;
|
|
471
|
+
var KEY_SEPARATOR = "";
|
|
472
|
+
var PILL_CLASS = "flex min-w-0 max-w-full shrink-0 items-center justify-center rounded-[6px] bg-greys-background-hover px-2 py-0.5 label-xs-table font-ss02-ss05 text-text-primary";
|
|
473
|
+
var TOGGLE_CLASS = "flex shrink-0 items-center py-0.5 label-xs-table font-ss02-ss05 text-primary-color-nuk-text hover:underline focus-visible:underline focus-visible:outline-none";
|
|
474
|
+
function pillKeys(items) {
|
|
475
|
+
const seen = /* @__PURE__ */ new Map();
|
|
476
|
+
return items.map((item) => {
|
|
477
|
+
const text = String(item);
|
|
478
|
+
const count = seen.get(text) ?? 0;
|
|
479
|
+
seen.set(text, count + 1);
|
|
480
|
+
return `${text}${KEY_SEPARATOR}${count}`;
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
function FactPills({ items, capped = false }) {
|
|
484
|
+
const listId = useId();
|
|
485
|
+
const listRef = useRef(null);
|
|
486
|
+
const [expanded, setExpanded] = useState2(false);
|
|
487
|
+
const [visibleCount, setVisibleCount] = useState2(null);
|
|
488
|
+
const [clipHeight, setClipHeight] = useState2(null);
|
|
489
|
+
const [width, setWidth] = useState2(0);
|
|
490
|
+
const contentKey = items.join(KEY_SEPARATOR);
|
|
491
|
+
const keys = pillKeys(items);
|
|
492
|
+
const collapsible = capped && !expanded;
|
|
493
|
+
useLayoutEffect(() => {
|
|
494
|
+
const list = listRef.current;
|
|
495
|
+
if (!capped || !list || typeof ResizeObserver === "undefined") return;
|
|
496
|
+
const observer = new ResizeObserver((entries) => {
|
|
497
|
+
const next = Math.round(entries[0]?.contentRect.width ?? 0);
|
|
498
|
+
setWidth((prev) => prev === next ? prev : next);
|
|
499
|
+
});
|
|
500
|
+
observer.observe(list);
|
|
501
|
+
return () => observer.disconnect();
|
|
502
|
+
}, [capped]);
|
|
503
|
+
const measurementKey = `${width}:${contentKey}`;
|
|
504
|
+
const [measuredFor, setMeasuredFor] = useState2(measurementKey);
|
|
505
|
+
if (measuredFor !== measurementKey) {
|
|
506
|
+
setMeasuredFor(measurementKey);
|
|
507
|
+
if (visibleCount !== null) setVisibleCount(null);
|
|
508
|
+
}
|
|
509
|
+
useLayoutEffect(() => {
|
|
510
|
+
const list = listRef.current;
|
|
511
|
+
if (!collapsible || !list) return;
|
|
512
|
+
const children = Array.from(list.children).filter(
|
|
513
|
+
(el) => el instanceof HTMLElement
|
|
514
|
+
);
|
|
515
|
+
const first = children[0];
|
|
516
|
+
if (!first || first.offsetHeight === 0) return;
|
|
517
|
+
const rowGap = Number.parseFloat(getComputedStyle(list).rowGap) || 0;
|
|
518
|
+
const rowStep = first.offsetHeight + rowGap;
|
|
519
|
+
const lastRowTop = first.offsetTop + rowStep * (MAX_ROWS - 1);
|
|
520
|
+
const fits = (el) => el.offsetTop <= lastRowTop + 1;
|
|
521
|
+
if (visibleCount === null) {
|
|
522
|
+
const nextClip = Math.ceil(rowStep * MAX_ROWS - rowGap);
|
|
523
|
+
setClipHeight((prev) => prev === nextClip ? prev : nextClip);
|
|
524
|
+
const fitting = children.filter(fits).length;
|
|
525
|
+
if (fitting < items.length) setVisibleCount(fitting);
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
const toggle = children[children.length - 1];
|
|
529
|
+
if (toggle && !fits(toggle)) {
|
|
530
|
+
setVisibleCount((prev) => prev !== null && prev > 0 ? prev - 1 : prev);
|
|
531
|
+
}
|
|
532
|
+
}, [collapsible, visibleCount, contentKey, items.length, width]);
|
|
533
|
+
const truncated = collapsible && visibleCount !== null && visibleCount < items.length;
|
|
534
|
+
const shownCount = truncated ? visibleCount : items.length;
|
|
535
|
+
const handleShowMore = () => setExpanded(true);
|
|
536
|
+
const handleShowLess = () => {
|
|
537
|
+
setExpanded(false);
|
|
538
|
+
setVisibleCount(null);
|
|
539
|
+
};
|
|
540
|
+
return /* @__PURE__ */ jsxs7(
|
|
541
|
+
"ul",
|
|
542
|
+
{
|
|
543
|
+
id: listId,
|
|
544
|
+
ref: listRef,
|
|
545
|
+
className: cn6(
|
|
546
|
+
"flex w-full flex-wrap content-start items-start gap-1",
|
|
547
|
+
collapsible && "overflow-hidden"
|
|
548
|
+
),
|
|
549
|
+
style: collapsible && clipHeight !== null ? { maxHeight: clipHeight } : void 0,
|
|
550
|
+
children: [
|
|
551
|
+
items.slice(0, shownCount).map((item, index) => /* @__PURE__ */ jsx7("li", { className: PILL_CLASS, title: String(item), children: /* @__PURE__ */ jsx7("span", { className: "truncate", children: item }) }, keys[index])),
|
|
552
|
+
truncated && /* @__PURE__ */ jsx7("li", { className: "flex shrink-0", children: /* @__PURE__ */ jsx7(
|
|
553
|
+
"button",
|
|
554
|
+
{
|
|
555
|
+
type: "button",
|
|
556
|
+
className: TOGGLE_CLASS,
|
|
557
|
+
"aria-expanded": false,
|
|
558
|
+
"aria-controls": listId,
|
|
559
|
+
onClick: handleShowMore,
|
|
560
|
+
children: "Show More"
|
|
561
|
+
}
|
|
562
|
+
) }),
|
|
563
|
+
capped && expanded && /* @__PURE__ */ jsx7("li", { className: "flex shrink-0", children: /* @__PURE__ */ jsx7(
|
|
564
|
+
"button",
|
|
565
|
+
{
|
|
566
|
+
type: "button",
|
|
567
|
+
className: TOGGLE_CLASS,
|
|
568
|
+
"aria-expanded": true,
|
|
569
|
+
"aria-controls": listId,
|
|
570
|
+
onClick: handleShowLess,
|
|
571
|
+
children: "Show Less"
|
|
572
|
+
}
|
|
573
|
+
) })
|
|
574
|
+
]
|
|
575
|
+
}
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/team/fact-field.tsx
|
|
580
|
+
import { Skeleton as Skeleton3, cn as cn7 } from "@nukleus-sports/ui-web";
|
|
581
|
+
import {
|
|
582
|
+
EMPTY_FACT_VALUE,
|
|
583
|
+
formatTeamFactNumber,
|
|
584
|
+
formatYearPills,
|
|
585
|
+
TEAM_FACT_KINDS,
|
|
586
|
+
TEAM_FACT_YEAR_PAIRS
|
|
587
|
+
} from "@nukleus-sports/core";
|
|
588
|
+
import { Fragment, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
589
|
+
function numberFact(facts, key) {
|
|
590
|
+
const value = facts[key];
|
|
591
|
+
return typeof value === "number" ? value : null;
|
|
592
|
+
}
|
|
593
|
+
function listFact(facts, key) {
|
|
594
|
+
const value = facts[key];
|
|
595
|
+
return Array.isArray(value) ? value : [];
|
|
596
|
+
}
|
|
597
|
+
function textFact(facts, key) {
|
|
598
|
+
const value = facts[key];
|
|
599
|
+
return typeof value === "string" ? value : null;
|
|
600
|
+
}
|
|
601
|
+
function EmptyValue({ children = EMPTY_FACT_VALUE }) {
|
|
602
|
+
return /* @__PURE__ */ jsx8("span", { className: "body-text font-ss02-ss05 text-text-secondary", children });
|
|
603
|
+
}
|
|
604
|
+
function FieldLabel({ children }) {
|
|
605
|
+
return /* @__PURE__ */ jsx8("span", { className: "w-full label-xs-text font-ss02-ss05 text-text-secondary", children });
|
|
606
|
+
}
|
|
607
|
+
function CountFact({
|
|
608
|
+
factKey,
|
|
609
|
+
data
|
|
610
|
+
}) {
|
|
611
|
+
const { facts, config } = data;
|
|
612
|
+
const pairedYears = TEAM_FACT_YEAR_PAIRS[factKey];
|
|
613
|
+
const years = pairedYears ? formatYearPills(listFact(facts, pairedYears), config.formatChampionshipYear) : [];
|
|
614
|
+
return /* @__PURE__ */ jsxs8("div", { className: "flex min-w-0 flex-col items-start gap-1", children: [
|
|
615
|
+
/* @__PURE__ */ jsx8(FieldLabel, { children: config.labels[factKey] }),
|
|
616
|
+
/* @__PURE__ */ jsx8("span", { className: "stat-count-number title-text text-text-primary", children: formatTeamFactNumber("count", numberFact(facts, factKey)) }),
|
|
617
|
+
years.length > 0 && /* @__PURE__ */ jsx8(FactPills, { items: years, capped: true })
|
|
618
|
+
] });
|
|
619
|
+
}
|
|
620
|
+
function RivalValue({
|
|
621
|
+
rival,
|
|
622
|
+
resolveImageUrl,
|
|
623
|
+
getRivalHref
|
|
624
|
+
}) {
|
|
625
|
+
switch (rival.status) {
|
|
626
|
+
case "none":
|
|
627
|
+
return /* @__PURE__ */ jsx8(EmptyValue, {});
|
|
628
|
+
case "loading":
|
|
629
|
+
return /* @__PURE__ */ jsx8(Skeleton3, { className: "h-8 w-40", "aria-label": "Loading rival" });
|
|
630
|
+
case "error":
|
|
631
|
+
return /* @__PURE__ */ jsx8(EmptyValue, { children: "Couldn't load the rival team" });
|
|
632
|
+
case "ready": {
|
|
633
|
+
const content = /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
634
|
+
/* @__PURE__ */ jsx8(
|
|
635
|
+
EntityAvatar,
|
|
636
|
+
{
|
|
637
|
+
entityType: "initials",
|
|
638
|
+
name: rival.rival.name,
|
|
639
|
+
imageUrl: rival.rival.teamLogoUrl,
|
|
640
|
+
resolveImageUrl,
|
|
641
|
+
size: "md",
|
|
642
|
+
className: "shrink-0"
|
|
643
|
+
}
|
|
644
|
+
),
|
|
645
|
+
/* @__PURE__ */ jsx8("span", { className: "min-w-0", children: rival.rival.name })
|
|
646
|
+
] });
|
|
647
|
+
const className = "inline-flex max-w-full items-center gap-1.5 body-text-semibold font-ss02-ss05 text-primary-color-nuk-text";
|
|
648
|
+
return getRivalHref ? /* @__PURE__ */ jsx8("a", { href: getRivalHref(rival.rival.id), className: cn7(className, "hover:underline"), children: content }) : /* @__PURE__ */ jsx8("span", { className, children: content });
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
function factValue(factKey, layout, data, resolveImageUrl, getRivalHref) {
|
|
653
|
+
const { facts, config } = data;
|
|
654
|
+
const kind = TEAM_FACT_KINDS[factKey];
|
|
655
|
+
if (kind === "number" || kind === "year" || kind === "text") {
|
|
656
|
+
const display = kind === "text" ? textFact(facts, factKey) : formatTeamFactNumber(kind, numberFact(facts, factKey));
|
|
657
|
+
const isEmpty = !display || display === EMPTY_FACT_VALUE;
|
|
658
|
+
return /* @__PURE__ */ jsx8(
|
|
659
|
+
"span",
|
|
660
|
+
{
|
|
661
|
+
className: cn7(
|
|
662
|
+
"w-full header-xl-medium-card font-ss02-ss05 [overflow-wrap:anywhere]",
|
|
663
|
+
isEmpty ? "text-text-secondary" : "text-text-primary"
|
|
664
|
+
),
|
|
665
|
+
children: display ?? EMPTY_FACT_VALUE
|
|
666
|
+
}
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
if (kind === "years" || kind === "labeled_years" || kind === "list") {
|
|
670
|
+
const raw = listFact(facts, factKey);
|
|
671
|
+
const items = kind === "years" ? formatYearPills(raw, config.formatChampionshipYear) : raw;
|
|
672
|
+
return items.length > 0 ? /* @__PURE__ */ jsx8(FactPills, { items, capped: layout === "grid" }) : /* @__PURE__ */ jsx8(EmptyValue, {});
|
|
673
|
+
}
|
|
674
|
+
if (kind === "rival") {
|
|
675
|
+
return /* @__PURE__ */ jsx8(
|
|
676
|
+
RivalValue,
|
|
677
|
+
{
|
|
678
|
+
rival: data.rival,
|
|
679
|
+
resolveImageUrl,
|
|
680
|
+
getRivalHref
|
|
681
|
+
}
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
const text = textFact(facts, factKey);
|
|
685
|
+
return /* @__PURE__ */ jsx8(
|
|
686
|
+
"p",
|
|
687
|
+
{
|
|
688
|
+
className: cn7(
|
|
689
|
+
"w-full body-text font-ss02-ss05 whitespace-pre-line",
|
|
690
|
+
text ? "text-text-primary" : "text-text-secondary"
|
|
691
|
+
),
|
|
692
|
+
children: text ?? EMPTY_FACT_VALUE
|
|
693
|
+
}
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
function FactField({
|
|
697
|
+
factKey,
|
|
698
|
+
layout,
|
|
699
|
+
data,
|
|
700
|
+
resolveImageUrl,
|
|
701
|
+
getRivalHref
|
|
702
|
+
}) {
|
|
703
|
+
const kind = TEAM_FACT_KINDS[factKey];
|
|
704
|
+
if (kind === "count") return /* @__PURE__ */ jsx8(CountFact, { factKey, data });
|
|
705
|
+
return /* @__PURE__ */ jsxs8(
|
|
706
|
+
"div",
|
|
707
|
+
{
|
|
708
|
+
className: cn7(
|
|
709
|
+
"flex min-w-0 flex-col items-start gap-1.5",
|
|
710
|
+
layout === "row" && "flex-1",
|
|
711
|
+
layout === "grid" && kind !== "list" && "gap-1"
|
|
712
|
+
),
|
|
713
|
+
children: [
|
|
714
|
+
/* @__PURE__ */ jsx8(FieldLabel, { children: data.config.labels[factKey] }),
|
|
715
|
+
factValue(factKey, layout, data, resolveImageUrl, getRivalHref)
|
|
716
|
+
]
|
|
717
|
+
}
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// src/team/venue-photo.tsx
|
|
722
|
+
import { useState as useState3 } from "react";
|
|
723
|
+
import { cn as cn8 } from "@nukleus-sports/ui-web";
|
|
724
|
+
import { XsViewInvoiceIcon } from "@nukleus-sports/icons";
|
|
725
|
+
import { facilityImageCredit } from "@nukleus-sports/core";
|
|
726
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
727
|
+
var PHOTO_WIDTHS = [640, 960, 1280];
|
|
728
|
+
var PHOTO_SIZES = "(min-width: 1280px) 420px, 100vw";
|
|
729
|
+
var LINK_CLASS = "inline-flex shrink-0 items-center gap-1 hover:text-text-primary";
|
|
730
|
+
function NewTabNote() {
|
|
731
|
+
return /* @__PURE__ */ jsx9("span", { className: "sr-only", children: " (opens in a new tab)" });
|
|
732
|
+
}
|
|
733
|
+
function resolvePhotoSources(path, resolveImageUrl) {
|
|
734
|
+
const candidates = PHOTO_WIDTHS.flatMap((width) => {
|
|
735
|
+
const url = resolveImageUrl(path, width);
|
|
736
|
+
return url ? [{ url, width }] : [];
|
|
737
|
+
});
|
|
738
|
+
return {
|
|
739
|
+
original: resolveImageUrl(path) ?? void 0,
|
|
740
|
+
srcSet: candidates.length ? candidates.map(({ url, width }) => `${url} ${width}w`).join(", ") : void 0,
|
|
741
|
+
resized: resolveImageUrl(path, 960) ?? candidates[0]?.url
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function VenueNameOnly({ name, label }) {
|
|
745
|
+
if (!name) return null;
|
|
746
|
+
return /* @__PURE__ */ jsxs9("div", { className: "flex min-w-0 flex-col items-start gap-1.5", children: [
|
|
747
|
+
/* @__PURE__ */ jsx9(FieldLabel, { children: label }),
|
|
748
|
+
/* @__PURE__ */ jsx9("span", { className: "w-full header-xl-medium-card font-ss02-ss05 text-text-primary", children: name })
|
|
749
|
+
] });
|
|
750
|
+
}
|
|
751
|
+
function PhotoCaption({ name, image }) {
|
|
752
|
+
const credit = facilityImageCredit(image);
|
|
753
|
+
return /* @__PURE__ */ jsxs9("figcaption", { className: "flex w-full flex-col gap-1 xxs-body-text font-ss02-ss05", children: [
|
|
754
|
+
name && /* @__PURE__ */ jsx9("span", { className: "w-full text-text-primary", children: name }),
|
|
755
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex w-full items-start gap-2 text-greys-text-secondary", children: [
|
|
756
|
+
/* @__PURE__ */ jsx9("span", { className: "min-w-0 flex-1", children: credit ? `Photo: ${credit}` : "Photo from Wikimedia Commons" }),
|
|
757
|
+
image.sourceUrl && /* @__PURE__ */ jsxs9(
|
|
758
|
+
"a",
|
|
759
|
+
{
|
|
760
|
+
href: image.sourceUrl,
|
|
761
|
+
target: "_blank",
|
|
762
|
+
rel: "noopener noreferrer",
|
|
763
|
+
className: LINK_CLASS,
|
|
764
|
+
children: [
|
|
765
|
+
"Source",
|
|
766
|
+
/* @__PURE__ */ jsx9(NewTabNote, {}),
|
|
767
|
+
/* @__PURE__ */ jsx9("span", { "aria-hidden": "true", className: "flex shrink-0", children: /* @__PURE__ */ jsx9(
|
|
768
|
+
XsViewInvoiceIcon,
|
|
769
|
+
{
|
|
770
|
+
width: 16,
|
|
771
|
+
height: 16,
|
|
772
|
+
className: "shrink-0 text-greys-ui-elem-strokes"
|
|
773
|
+
}
|
|
774
|
+
) })
|
|
775
|
+
]
|
|
776
|
+
}
|
|
777
|
+
),
|
|
778
|
+
image.licenseUrl && /* @__PURE__ */ jsxs9(
|
|
779
|
+
"a",
|
|
780
|
+
{
|
|
781
|
+
href: image.licenseUrl,
|
|
782
|
+
target: "_blank",
|
|
783
|
+
rel: "noopener noreferrer",
|
|
784
|
+
className: LINK_CLASS,
|
|
785
|
+
children: [
|
|
786
|
+
"License",
|
|
787
|
+
/* @__PURE__ */ jsx9(NewTabNote, {})
|
|
788
|
+
]
|
|
789
|
+
}
|
|
790
|
+
)
|
|
791
|
+
] })
|
|
792
|
+
] });
|
|
793
|
+
}
|
|
794
|
+
function VenuePhoto({ venue, label, resolveImageUrl }) {
|
|
795
|
+
const { name, image } = venue;
|
|
796
|
+
const [failed, setFailed] = useState3("none");
|
|
797
|
+
const [isLoaded, setIsLoaded] = useState3(false);
|
|
798
|
+
const sources = image && resolveImageUrl ? resolvePhotoSources(image.path, resolveImageUrl) : null;
|
|
799
|
+
const useResized = failed === "none" && Boolean(sources?.srcSet);
|
|
800
|
+
const src = failed === "all" ? void 0 : useResized ? sources?.resized : sources?.original;
|
|
801
|
+
if (!image || !src) return /* @__PURE__ */ jsx9(VenueNameOnly, { name, label });
|
|
802
|
+
return /* @__PURE__ */ jsxs9("figure", { className: "flex w-full flex-col gap-3", children: [
|
|
803
|
+
/* @__PURE__ */ jsx9(
|
|
804
|
+
"img",
|
|
805
|
+
{
|
|
806
|
+
src,
|
|
807
|
+
srcSet: useResized ? sources?.srcSet : void 0,
|
|
808
|
+
sizes: useResized ? PHOTO_SIZES : void 0,
|
|
809
|
+
onLoad: () => setIsLoaded(true),
|
|
810
|
+
onError: () => setFailed(useResized ? "resized" : "all"),
|
|
811
|
+
alt: name ?? label,
|
|
812
|
+
className: cn8(
|
|
813
|
+
"h-[150px] w-full rounded-[8px] bg-greys-background-hover object-cover",
|
|
814
|
+
!isLoaded && "animate-pulse"
|
|
815
|
+
),
|
|
816
|
+
loading: "lazy"
|
|
817
|
+
}
|
|
818
|
+
),
|
|
819
|
+
/* @__PURE__ */ jsx9(PhotoCaption, { name, image })
|
|
820
|
+
] });
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// src/team/team-facts-content.tsx
|
|
824
|
+
import {
|
|
825
|
+
teamFactsDisplayFields
|
|
826
|
+
} from "@nukleus-sports/core";
|
|
827
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
828
|
+
var SECTION_FIELDS_CLASS = {
|
|
829
|
+
grid: "grid grid-cols-2 items-start gap-3",
|
|
830
|
+
row: "flex items-start gap-3",
|
|
831
|
+
column: "flex flex-col gap-3"
|
|
832
|
+
};
|
|
833
|
+
var SECTION_CLASS = (
|
|
834
|
+
// 11px + the 1px border = a 12px inset.
|
|
835
|
+
"flex w-full min-w-0 flex-col gap-3 overflow-hidden rounded-[10px] border border-greys-grey-strokes-tables bg-greys-light-grey p-3"
|
|
836
|
+
);
|
|
837
|
+
function TeamFactsContent({
|
|
838
|
+
data,
|
|
839
|
+
resolveImageUrl,
|
|
840
|
+
resolveVenuePhotoUrl,
|
|
841
|
+
getRivalHref
|
|
842
|
+
}) {
|
|
843
|
+
const { config, venue, hasFacts } = data;
|
|
844
|
+
const photo = /* @__PURE__ */ jsx10(
|
|
845
|
+
VenuePhoto,
|
|
846
|
+
{
|
|
847
|
+
venue,
|
|
848
|
+
label: config.venue.label,
|
|
849
|
+
resolveImageUrl: resolveVenuePhotoUrl
|
|
850
|
+
},
|
|
851
|
+
venue.image?.path ?? "none"
|
|
852
|
+
);
|
|
853
|
+
if (!hasFacts) {
|
|
854
|
+
return /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-3", children: [
|
|
855
|
+
/* @__PURE__ */ jsx10("div", { className: "flex h-[120px] items-center justify-center rounded-[10px] border border-dashed border-greys-grey-strokes-tables text-14.5 text-text-secondary", children: "No team facts yet." }),
|
|
856
|
+
(venue.image || venue.name) && /* @__PURE__ */ jsx10("section", { className: SECTION_CLASS, children: photo })
|
|
857
|
+
] });
|
|
858
|
+
}
|
|
859
|
+
return /* @__PURE__ */ jsx10("div", { className: "flex flex-col gap-3", children: config.sections.map((section) => /* @__PURE__ */ jsxs10("section", { "aria-label": section.title, className: SECTION_CLASS, children: [
|
|
860
|
+
/* @__PURE__ */ jsx10("h3", { className: "label-xs-semibold-text font-ss02-ss05 uppercase text-greys-text-secondary", children: section.title }),
|
|
861
|
+
/* @__PURE__ */ jsx10("div", { className: SECTION_FIELDS_CLASS[section.layout], children: teamFactsDisplayFields(section).map((key) => /* @__PURE__ */ jsx10(
|
|
862
|
+
FactField,
|
|
863
|
+
{
|
|
864
|
+
factKey: key,
|
|
865
|
+
layout: section.layout,
|
|
866
|
+
data,
|
|
867
|
+
resolveImageUrl,
|
|
868
|
+
getRivalHref
|
|
869
|
+
},
|
|
870
|
+
key
|
|
871
|
+
)) }),
|
|
872
|
+
section.showsVenuePhoto && photo
|
|
873
|
+
] }, section.title)) });
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// src/team/team-facts-widget.tsx
|
|
877
|
+
import {
|
|
878
|
+
Button,
|
|
879
|
+
Card as Card4,
|
|
880
|
+
CardContent as CardContent4,
|
|
881
|
+
CardHeader as CardHeader3,
|
|
882
|
+
CardTitle as CardTitle3,
|
|
883
|
+
Skeleton as Skeleton4,
|
|
884
|
+
cn as cn9
|
|
885
|
+
} from "@nukleus-sports/ui-web";
|
|
886
|
+
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
887
|
+
var SKELETON_KEYS = ["trophy-case", "tradition", "profile"];
|
|
888
|
+
function TeamFactsWidget({
|
|
889
|
+
state,
|
|
890
|
+
resolveImageUrl,
|
|
891
|
+
resolveVenuePhotoUrl,
|
|
892
|
+
getRivalHref,
|
|
893
|
+
className
|
|
894
|
+
}) {
|
|
895
|
+
return /* @__PURE__ */ jsxs11(
|
|
896
|
+
Card4,
|
|
897
|
+
{
|
|
898
|
+
className: cn9(
|
|
899
|
+
"flex w-full min-w-0 flex-col gap-3 rounded-[10px] border-0 px-4 pb-[22px] pt-4",
|
|
900
|
+
// Matches the Team Info card's desktop height (TeamInfoCard `md:min-h-[612px]`).
|
|
901
|
+
"xl:min-h-[612px] xl:self-stretch xl:[contain:size]",
|
|
902
|
+
className
|
|
903
|
+
),
|
|
904
|
+
children: [
|
|
905
|
+
/* @__PURE__ */ jsx11(CardHeader3, { className: "flex h-8 shrink-0 flex-row items-center p-0", children: /* @__PURE__ */ jsx11(CardTitle3, { className: "header-xl-medium-card font-ss02-ss05 text-text-primary", children: "Team Facts" }) }),
|
|
906
|
+
/* @__PURE__ */ jsxs11(CardContent4, { className: "p-0 xl:min-h-0 xl:flex-1 xl:overflow-y-auto xl:[scrollbar-width:none] xl:[&::-webkit-scrollbar]:hidden", children: [
|
|
907
|
+
state.status === "loading" && /* @__PURE__ */ jsx11("div", { className: "flex flex-col gap-3", role: "status", "aria-label": "Loading team facts", children: SKELETON_KEYS.map((key) => /* @__PURE__ */ jsx11(Skeleton4, { className: "h-[200px] w-full rounded-[10px]" }, key)) }),
|
|
908
|
+
state.status === "error" && /* @__PURE__ */ jsxs11(
|
|
909
|
+
"div",
|
|
910
|
+
{
|
|
911
|
+
role: "alert",
|
|
912
|
+
className: "flex h-[120px] flex-col items-center justify-center gap-2 text-14.5 text-text-secondary",
|
|
913
|
+
children: [
|
|
914
|
+
/* @__PURE__ */ jsx11("span", { children: "Couldn't load team facts." }),
|
|
915
|
+
state.devMessage && /* @__PURE__ */ jsx11("span", { className: "xxs-body-text", children: state.devMessage }),
|
|
916
|
+
state.retry && /* @__PURE__ */ jsx11(Button, { type: "button", variant: "outline", size: "sm", onClick: state.retry, children: "Try again" })
|
|
917
|
+
]
|
|
918
|
+
}
|
|
919
|
+
),
|
|
920
|
+
state.status === "ready" && /* @__PURE__ */ jsx11(
|
|
921
|
+
TeamFactsContent,
|
|
922
|
+
{
|
|
923
|
+
data: state.data,
|
|
924
|
+
resolveImageUrl,
|
|
925
|
+
resolveVenuePhotoUrl,
|
|
926
|
+
getRivalHref
|
|
927
|
+
},
|
|
928
|
+
state.data.teamId
|
|
929
|
+
)
|
|
930
|
+
] })
|
|
931
|
+
]
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// src/team/stat-ranking-leaderboard-dialog.tsx
|
|
937
|
+
import { useMemo as useMemo2 } from "react";
|
|
938
|
+
import {
|
|
939
|
+
BaseTable as BaseTable2,
|
|
940
|
+
Button as Button2,
|
|
941
|
+
Dialog,
|
|
942
|
+
DialogContent,
|
|
943
|
+
DialogDescription,
|
|
944
|
+
DialogHeader,
|
|
945
|
+
DialogTitle,
|
|
946
|
+
MobileModalLayout,
|
|
947
|
+
cn as cn10
|
|
948
|
+
} from "@nukleus-sports/ui-web";
|
|
949
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "@nukleus-sports/icons";
|
|
950
|
+
import { toOrdinal } from "@nukleus-sports/core";
|
|
951
|
+
import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
952
|
+
var PAGE_BUTTON_BASE = "background";
|
|
953
|
+
var PAGE_BUTTON_DESKTOP = "!h-[32px] !w-[32px] p-[6px]";
|
|
954
|
+
var PAGE_BUTTON_MOBILE = "!h-11 !w-11 p-3 !outline-0 !border-0 !bg-inherit";
|
|
955
|
+
var HIGHLIGHT_CLASS = "text-semantic-color-status-priority-completed-copy bg-primary-color-total-row-table-2";
|
|
956
|
+
function formatRank(rank, tied) {
|
|
957
|
+
return tied ? `T-${toOrdinal(rank)}` : toOrdinal(rank);
|
|
958
|
+
}
|
|
959
|
+
function Footnotes({ notes }) {
|
|
960
|
+
return /* @__PURE__ */ jsx12("div", { children: notes.map((note) => /* @__PURE__ */ jsxs12("p", { className: "alert-text-italic text-text-secondary", children: [
|
|
961
|
+
"* ",
|
|
962
|
+
note
|
|
963
|
+
] }, note)) });
|
|
964
|
+
}
|
|
965
|
+
function Pagination({ page, totalPages, isCountKnown, isSm, onPageChange }) {
|
|
966
|
+
const buttonClass = cn10(PAGE_BUTTON_BASE, isSm ? PAGE_BUTTON_DESKTOP : PAGE_BUTTON_MOBILE);
|
|
967
|
+
return /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between", children: [
|
|
968
|
+
/* @__PURE__ */ jsx12("span", { className: "label-xs-text text-text-secondary", children: isCountKnown ? `Page ${page} of ${totalPages}` : `Page ${page}` }),
|
|
969
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-3", children: [
|
|
970
|
+
/* @__PURE__ */ jsx12(
|
|
971
|
+
Button2,
|
|
972
|
+
{
|
|
973
|
+
variant: "secondary-greys",
|
|
974
|
+
size: "sm",
|
|
975
|
+
className: buttonClass,
|
|
976
|
+
onClick: () => onPageChange(Math.max(1, page - 1)),
|
|
977
|
+
disabled: page === 1,
|
|
978
|
+
"aria-label": "Go to previous page",
|
|
979
|
+
children: /* @__PURE__ */ jsx12(ChevronLeftIcon, { className: "h-4 w-4" })
|
|
980
|
+
}
|
|
981
|
+
),
|
|
982
|
+
/* @__PURE__ */ jsx12(
|
|
983
|
+
Button2,
|
|
984
|
+
{
|
|
985
|
+
variant: "secondary-greys",
|
|
986
|
+
size: "sm",
|
|
987
|
+
className: buttonClass,
|
|
988
|
+
onClick: () => onPageChange(Math.min(totalPages, page + 1)),
|
|
989
|
+
disabled: !isCountKnown || page >= totalPages,
|
|
990
|
+
"aria-label": "Go to next page",
|
|
991
|
+
children: /* @__PURE__ */ jsx12(ChevronRightIcon, { className: "h-4 w-4" })
|
|
992
|
+
}
|
|
993
|
+
)
|
|
994
|
+
] })
|
|
995
|
+
] });
|
|
996
|
+
}
|
|
997
|
+
function useLeaderboardColumns(entityLabel, statLabel, formatValue, isSm) {
|
|
998
|
+
return useMemo2(
|
|
999
|
+
() => [
|
|
1000
|
+
{
|
|
1001
|
+
accessorKey: "rank",
|
|
1002
|
+
header: "Rank",
|
|
1003
|
+
// BaseTable already wraps every cell in its own <TableCell>; returning another here would
|
|
1004
|
+
// nest <td>s. Column styling goes through rowCellClassName (the row highlight is the
|
|
1005
|
+
// table's getRowClassName).
|
|
1006
|
+
meta: { cellSize: "xs", rowCellClassName: "tabular-nums" },
|
|
1007
|
+
cell: ({ row }) => formatRank(row.original.rank, row.original.tied)
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
accessorKey: "entityName",
|
|
1011
|
+
header: entityLabel,
|
|
1012
|
+
meta: { cellSize: isSm ? "xxl" : "m" },
|
|
1013
|
+
cell: ({ row }) => row.original.entityName
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
accessorKey: "value",
|
|
1017
|
+
header: () => /* @__PURE__ */ jsx12("div", { className: "text-right text-wrap line-clamp-2", title: statLabel, children: statLabel }),
|
|
1018
|
+
meta: {
|
|
1019
|
+
cellSize: isSm ? "m" : "xs",
|
|
1020
|
+
rowCellClassName: "text-right tabular-nums break-all"
|
|
1021
|
+
},
|
|
1022
|
+
cell: ({ row }) => formatValue(row.original.value)
|
|
1023
|
+
}
|
|
1024
|
+
],
|
|
1025
|
+
[entityLabel, statLabel, formatValue, isSm]
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
function LeaderboardTable(props) {
|
|
1029
|
+
const { rows, highlightEntityId, pageSize, loading, isError, isConfigError } = props;
|
|
1030
|
+
const columns = useLeaderboardColumns(
|
|
1031
|
+
props.entityLabel,
|
|
1032
|
+
props.statLabel,
|
|
1033
|
+
props.formatValue,
|
|
1034
|
+
props.isSm
|
|
1035
|
+
);
|
|
1036
|
+
if (isConfigError) {
|
|
1037
|
+
return /* @__PURE__ */ jsx12("div", { className: "flex items-center justify-center h-full text-14.5 text-text-secondary", children: "Couldn't load ranking details. Please try again." });
|
|
1038
|
+
}
|
|
1039
|
+
return /* @__PURE__ */ jsxs12(Fragment2, { children: [
|
|
1040
|
+
isError && rows.length > 0 && /* @__PURE__ */ jsx12("p", { className: "text-12 text-destructive px-1 pb-2", children: "Couldn't refresh rankings. Showing the last loaded data." }),
|
|
1041
|
+
/* @__PURE__ */ jsx12(
|
|
1042
|
+
BaseTable2,
|
|
1043
|
+
{
|
|
1044
|
+
columns,
|
|
1045
|
+
data: rows,
|
|
1046
|
+
loading,
|
|
1047
|
+
pageSize,
|
|
1048
|
+
stickyHeader: true,
|
|
1049
|
+
numberOfColumns: 2,
|
|
1050
|
+
tableClassName: "!border-separate border-spacing-0 !overflow-visible",
|
|
1051
|
+
containerClassName: "border-0 rounded-none w-full !overflow-visible [&_div.overflow-auto]:!overflow-visible [&_div.overflow-auto]:!h-auto",
|
|
1052
|
+
className: "w-full",
|
|
1053
|
+
emptyMessage: isError ? "Couldn't load ranking data. Please try again." : "No ranking data available.",
|
|
1054
|
+
getRowId: (row) => `${row.entityId}-${row.rank}`,
|
|
1055
|
+
getRowClassName: (row) => highlightEntityId != null && row.entityId === highlightEntityId ? HIGHLIGHT_CLASS : ""
|
|
1056
|
+
}
|
|
1057
|
+
)
|
|
1058
|
+
] });
|
|
1059
|
+
}
|
|
1060
|
+
function LeaderboardContent(props) {
|
|
1061
|
+
const { subtitle, footnotes = [], isSm, page, totalCount, pageSize, onPageChange } = props;
|
|
1062
|
+
const isCountKnown = totalCount !== void 0;
|
|
1063
|
+
const totalPages = Math.max(1, Math.ceil((totalCount ?? 0) / pageSize));
|
|
1064
|
+
const showPagination = page > 1 || isCountKnown && totalPages > 1;
|
|
1065
|
+
return /* @__PURE__ */ jsxs12("div", { className: "flex flex-col h-full overflow-hidden", children: [
|
|
1066
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-6 sm:gap-4 overflow-hidden px-5", children: [
|
|
1067
|
+
subtitle && /* @__PURE__ */ jsxs12(DialogDescription, { className: "flex flex-col gap-1 header-xl-medium-card text-text-secondary sm:px-4 font-ss02 ss05 leading-normal", children: [
|
|
1068
|
+
subtitle,
|
|
1069
|
+
!isSm && footnotes.length > 0 && /* @__PURE__ */ jsx12(Footnotes, { notes: footnotes })
|
|
1070
|
+
] }),
|
|
1071
|
+
/* @__PURE__ */ jsx12("div", { className: "flex-1 overflow-y-auto", children: /* @__PURE__ */ jsx12(LeaderboardTable, { ...props }) })
|
|
1072
|
+
] }),
|
|
1073
|
+
(footnotes.length > 0 || showPagination) && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col pt-3 pb-6 px-9 border-t border-border gap-3 relative z-10 shadow-[0_0_4px_0_rgba(0,0,0,0.25)]", children: [
|
|
1074
|
+
footnotes.length > 0 && /* @__PURE__ */ jsx12(Footnotes, { notes: footnotes }),
|
|
1075
|
+
showPagination && /* @__PURE__ */ jsx12(
|
|
1076
|
+
Pagination,
|
|
1077
|
+
{
|
|
1078
|
+
page,
|
|
1079
|
+
totalPages,
|
|
1080
|
+
isCountKnown,
|
|
1081
|
+
isSm,
|
|
1082
|
+
onPageChange
|
|
1083
|
+
}
|
|
1084
|
+
)
|
|
1085
|
+
] })
|
|
1086
|
+
] });
|
|
1087
|
+
}
|
|
1088
|
+
function StatRankingLeaderboardDialog(props) {
|
|
1089
|
+
const { open, onOpenChange, title, isSm } = props;
|
|
1090
|
+
if (isSm) {
|
|
1091
|
+
return /* @__PURE__ */ jsx12(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs12(DialogContent, { className: "p-0 min-w-[536px] sm:max-w-[500px] pt-4 gap-6 bg-card border-0 flex flex-col max-h-[85vh]", children: [
|
|
1092
|
+
/* @__PURE__ */ jsx12(DialogHeader, { children: /* @__PURE__ */ jsx12(DialogTitle, { className: "header-xl-medium-card", children: title }) }),
|
|
1093
|
+
/* @__PURE__ */ jsx12(LeaderboardContent, { ...props })
|
|
1094
|
+
] }) });
|
|
1095
|
+
}
|
|
1096
|
+
return /* @__PURE__ */ jsx12(
|
|
1097
|
+
MobileModalLayout,
|
|
1098
|
+
{
|
|
1099
|
+
onCancel: () => onOpenChange(false),
|
|
1100
|
+
isOpen: open,
|
|
1101
|
+
isSm,
|
|
1102
|
+
title,
|
|
1103
|
+
cancelButtonName: "Close",
|
|
1104
|
+
childClassName: "h-auto min-h-full h-[calc(100vh-100px)]",
|
|
1105
|
+
children: /* @__PURE__ */ jsx12("div", { className: "flex flex-col h-full pt-6", children: /* @__PURE__ */ jsx12(LeaderboardContent, { ...props }) })
|
|
1106
|
+
}
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
// src/team/team-season-stats-widget.tsx
|
|
1111
|
+
import {
|
|
1112
|
+
Button as Button3,
|
|
1113
|
+
Card as Card5,
|
|
1114
|
+
CardContent as CardContent5,
|
|
1115
|
+
CardHeader as CardHeader4,
|
|
1116
|
+
CardTitle as CardTitle4,
|
|
1117
|
+
IconLoader,
|
|
1118
|
+
Skeleton as Skeleton5,
|
|
1119
|
+
cn as cn11
|
|
1120
|
+
} from "@nukleus-sports/ui-web";
|
|
1121
|
+
import {
|
|
1122
|
+
computeTeamSeasonStatsFromSummary,
|
|
1123
|
+
formatStatRankByConfig,
|
|
1124
|
+
getTeamRankingConfigIds,
|
|
1125
|
+
getTeamStatColumns as getTeamStatColumns2,
|
|
1126
|
+
isSupportedTeamStatsSport as isSupportedTeamStatsSport2
|
|
1127
|
+
} from "@nukleus-sports/core";
|
|
1128
|
+
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1129
|
+
var PRESEASON_TYPE = 1;
|
|
1130
|
+
var RANK_TEXT_CLASS = "label-xs-medium text-text-secondary";
|
|
1131
|
+
var RANK_LINK_CLASS = `${RANK_TEXT_CLASS} hover:text-text-primary hover:underline cursor-pointer transition-colors`;
|
|
1132
|
+
function RankBadge({
|
|
1133
|
+
rankText,
|
|
1134
|
+
statLabel,
|
|
1135
|
+
configId,
|
|
1136
|
+
isRankingsError,
|
|
1137
|
+
onRankClick
|
|
1138
|
+
}) {
|
|
1139
|
+
if (isRankingsError) {
|
|
1140
|
+
return /* @__PURE__ */ jsxs13("span", { className: "label-xs-medium text-destructive", title: "Couldn't load ranking", children: [
|
|
1141
|
+
/* @__PURE__ */ jsx13("span", { "aria-hidden": "true", children: "--" }),
|
|
1142
|
+
/* @__PURE__ */ jsx13("span", { className: "sr-only", children: "Couldn't load ranking" })
|
|
1143
|
+
] });
|
|
1144
|
+
}
|
|
1145
|
+
if (!rankText) return null;
|
|
1146
|
+
if (!onRankClick) return /* @__PURE__ */ jsx13("span", { className: RANK_TEXT_CLASS, children: rankText });
|
|
1147
|
+
return /* @__PURE__ */ jsx13(
|
|
1148
|
+
Button3,
|
|
1149
|
+
{
|
|
1150
|
+
type: "button",
|
|
1151
|
+
variant: "unstyled",
|
|
1152
|
+
size: "none",
|
|
1153
|
+
"aria-label": `${rankText} in ${statLabel}: view leaderboard`,
|
|
1154
|
+
onClick: (event) => {
|
|
1155
|
+
event.stopPropagation();
|
|
1156
|
+
onRankClick(configId);
|
|
1157
|
+
},
|
|
1158
|
+
className: RANK_LINK_CLASS,
|
|
1159
|
+
children: rankText
|
|
1160
|
+
}
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
function CenteredMessage({ children }) {
|
|
1164
|
+
return /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-center h-full text-14.5 text-text-secondary", children });
|
|
1165
|
+
}
|
|
1166
|
+
function StatsBody({
|
|
1167
|
+
stats,
|
|
1168
|
+
sportId,
|
|
1169
|
+
rankings,
|
|
1170
|
+
configIds,
|
|
1171
|
+
showRanks,
|
|
1172
|
+
isSummaryError,
|
|
1173
|
+
isRankingsError,
|
|
1174
|
+
onRankClick
|
|
1175
|
+
}) {
|
|
1176
|
+
const columns = getTeamStatColumns2(sportId);
|
|
1177
|
+
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1.5 h-full w-full justify-center", children: [
|
|
1178
|
+
isSummaryError && /* @__PURE__ */ jsx13("p", { className: "text-12 text-destructive", children: "Couldn't refresh stats. Showing the last loaded data." }),
|
|
1179
|
+
/* @__PURE__ */ jsx13("div", { className: "grid grid-cols-2 gap-x-1.5 gap-y-1.5 sm:flex sm:flex-row sm:gap-3 sm:justify-between items-center w-full", children: columns.map((column, index) => {
|
|
1180
|
+
const configId = configIds?.[index];
|
|
1181
|
+
return /* @__PURE__ */ jsx13(
|
|
1182
|
+
StatColumn,
|
|
1183
|
+
{
|
|
1184
|
+
label: column.label,
|
|
1185
|
+
value: stats.values[index],
|
|
1186
|
+
suffix: column.suffix,
|
|
1187
|
+
rankBadge: showRanks && configId !== void 0 ? /* @__PURE__ */ jsx13(
|
|
1188
|
+
RankBadge,
|
|
1189
|
+
{
|
|
1190
|
+
rankText: formatStatRankByConfig(rankings, configId),
|
|
1191
|
+
statLabel: column.label,
|
|
1192
|
+
configId,
|
|
1193
|
+
isRankingsError,
|
|
1194
|
+
onRankClick
|
|
1195
|
+
}
|
|
1196
|
+
) : void 0
|
|
1197
|
+
},
|
|
1198
|
+
column.label
|
|
1199
|
+
);
|
|
1200
|
+
}) })
|
|
1201
|
+
] });
|
|
1202
|
+
}
|
|
1203
|
+
function getEmptyMessage(isSupportedSport, hasSeason, isSummaryError) {
|
|
1204
|
+
if (!isSupportedSport) return "Team season stats coming soon.";
|
|
1205
|
+
if (!hasSeason) return "Select a season to view stats.";
|
|
1206
|
+
return isSummaryError ? "Couldn't load season stats. Please try again." : "No season stats for the current season.";
|
|
1207
|
+
}
|
|
1208
|
+
function TeamSeasonStatsWidget({
|
|
1209
|
+
sportId,
|
|
1210
|
+
leagueId,
|
|
1211
|
+
seasons,
|
|
1212
|
+
seasonsLoading = false,
|
|
1213
|
+
summary,
|
|
1214
|
+
rankings,
|
|
1215
|
+
statsLoading = false,
|
|
1216
|
+
isSummaryError = false,
|
|
1217
|
+
isRankingsError = false,
|
|
1218
|
+
onRankClick,
|
|
1219
|
+
className
|
|
1220
|
+
}) {
|
|
1221
|
+
const isSupportedSport = sportId != null && isSupportedTeamStatsSport2(sportId);
|
|
1222
|
+
const hasSeason = Boolean(seasons?.selectedYear) && seasons?.selectedType != null;
|
|
1223
|
+
const stats = isSupportedSport && hasSeason ? computeTeamSeasonStatsFromSummary(summary, sportId) : null;
|
|
1224
|
+
const configIds = getTeamRankingConfigIds(sportId, leagueId);
|
|
1225
|
+
const showRanks = seasons?.selectedType !== PRESEASON_TYPE;
|
|
1226
|
+
if (seasonsLoading) {
|
|
1227
|
+
return /* @__PURE__ */ jsxs13(Card5, { className: cn11("border-0 p-4 h-[300px]", className), children: [
|
|
1228
|
+
/* @__PURE__ */ jsx13(CardHeader4, { className: "p-0 pb-4", children: /* @__PURE__ */ jsx13(CardTitle4, { className: "text-base font-medium", children: "Season Stats" }) }),
|
|
1229
|
+
/* @__PURE__ */ jsx13(CardContent5, { className: "p-0", children: /* @__PURE__ */ jsx13("div", { className: "space-y-3 flex justify-center items-center w-full h-full", children: /* @__PURE__ */ jsx13(IconLoader, {}) }) })
|
|
1230
|
+
] });
|
|
1231
|
+
}
|
|
1232
|
+
let body;
|
|
1233
|
+
if (statsLoading) {
|
|
1234
|
+
body = /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsx13(Skeleton5, { className: "h-4 w-3/4" }) });
|
|
1235
|
+
} else if (isSupportedSport && stats) {
|
|
1236
|
+
body = /* @__PURE__ */ jsx13(
|
|
1237
|
+
StatsBody,
|
|
1238
|
+
{
|
|
1239
|
+
stats,
|
|
1240
|
+
sportId,
|
|
1241
|
+
rankings: rankings ?? [],
|
|
1242
|
+
configIds,
|
|
1243
|
+
showRanks,
|
|
1244
|
+
isSummaryError,
|
|
1245
|
+
isRankingsError,
|
|
1246
|
+
onRankClick
|
|
1247
|
+
}
|
|
1248
|
+
);
|
|
1249
|
+
} else {
|
|
1250
|
+
body = /* @__PURE__ */ jsx13(CenteredMessage, { children: getEmptyMessage(isSupportedSport, hasSeason, isSummaryError) });
|
|
1251
|
+
}
|
|
1252
|
+
return /* @__PURE__ */ jsxs13(
|
|
1253
|
+
Card5,
|
|
1254
|
+
{
|
|
1255
|
+
className: cn11(
|
|
1256
|
+
"border-0 px-4 py-3 sm:p-4 flex flex-col gap-[25px] sm:gap-4 sm:h-[300px]",
|
|
1257
|
+
className
|
|
1258
|
+
),
|
|
1259
|
+
children: [
|
|
1260
|
+
/* @__PURE__ */ jsx13(CardHeader4, { className: "p-0", children: /* @__PURE__ */ jsxs13("div", { className: "flex flex-row items-center justify-between w-full h-8", children: [
|
|
1261
|
+
/* @__PURE__ */ jsx13(CardTitle4, { className: "header-xl-medium-card text-base text-text-primary", children: "Team Stats" }),
|
|
1262
|
+
isSupportedSport && seasons && seasons.years.length > 0 && /* @__PURE__ */ jsx13(SeasonSelector, { ...seasons, hideTypeOnMobile: true })
|
|
1263
|
+
] }) }),
|
|
1264
|
+
/* @__PURE__ */ jsx13(CardContent5, { className: "p-0 h-auto sm:h-[220px] flex justify-center", children: body })
|
|
1265
|
+
]
|
|
1266
|
+
}
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// src/team/recent-games-widget.tsx
|
|
1271
|
+
import { useState as useState4 } from "react";
|
|
1272
|
+
import {
|
|
1273
|
+
Button as Button4,
|
|
1274
|
+
Card as Card6,
|
|
1275
|
+
CardContent as CardContent6,
|
|
1276
|
+
CardHeader as CardHeader5,
|
|
1277
|
+
CardTitle as CardTitle5,
|
|
1278
|
+
IconLoader as IconLoader2,
|
|
1279
|
+
cn as cn12
|
|
1280
|
+
} from "@nukleus-sports/ui-web";
|
|
1281
|
+
import { ArrowUpRightIcon } from "@nukleus-sports/icons";
|
|
1282
|
+
import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1283
|
+
var DATE_FORMAT = new Intl.DateTimeFormat("en-US", {
|
|
1284
|
+
weekday: "long",
|
|
1285
|
+
month: "long",
|
|
1286
|
+
day: "numeric",
|
|
1287
|
+
year: "numeric"
|
|
1288
|
+
});
|
|
1289
|
+
var MESSAGES = {
|
|
1290
|
+
"no-team": "No games available.",
|
|
1291
|
+
"team-error": "Couldn't load team info. Please try again.",
|
|
1292
|
+
"games-error": "Couldn't load games. Please try again."
|
|
1293
|
+
};
|
|
1294
|
+
function ResultText({ result }) {
|
|
1295
|
+
if (result.outcome === "none") return /* @__PURE__ */ jsx14("span", { className: "text-text-secondary text-14", children: "--" });
|
|
1296
|
+
if (result.outcome === "tie") {
|
|
1297
|
+
return /* @__PURE__ */ jsxs14("span", { className: "text-14 font-medium text-text-primary", children: [
|
|
1298
|
+
"T ",
|
|
1299
|
+
result.detail
|
|
1300
|
+
] });
|
|
1301
|
+
}
|
|
1302
|
+
const isWin = result.outcome === "win";
|
|
1303
|
+
return /* @__PURE__ */ jsxs14("span", { className: "text-14 font-medium", children: [
|
|
1304
|
+
/* @__PURE__ */ jsx14(
|
|
1305
|
+
"span",
|
|
1306
|
+
{
|
|
1307
|
+
className: isWin ? "text-primary-color-nuk-text" : "text-semantic-color-status-priority-blocked-hot-copy",
|
|
1308
|
+
children: isWin ? "W" : "L"
|
|
1309
|
+
}
|
|
1310
|
+
),
|
|
1311
|
+
/* @__PURE__ */ jsxs14("span", { className: "text-text-primary", children: [
|
|
1312
|
+
" ",
|
|
1313
|
+
result.detail
|
|
1314
|
+
] })
|
|
1315
|
+
] });
|
|
1316
|
+
}
|
|
1317
|
+
function OpponentLogo({ opponent, resolveImageUrl, defaultLogoUrl }) {
|
|
1318
|
+
const [failedUrl, setFailedUrl] = useState4(null);
|
|
1319
|
+
const { logo } = opponent;
|
|
1320
|
+
const resolved = logo ? logo.stored ? resolveImageUrl?.(logo.url) : logo.url : void 0;
|
|
1321
|
+
return /* @__PURE__ */ jsx14(
|
|
1322
|
+
"img",
|
|
1323
|
+
{
|
|
1324
|
+
src: resolved && resolved !== failedUrl ? resolved : defaultLogoUrl,
|
|
1325
|
+
alt: `${opponent.name} logo`,
|
|
1326
|
+
className: "h-8 w-8 rounded-full",
|
|
1327
|
+
loading: "lazy",
|
|
1328
|
+
onError: () => {
|
|
1329
|
+
if (resolved) setFailedUrl(resolved);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
function GameItem({ row, resolveImageUrl, defaultLogoUrl }) {
|
|
1335
|
+
return /* @__PURE__ */ jsxs14("div", { className: "border-b border-border last:border-0", children: [
|
|
1336
|
+
row.isFirstUpcoming && /* @__PURE__ */ jsx14("p", { className: "px-2 pt-2 text-12 font-medium uppercase tracking-wide text-text-secondary", children: "Upcoming" }),
|
|
1337
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex flex-col p-2 gap-[5px]", children: [
|
|
1338
|
+
/* @__PURE__ */ jsx14("p", { className: "text-14 font-normal text-text-secondary", children: DATE_FORMAT.format(new Date(row.gameDate)) }),
|
|
1339
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-3", children: [
|
|
1340
|
+
/* @__PURE__ */ jsx14("span", { className: "text-14 font-normal text-text-secondary shrink-0", children: row.isHome ? "vs " : "@ " }),
|
|
1341
|
+
/* @__PURE__ */ jsx14(
|
|
1342
|
+
OpponentLogo,
|
|
1343
|
+
{
|
|
1344
|
+
opponent: row.opponent,
|
|
1345
|
+
resolveImageUrl,
|
|
1346
|
+
defaultLogoUrl
|
|
1347
|
+
}
|
|
1348
|
+
),
|
|
1349
|
+
/* @__PURE__ */ jsx14("span", { className: "text-14.5 font-normal text-text-primary truncate", children: row.opponent.name }),
|
|
1350
|
+
row.result && /* @__PURE__ */ jsxs14(Fragment3, { children: [
|
|
1351
|
+
/* @__PURE__ */ jsx14("span", { className: "text-14 text-text-secondary", children: "-" }),
|
|
1352
|
+
/* @__PURE__ */ jsx14(ResultText, { result: row.result })
|
|
1353
|
+
] })
|
|
1354
|
+
] }),
|
|
1355
|
+
row.time && /* @__PURE__ */ jsx14("p", { className: "text-14 font-normal text-text-secondary", children: row.time })
|
|
1356
|
+
] })
|
|
1357
|
+
] });
|
|
1358
|
+
}
|
|
1359
|
+
function Message({ children }) {
|
|
1360
|
+
return /* @__PURE__ */ jsx14("div", { className: "text-text-primary text-14.5 px-1", children });
|
|
1361
|
+
}
|
|
1362
|
+
function Body({
|
|
1363
|
+
status,
|
|
1364
|
+
rows,
|
|
1365
|
+
resolveImageUrl,
|
|
1366
|
+
defaultLogoUrl
|
|
1367
|
+
}) {
|
|
1368
|
+
if (status === "loading") {
|
|
1369
|
+
return /* @__PURE__ */ jsx14("div", { className: "space-y-4 flex justify-center items-center w-full h-full", children: /* @__PURE__ */ jsx14(IconLoader2, {}) });
|
|
1370
|
+
}
|
|
1371
|
+
if (status !== "ready") return /* @__PURE__ */ jsx14(Message, { children: MESSAGES[status] });
|
|
1372
|
+
if (rows.length === 0) return /* @__PURE__ */ jsx14(Message, { children: "There are no games scheduled at this time." });
|
|
1373
|
+
return /* @__PURE__ */ jsx14("div", { className: "flex flex-col overflow-y-auto overflow-x-hidden gap-1", children: rows.map((row) => /* @__PURE__ */ jsx14(
|
|
1374
|
+
GameItem,
|
|
1375
|
+
{
|
|
1376
|
+
row,
|
|
1377
|
+
resolveImageUrl,
|
|
1378
|
+
defaultLogoUrl
|
|
1379
|
+
},
|
|
1380
|
+
row.id
|
|
1381
|
+
)) });
|
|
1382
|
+
}
|
|
1383
|
+
function RecentGamesWidget({
|
|
1384
|
+
status,
|
|
1385
|
+
rows,
|
|
1386
|
+
resolveImageUrl,
|
|
1387
|
+
defaultLogoUrl,
|
|
1388
|
+
onExpand,
|
|
1389
|
+
className
|
|
1390
|
+
}) {
|
|
1391
|
+
return /* @__PURE__ */ jsxs14(
|
|
1392
|
+
Card6,
|
|
1393
|
+
{
|
|
1394
|
+
className: cn12(
|
|
1395
|
+
"p-4 w-full xl:w-[420px] flex flex-col overflow-hidden border-none gap-3 h-full md:min-h-[612px]",
|
|
1396
|
+
className
|
|
1397
|
+
),
|
|
1398
|
+
children: [
|
|
1399
|
+
/* @__PURE__ */ jsxs14(CardHeader5, { className: "flex flex-row items-center justify-between space-y-0 p-0", children: [
|
|
1400
|
+
/* @__PURE__ */ jsx14(CardTitle5, { children: "Recent Games" }),
|
|
1401
|
+
onExpand && /* @__PURE__ */ jsx14(
|
|
1402
|
+
Button4,
|
|
1403
|
+
{
|
|
1404
|
+
type: "button",
|
|
1405
|
+
variant: "ghost",
|
|
1406
|
+
size: "sm",
|
|
1407
|
+
"aria-label": "View full schedule",
|
|
1408
|
+
onClick: onExpand,
|
|
1409
|
+
className: "outline-1 background outline-offset-[-1px] outline-[hsl(var(--color-ui-elem-strokes))] outline h-[32px] w-[32px]",
|
|
1410
|
+
children: /* @__PURE__ */ jsx14(ArrowUpRightIcon, { className: "text-greys-icons h-5 w-5" })
|
|
1411
|
+
}
|
|
1412
|
+
)
|
|
1413
|
+
] }),
|
|
1414
|
+
/* @__PURE__ */ jsx14(CardContent6, { className: "flex-1 flex flex-col overflow-hidden p-0", children: /* @__PURE__ */ jsx14(
|
|
1415
|
+
Body,
|
|
1416
|
+
{
|
|
1417
|
+
status,
|
|
1418
|
+
rows,
|
|
1419
|
+
resolveImageUrl,
|
|
1420
|
+
defaultLogoUrl
|
|
1421
|
+
}
|
|
1422
|
+
) })
|
|
1423
|
+
]
|
|
1424
|
+
}
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// src/team/team-stats-table.tsx
|
|
1429
|
+
import { useState as useState5 } from "react";
|
|
1430
|
+
import {
|
|
1431
|
+
BaseTable as BaseTable3,
|
|
1432
|
+
Card as Card7,
|
|
1433
|
+
CardContent as CardContent7,
|
|
1434
|
+
CardHeader as CardHeader6,
|
|
1435
|
+
CardTitle as CardTitle6,
|
|
1436
|
+
Select as Select2,
|
|
1437
|
+
SelectContent as SelectContent2,
|
|
1438
|
+
SelectItem as SelectItem2,
|
|
1439
|
+
SelectTrigger as SelectTrigger2,
|
|
1440
|
+
SelectValue as SelectValue2,
|
|
1441
|
+
Skeleton as Skeleton6,
|
|
1442
|
+
cn as cn13
|
|
1443
|
+
} from "@nukleus-sports/ui-web";
|
|
1444
|
+
import {
|
|
1445
|
+
getOrderedTeamStatTypesForCategory,
|
|
1446
|
+
getVisibleTeamStatTypes,
|
|
1447
|
+
showsTeamStatCategoryPicker
|
|
1448
|
+
} from "@nukleus-sports/core";
|
|
1449
|
+
import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1450
|
+
function stripLeadingSlash(path) {
|
|
1451
|
+
return path.startsWith("/") ? path.slice(1) : path;
|
|
1452
|
+
}
|
|
1453
|
+
function isDefinedStatType(value) {
|
|
1454
|
+
return Boolean(value);
|
|
1455
|
+
}
|
|
1456
|
+
function getAvailableStatCategories(stats) {
|
|
1457
|
+
return Array.from(
|
|
1458
|
+
new Set(
|
|
1459
|
+
stats.flatMap(
|
|
1460
|
+
(stat) => (stat.stat_details?.stats ?? []).map((s) => s.stat_type).filter(isDefinedStatType)
|
|
1461
|
+
)
|
|
1462
|
+
)
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
function deriveSelectedStatCategory(requested, available) {
|
|
1466
|
+
if (requested && available.includes(requested)) return requested;
|
|
1467
|
+
if (available.includes("offense")) return "offense";
|
|
1468
|
+
return available[0] ?? "offense";
|
|
1469
|
+
}
|
|
1470
|
+
function getStatsEmptyMessage(seasons, statsCount) {
|
|
1471
|
+
if (!seasons.selectedYear || seasons.selectedType === null) {
|
|
1472
|
+
return "Select a season to view stats.";
|
|
1473
|
+
}
|
|
1474
|
+
if (statsCount === 0) {
|
|
1475
|
+
const yearLabel = seasons.years.find((y) => y.value === seasons.selectedYear)?.label;
|
|
1476
|
+
const typeLabel = seasons.types.find((t) => t.value === seasons.selectedType)?.label;
|
|
1477
|
+
return `No stats available for ${yearLabel} - ${typeLabel}.`;
|
|
1478
|
+
}
|
|
1479
|
+
return "No stats found for this season";
|
|
1480
|
+
}
|
|
1481
|
+
function formatTeamStatDate(stat) {
|
|
1482
|
+
const dateStr = stat.stat_details?.game_details?.date;
|
|
1483
|
+
const date = dateStr ? new Date(dateStr) : null;
|
|
1484
|
+
if (!date || Number.isNaN(date.getTime())) {
|
|
1485
|
+
return /* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: "--" });
|
|
1486
|
+
}
|
|
1487
|
+
const formatted = date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
1488
|
+
return /* @__PURE__ */ jsx15("div", { className: "text-13.5 font-normal text-text-primary", children: formatted });
|
|
1489
|
+
}
|
|
1490
|
+
function getTeamStatResult(stat) {
|
|
1491
|
+
const gameDetails = stat.stat_details?.game_details;
|
|
1492
|
+
if (gameDetails?.home_team_score === void 0 || gameDetails?.away_team_score === void 0) {
|
|
1493
|
+
return "--";
|
|
1494
|
+
}
|
|
1495
|
+
const isHome = stat.team_id === gameDetails.home_team_id;
|
|
1496
|
+
const homeScore = gameDetails.home_team_score;
|
|
1497
|
+
const awayScore = gameDetails.away_team_score;
|
|
1498
|
+
let winLoss = "T";
|
|
1499
|
+
if (homeScore !== awayScore) {
|
|
1500
|
+
const teamWon = isHome ? homeScore > awayScore : awayScore > homeScore;
|
|
1501
|
+
winLoss = teamWon ? "W" : "L";
|
|
1502
|
+
}
|
|
1503
|
+
const teamScore = isHome ? homeScore : awayScore;
|
|
1504
|
+
const opponentScore = isHome ? awayScore : homeScore;
|
|
1505
|
+
const score = `${teamScore}-${opponentScore}${gameDetails.status_alt_details ? ` ${gameDetails.status_alt_details}` : ""}`;
|
|
1506
|
+
const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
|
|
1507
|
+
return /* @__PURE__ */ jsxs15("div", { className: "flex items-baseline gap-1 leading-tight", children: [
|
|
1508
|
+
/* @__PURE__ */ jsx15("span", { className: cn13(colorClass, "body-text"), children: winLoss }),
|
|
1509
|
+
/* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: score })
|
|
1510
|
+
] });
|
|
1511
|
+
}
|
|
1512
|
+
function StatOpponentCell({
|
|
1513
|
+
stat,
|
|
1514
|
+
resolveOpponentLogoUrl,
|
|
1515
|
+
defaultLogoUrl,
|
|
1516
|
+
showName
|
|
1517
|
+
}) {
|
|
1518
|
+
const [failedUrl, setFailedUrl] = useState5(null);
|
|
1519
|
+
const gameDetails = stat.stat_details?.game_details;
|
|
1520
|
+
const isHome = stat.team_id === gameDetails?.home_team_id;
|
|
1521
|
+
const opponentName = isHome ? gameDetails?.away_team_name : gameDetails?.home_team_name;
|
|
1522
|
+
const opponentLogoPath = isHome ? gameDetails?.away_team_logo : gameDetails?.home_team_logo;
|
|
1523
|
+
if (!opponentName) return /* @__PURE__ */ jsx15(Fragment4, { children: "--" });
|
|
1524
|
+
const prefix = isHome ? "vs" : "@";
|
|
1525
|
+
const resolved = opponentLogoPath ? resolveOpponentLogoUrl(stripLeadingSlash(opponentLogoPath)) : null;
|
|
1526
|
+
const logoSrc = resolved && resolved !== failedUrl ? resolved : defaultLogoUrl;
|
|
1527
|
+
return /* @__PURE__ */ jsx15("div", { className: "h-full overflow-hidden", children: /* @__PURE__ */ jsx15("div", { className: "flex items-center h-full", children: /* @__PURE__ */ jsxs15("div", { className: "flex max-sm:gap-1 gap-2 items-center font-normal leading-tight text-12", children: [
|
|
1528
|
+
/* @__PURE__ */ jsx15("span", { className: "text-text-primary body-text", children: prefix }),
|
|
1529
|
+
/* @__PURE__ */ jsx15(
|
|
1530
|
+
"img",
|
|
1531
|
+
{
|
|
1532
|
+
src: logoSrc,
|
|
1533
|
+
alt: showName ? "" : opponentName,
|
|
1534
|
+
className: "max-sm:w-5 max-sm:h-5 w-4 h-4 rounded-full flex-shrink-0",
|
|
1535
|
+
onError: () => {
|
|
1536
|
+
if (resolved) setFailedUrl(resolved);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
),
|
|
1540
|
+
showName && /* @__PURE__ */ jsx15("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentName })
|
|
1541
|
+
] }) }) });
|
|
1542
|
+
}
|
|
1543
|
+
function buildStatsColumns({
|
|
1544
|
+
filteredStatTypes,
|
|
1545
|
+
selectedStatCategory,
|
|
1546
|
+
resolveOpponentLogoUrl,
|
|
1547
|
+
defaultLogoUrl,
|
|
1548
|
+
isSm,
|
|
1549
|
+
isSmallLaptop
|
|
1550
|
+
}) {
|
|
1551
|
+
return [
|
|
1552
|
+
{
|
|
1553
|
+
id: "game_date",
|
|
1554
|
+
header: () => /* @__PURE__ */ jsx15("div", { className: "w-[50px] shrink-0", children: "Date" }),
|
|
1555
|
+
cell: ({ row }) => formatTeamStatDate(row.original),
|
|
1556
|
+
meta: { cellSize: isSm ? "xs" : "xxs", headerClassName: "h-auto" }
|
|
1557
|
+
},
|
|
1558
|
+
{
|
|
1559
|
+
id: "opponent",
|
|
1560
|
+
header: () => /* @__PURE__ */ jsx15("div", { children: isSm ? "Opponent" : "Opp" }),
|
|
1561
|
+
cell: ({ row }) => /* @__PURE__ */ jsx15(
|
|
1562
|
+
StatOpponentCell,
|
|
1563
|
+
{
|
|
1564
|
+
stat: row.original,
|
|
1565
|
+
resolveOpponentLogoUrl,
|
|
1566
|
+
defaultLogoUrl,
|
|
1567
|
+
showName: isSm
|
|
1568
|
+
}
|
|
1569
|
+
),
|
|
1570
|
+
meta: {
|
|
1571
|
+
cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse",
|
|
1572
|
+
headerClassName: "h-auto"
|
|
1573
|
+
}
|
|
1574
|
+
},
|
|
1575
|
+
{
|
|
1576
|
+
id: "result",
|
|
1577
|
+
header: "Result",
|
|
1578
|
+
cell: ({ row }) => getTeamStatResult(row.original),
|
|
1579
|
+
meta: { cellSize: "xs", headerClassName: "h-auto", rowCellClassName: "!min-w-[70px]" }
|
|
1580
|
+
},
|
|
1581
|
+
...filteredStatTypes.map((statType) => ({
|
|
1582
|
+
id: statType.name,
|
|
1583
|
+
header: statType.label || statType.name,
|
|
1584
|
+
cell: ({ row }) => {
|
|
1585
|
+
const value = row.original.stat_details?.stats?.find(
|
|
1586
|
+
(s) => s.stat_id === statType.id && s.stat_type === selectedStatCategory
|
|
1587
|
+
)?.stat_value;
|
|
1588
|
+
return value !== void 0 ? value : "--";
|
|
1589
|
+
},
|
|
1590
|
+
meta: {
|
|
1591
|
+
cellSize: "xxs",
|
|
1592
|
+
headerClassName: "h-auto py-0 !whitespace-normal !overflow-visible !text-clip !break-words !line-clamp-2"
|
|
1593
|
+
}
|
|
1594
|
+
}))
|
|
1595
|
+
];
|
|
1596
|
+
}
|
|
1597
|
+
function StatsBody2({
|
|
1598
|
+
seasons,
|
|
1599
|
+
showsCategoryPicker,
|
|
1600
|
+
selectedStatCategory,
|
|
1601
|
+
availableStatCategories,
|
|
1602
|
+
onStatCategoryChange,
|
|
1603
|
+
isStatTypesError,
|
|
1604
|
+
hasVisibleStatTypes,
|
|
1605
|
+
columns,
|
|
1606
|
+
stats,
|
|
1607
|
+
statsLoading,
|
|
1608
|
+
isStatsError,
|
|
1609
|
+
isSm,
|
|
1610
|
+
isSmallLaptop,
|
|
1611
|
+
emptyMessage
|
|
1612
|
+
}) {
|
|
1613
|
+
return /* @__PURE__ */ jsxs15(Fragment4, { children: [
|
|
1614
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 min-[360px]:gap-3", children: [
|
|
1615
|
+
/* @__PURE__ */ jsx15(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
|
|
1616
|
+
showsCategoryPicker && /* @__PURE__ */ jsxs15(
|
|
1617
|
+
Select2,
|
|
1618
|
+
{
|
|
1619
|
+
value: selectedStatCategory,
|
|
1620
|
+
onValueChange: onStatCategoryChange,
|
|
1621
|
+
disabled: !seasons.selectedYear || seasons.selectedType === null,
|
|
1622
|
+
children: [
|
|
1623
|
+
/* @__PURE__ */ jsx15(SelectTrigger2, { variant: "widget", size: "widget", "aria-label": "Stat category", children: /* @__PURE__ */ jsx15(SelectValue2, { placeholder: "Select stat category" }) }),
|
|
1624
|
+
/* @__PURE__ */ jsx15(
|
|
1625
|
+
SelectContent2,
|
|
1626
|
+
{
|
|
1627
|
+
className: "bg-popover border-border z-50 [&_.checkbox]:!flex",
|
|
1628
|
+
classNameViewPort: "gap-2",
|
|
1629
|
+
children: availableStatCategories.map((category) => /* @__PURE__ */ jsx15(SelectItem2, { value: category, className: "capitalize min-h-8", children: category.charAt(0).toUpperCase() + category.slice(1) }, category))
|
|
1630
|
+
}
|
|
1631
|
+
)
|
|
1632
|
+
]
|
|
1633
|
+
}
|
|
1634
|
+
)
|
|
1635
|
+
] }),
|
|
1636
|
+
/* @__PURE__ */ jsxs15("div", { className: "space-y-4 xl:flex-1 xl:min-h-0 xl:overflow-hidden", children: [
|
|
1637
|
+
isStatTypesError && !hasVisibleStatTypes && /* @__PURE__ */ jsx15("p", { className: "text-text-secondary text-13.5", children: "Couldn't load stat categories -- showing limited columns." }),
|
|
1638
|
+
/* @__PURE__ */ jsx15(
|
|
1639
|
+
BaseTable3,
|
|
1640
|
+
{
|
|
1641
|
+
columns,
|
|
1642
|
+
data: stats,
|
|
1643
|
+
pageSize: stats.length || 10,
|
|
1644
|
+
hidePagination: true,
|
|
1645
|
+
stickyHeader: true,
|
|
1646
|
+
splitLayout: isSmallLaptop || !isSm,
|
|
1647
|
+
splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
|
|
1648
|
+
loading: statsLoading,
|
|
1649
|
+
containerClassName: "border-0 rounded-none h-full",
|
|
1650
|
+
className: "border-none xl:h-full xl:min-h-0",
|
|
1651
|
+
numberOfColumns: 2,
|
|
1652
|
+
emptyMessage: isStatsError && stats.length === 0 ? "Couldn't load stats. Please try again." : emptyMessage
|
|
1653
|
+
}
|
|
1654
|
+
)
|
|
1655
|
+
] })
|
|
1656
|
+
] });
|
|
1657
|
+
}
|
|
1658
|
+
function TeamStatsTable({
|
|
1659
|
+
stats,
|
|
1660
|
+
statsLoading = false,
|
|
1661
|
+
isStatsError = false,
|
|
1662
|
+
statTypes,
|
|
1663
|
+
isStatTypesError = false,
|
|
1664
|
+
sportId,
|
|
1665
|
+
isTeamError = false,
|
|
1666
|
+
resolveOpponentLogoUrl,
|
|
1667
|
+
defaultLogoUrl,
|
|
1668
|
+
seasons,
|
|
1669
|
+
seasonsLoading = false,
|
|
1670
|
+
isSeasonsError = false,
|
|
1671
|
+
isSm,
|
|
1672
|
+
isSmallLaptop,
|
|
1673
|
+
className
|
|
1674
|
+
}) {
|
|
1675
|
+
const [requestedStatCategory, setRequestedStatCategory] = useState5(null);
|
|
1676
|
+
const availableStatCategories = getAvailableStatCategories(stats);
|
|
1677
|
+
const selectedStatCategory = deriveSelectedStatCategory(
|
|
1678
|
+
requestedStatCategory,
|
|
1679
|
+
availableStatCategories
|
|
1680
|
+
);
|
|
1681
|
+
if (isTeamError) {
|
|
1682
|
+
return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-0", className), children: /* @__PURE__ */ jsx15(CardContent7, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ jsx15("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
|
|
1683
|
+
}
|
|
1684
|
+
if (seasonsLoading || sportId === null) {
|
|
1685
|
+
return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-0", className), children: /* @__PURE__ */ jsxs15(CardContent7, { className: "space-y-4 pt-6", children: [
|
|
1686
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-3 sm:flex-row justify-start", children: [
|
|
1687
|
+
/* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[68px] bg-form rounded-[5px]" }),
|
|
1688
|
+
/* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[142px] bg-form rounded-[5px]" }),
|
|
1689
|
+
/* @__PURE__ */ jsx15(Skeleton6, { className: "h-7 w-[102px] bg-form rounded-[5px]" })
|
|
1690
|
+
] }),
|
|
1691
|
+
/* @__PURE__ */ jsx15(Skeleton6, { className: "h-40 w-full bg-form !mt-3" })
|
|
1692
|
+
] }) });
|
|
1693
|
+
}
|
|
1694
|
+
if (!seasons || seasons.years.length === 0) {
|
|
1695
|
+
return /* @__PURE__ */ jsx15(Card7, { className: cn13("border-none", className), children: /* @__PURE__ */ jsx15(CardContent7, { className: "pt-6", children: /* @__PURE__ */ jsx15("div", { className: "text-center py-8", children: /* @__PURE__ */ jsx15("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." }) }) }) });
|
|
1696
|
+
}
|
|
1697
|
+
const visibleStatTypes = getVisibleTeamStatTypes(statTypes, sportId);
|
|
1698
|
+
const filteredStatTypes = getOrderedTeamStatTypesForCategory(
|
|
1699
|
+
visibleStatTypes,
|
|
1700
|
+
sportId,
|
|
1701
|
+
selectedStatCategory
|
|
1702
|
+
);
|
|
1703
|
+
const showsCategoryPicker = availableStatCategories.length > 0 && showsTeamStatCategoryPicker(sportId);
|
|
1704
|
+
const columns = buildStatsColumns({
|
|
1705
|
+
filteredStatTypes,
|
|
1706
|
+
selectedStatCategory,
|
|
1707
|
+
resolveOpponentLogoUrl,
|
|
1708
|
+
defaultLogoUrl,
|
|
1709
|
+
isSm,
|
|
1710
|
+
isSmallLaptop
|
|
1711
|
+
});
|
|
1712
|
+
const emptyMessage = getStatsEmptyMessage(seasons, stats.length);
|
|
1713
|
+
return /* @__PURE__ */ jsxs15(
|
|
1714
|
+
Card7,
|
|
1715
|
+
{
|
|
1716
|
+
className: cn13(
|
|
1717
|
+
"border-none p-4 flex flex-col gap-3 xl:h-full xl:min-h-0 xl:flex-1 xl:overflow-hidden",
|
|
1718
|
+
className
|
|
1719
|
+
),
|
|
1720
|
+
children: [
|
|
1721
|
+
/* @__PURE__ */ jsx15(CardHeader6, { className: "p-0", children: /* @__PURE__ */ jsx15(CardTitle6, { children: "Stats" }) }),
|
|
1722
|
+
/* @__PURE__ */ jsx15(CardContent7, { className: "space-y-0 p-0 flex flex-col gap-3 xl:flex-1 xl:min-h-0", children: /* @__PURE__ */ jsx15(
|
|
1723
|
+
StatsBody2,
|
|
1724
|
+
{
|
|
1725
|
+
seasons,
|
|
1726
|
+
showsCategoryPicker,
|
|
1727
|
+
selectedStatCategory,
|
|
1728
|
+
availableStatCategories,
|
|
1729
|
+
onStatCategoryChange: setRequestedStatCategory,
|
|
1730
|
+
isStatTypesError,
|
|
1731
|
+
hasVisibleStatTypes: visibleStatTypes.length > 0,
|
|
1732
|
+
columns,
|
|
1733
|
+
stats,
|
|
1734
|
+
statsLoading,
|
|
1735
|
+
isStatsError,
|
|
1736
|
+
isSm,
|
|
1737
|
+
isSmallLaptop,
|
|
1738
|
+
emptyMessage
|
|
1739
|
+
}
|
|
1740
|
+
) })
|
|
1741
|
+
]
|
|
1742
|
+
}
|
|
1743
|
+
);
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
// src/team/team-schedule-table.tsx
|
|
1747
|
+
import {
|
|
1748
|
+
BaseTable as BaseTable4,
|
|
1749
|
+
Card as Card8,
|
|
1750
|
+
CardContent as CardContent8,
|
|
1751
|
+
CardHeader as CardHeader7,
|
|
1752
|
+
CardTitle as CardTitle7,
|
|
1753
|
+
IconLoader as IconLoader3,
|
|
1754
|
+
cn as cn14
|
|
1755
|
+
} from "@nukleus-sports/ui-web";
|
|
1756
|
+
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1757
|
+
var SPECIAL_LOGO_LEAGUES = ["NFL", "NBA", "NHL", "MLB", "WNBA"];
|
|
1758
|
+
var COLLEGE_LEAGUE_IDS = [2, 6, 13];
|
|
1759
|
+
var COMPLETED_STATUS_ID = "3";
|
|
1760
|
+
var DATE_FORMAT2 = new Intl.DateTimeFormat("en-US", { month: "short", day: "numeric" });
|
|
1761
|
+
function firstCompetition(game) {
|
|
1762
|
+
return game.game_details?.competitions?.[0];
|
|
1763
|
+
}
|
|
1764
|
+
function formatScore(score) {
|
|
1765
|
+
if (score?.displayValue) return score.displayValue;
|
|
1766
|
+
if (typeof score?.value === "number") return String(score.value);
|
|
1767
|
+
return "0";
|
|
1768
|
+
}
|
|
1769
|
+
function findCompetitor(competitors, teamEspnId) {
|
|
1770
|
+
if (!competitors || competitors.length !== 2 || !teamEspnId) return null;
|
|
1771
|
+
const [first, second] = competitors;
|
|
1772
|
+
if (!first || !second) return null;
|
|
1773
|
+
if (first.id === teamEspnId) return { own: first, other: second };
|
|
1774
|
+
if (second.id === teamEspnId) return { own: second, other: first };
|
|
1775
|
+
return null;
|
|
1776
|
+
}
|
|
1777
|
+
function findLeader(competitors, leaderType) {
|
|
1778
|
+
if (!competitors || competitors.length !== 2) return null;
|
|
1779
|
+
for (const competitor of competitors) {
|
|
1780
|
+
const leader = competitor?.leaders?.find((entry) => entry.name === leaderType);
|
|
1781
|
+
const top = leader?.leaders?.[0];
|
|
1782
|
+
if (top?.athlete) {
|
|
1783
|
+
return {
|
|
1784
|
+
displayName: top.athlete.displayName || "--",
|
|
1785
|
+
displayValue: top.displayValue || "--"
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
return null;
|
|
1790
|
+
}
|
|
1791
|
+
function showsFootballLeaders(leagueId) {
|
|
1792
|
+
return leagueId !== null && [1, 2, 13].includes(leagueId);
|
|
1793
|
+
}
|
|
1794
|
+
function showsBasketballLeaders(leagueId) {
|
|
1795
|
+
return leagueId !== null && [4, 5, 6].includes(leagueId);
|
|
1796
|
+
}
|
|
1797
|
+
function showsHockeyLeaders(leagueId) {
|
|
1798
|
+
return leagueId === 14;
|
|
1799
|
+
}
|
|
1800
|
+
function showsMlbLeaders(leagueId) {
|
|
1801
|
+
return leagueId === 7;
|
|
1802
|
+
}
|
|
1803
|
+
function leaderCell(leader, small = false) {
|
|
1804
|
+
if (!leader) return "--";
|
|
1805
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col leading-tight", children: [
|
|
1806
|
+
/* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: leader.displayName }),
|
|
1807
|
+
/* @__PURE__ */ jsx16(
|
|
1808
|
+
"span",
|
|
1809
|
+
{
|
|
1810
|
+
className: cn14(
|
|
1811
|
+
small ? "text-text-secondary text-11" : "text-text-primary body-text",
|
|
1812
|
+
"truncate"
|
|
1813
|
+
),
|
|
1814
|
+
children: leader.displayValue
|
|
1815
|
+
}
|
|
1816
|
+
)
|
|
1817
|
+
] });
|
|
1818
|
+
}
|
|
1819
|
+
function formatScheduleDate(game) {
|
|
1820
|
+
if (!game.game_details) return "--";
|
|
1821
|
+
try {
|
|
1822
|
+
const { timeValid, date: rawDate } = game.game_details;
|
|
1823
|
+
const date = timeValid ? new Date(rawDate) : (() => {
|
|
1824
|
+
const [year, month, day] = rawDate.split("T")[0].split("-").map(Number);
|
|
1825
|
+
return new Date(year, month - 1, day);
|
|
1826
|
+
})();
|
|
1827
|
+
return /* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text", children: DATE_FORMAT2.format(date) });
|
|
1828
|
+
} catch {
|
|
1829
|
+
return "--";
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
function getScheduleResult(game, teamEspnId) {
|
|
1833
|
+
const competition = firstCompetition(game);
|
|
1834
|
+
if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return null;
|
|
1835
|
+
const match = findCompetitor(competition.competitors, teamEspnId);
|
|
1836
|
+
if (!match) return null;
|
|
1837
|
+
const { own, other } = match;
|
|
1838
|
+
const ownValue = own.score?.value;
|
|
1839
|
+
const otherValue = other.score?.value;
|
|
1840
|
+
const scoresKnown = typeof ownValue === "number" && typeof otherValue === "number";
|
|
1841
|
+
const tied = scoresKnown && ownValue === otherValue;
|
|
1842
|
+
const winLoss = tied ? "T" : own.winner === true ? "W" : "L";
|
|
1843
|
+
const score = `${formatScore(own.score)}-${formatScore(other.score)}`;
|
|
1844
|
+
const colorClass = winLoss === "W" ? "text-primary-color-nuk-text" : winLoss === "L" ? "text-semantic-color-status-priority-blocked-hot-copy" : "text-text-primary";
|
|
1845
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex items-baseline gap-1 leading-tight", children: [
|
|
1846
|
+
/* @__PURE__ */ jsx16("span", { className: cn14(colorClass, "body-text"), children: winLoss }),
|
|
1847
|
+
/* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text", children: score })
|
|
1848
|
+
] });
|
|
1849
|
+
}
|
|
1850
|
+
function getScheduleRecord(game, teamEspnId) {
|
|
1851
|
+
const competition = firstCompetition(game);
|
|
1852
|
+
if (competition?.status?.type?.id !== COMPLETED_STATUS_ID) return "--";
|
|
1853
|
+
return findCompetitor(competition.competitors, teamEspnId)?.own.record?.[0]?.displayValue || "--";
|
|
1854
|
+
}
|
|
1855
|
+
function getWinningGoalie(game) {
|
|
1856
|
+
const athlete = firstCompetition(game)?.featuredAthletes?.[0]?.athlete;
|
|
1857
|
+
if (!athlete?.lastName) return "--";
|
|
1858
|
+
return /* @__PURE__ */ jsx16("div", { className: "flex flex-col leading-tight", children: /* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }) });
|
|
1859
|
+
}
|
|
1860
|
+
function getHockeyTopPlayer(game) {
|
|
1861
|
+
const competitors = firstCompetition(game)?.competitors;
|
|
1862
|
+
const competitor = competitors?.find((c) => c?.leaders?.[0]?.leaders?.length);
|
|
1863
|
+
const top = competitor?.leaders?.[0]?.leaders?.[0];
|
|
1864
|
+
if (!top?.athlete?.lastName) return "--";
|
|
1865
|
+
return leaderCell(
|
|
1866
|
+
{ displayName: top.athlete.lastName, displayValue: top.displayValue || "--" },
|
|
1867
|
+
true
|
|
1868
|
+
);
|
|
1869
|
+
}
|
|
1870
|
+
function getMlbPitcher(game, pitcherType) {
|
|
1871
|
+
const pitcher = firstCompetition(game)?.featuredAthletes?.find((a) => a.name === pitcherType);
|
|
1872
|
+
const athlete = pitcher?.athlete;
|
|
1873
|
+
if (!athlete?.lastName) return "--";
|
|
1874
|
+
const stat = pitcherType === "savingPitcher" ? athlete.saves : athlete.record;
|
|
1875
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col leading-tight", children: [
|
|
1876
|
+
/* @__PURE__ */ jsx16("span", { className: "text-text-primary font-normal truncate", children: athlete.lastName }),
|
|
1877
|
+
/* @__PURE__ */ jsx16("span", { className: "text-text-secondary text-11 truncate", children: stat || "--" })
|
|
1878
|
+
] });
|
|
1879
|
+
}
|
|
1880
|
+
function OpponentCell({
|
|
1881
|
+
game,
|
|
1882
|
+
teamEspnId,
|
|
1883
|
+
leagueId,
|
|
1884
|
+
leagueAbbreviation,
|
|
1885
|
+
resolveLogoUrl,
|
|
1886
|
+
defaultLogoUrl,
|
|
1887
|
+
showName
|
|
1888
|
+
}) {
|
|
1889
|
+
const match = findCompetitor(firstCompetition(game)?.competitors, teamEspnId);
|
|
1890
|
+
if (!match || leagueId === null || !leagueAbbreviation) return /* @__PURE__ */ jsx16(Fragment5, { children: "--" });
|
|
1891
|
+
const prefix = match.own.homeAway === "home" ? "vs" : "@";
|
|
1892
|
+
const opponentTeam = match.other.team;
|
|
1893
|
+
const isSpecialLeague = SPECIAL_LOGO_LEAGUES.includes(leagueAbbreviation);
|
|
1894
|
+
const identifier = isSpecialLeague ? opponentTeam.abbreviation : opponentTeam.id;
|
|
1895
|
+
const folder = COLLEGE_LEAGUE_IDS.includes(leagueId) ? "NCAA" : leagueAbbreviation;
|
|
1896
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1 sm:gap-2 h-full overflow-hidden", children: [
|
|
1897
|
+
/* @__PURE__ */ jsx16("span", { className: "text-text-primary body-text shrink-0 sm:w-4", children: prefix }),
|
|
1898
|
+
/* @__PURE__ */ jsx16(
|
|
1899
|
+
"img",
|
|
1900
|
+
{
|
|
1901
|
+
src: resolveLogoUrl(folder, identifier),
|
|
1902
|
+
alt: showName ? "" : opponentTeam.displayName,
|
|
1903
|
+
loading: "lazy",
|
|
1904
|
+
className: "h-5 w-5 shrink-0 inline sm:h-6 sm:w-6 sm:mr-2",
|
|
1905
|
+
onError: (event) => {
|
|
1906
|
+
event.currentTarget.src = defaultLogoUrl;
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
),
|
|
1910
|
+
showName && /* @__PURE__ */ jsx16("span", { className: "text-primary-color-nuk-text body-text line-clamp-2", children: opponentTeam.displayName })
|
|
1911
|
+
] });
|
|
1912
|
+
}
|
|
1913
|
+
function buildScheduleColumns({
|
|
1914
|
+
leagueId,
|
|
1915
|
+
leagueAbbreviation,
|
|
1916
|
+
teamEspnId,
|
|
1917
|
+
resolveLogoUrl,
|
|
1918
|
+
defaultLogoUrl,
|
|
1919
|
+
isSm,
|
|
1920
|
+
isSmallLaptop
|
|
1921
|
+
}) {
|
|
1922
|
+
const showsHockey = showsHockeyLeaders(leagueId);
|
|
1923
|
+
return [
|
|
1924
|
+
{
|
|
1925
|
+
id: "game_date",
|
|
1926
|
+
header: () => /* @__PURE__ */ jsx16("div", { className: "w-[50px] shrink-0", children: "Date" }),
|
|
1927
|
+
accessorFn: (row) => row.game_date,
|
|
1928
|
+
cell: ({ row }) => formatScheduleDate(row.original),
|
|
1929
|
+
meta: { cellSize: isSm ? "xs" : "xxs" }
|
|
1930
|
+
},
|
|
1931
|
+
{
|
|
1932
|
+
id: "opponent",
|
|
1933
|
+
header: () => /* @__PURE__ */ jsx16("div", { children: isSm ? "Opponent" : "Opp" }),
|
|
1934
|
+
cell: ({ row }) => /* @__PURE__ */ jsx16(
|
|
1935
|
+
OpponentCell,
|
|
1936
|
+
{
|
|
1937
|
+
game: row.original,
|
|
1938
|
+
teamEspnId,
|
|
1939
|
+
leagueId,
|
|
1940
|
+
leagueAbbreviation,
|
|
1941
|
+
resolveLogoUrl,
|
|
1942
|
+
defaultLogoUrl,
|
|
1943
|
+
showName: isSm
|
|
1944
|
+
}
|
|
1945
|
+
),
|
|
1946
|
+
meta: { cellSize: isSm ? isSmallLaptop ? "lg" : "l" : "eclipse" }
|
|
1947
|
+
},
|
|
1948
|
+
{
|
|
1949
|
+
id: "result",
|
|
1950
|
+
header: "Result",
|
|
1951
|
+
cell: ({ row }) => getScheduleResult(row.original, teamEspnId) ?? "--",
|
|
1952
|
+
meta: { cellSize: "xs" }
|
|
1953
|
+
},
|
|
1954
|
+
{
|
|
1955
|
+
id: "record",
|
|
1956
|
+
header: showsHockey ? "W-L-OTL" : "W-L",
|
|
1957
|
+
cell: ({ row }) => getScheduleRecord(row.original, teamEspnId),
|
|
1958
|
+
meta: { cellSize: "xs" }
|
|
1959
|
+
},
|
|
1960
|
+
...showsMlbLeaders(leagueId) ? [
|
|
1961
|
+
{
|
|
1962
|
+
id: "win",
|
|
1963
|
+
header: "Win",
|
|
1964
|
+
cell: ({ row }) => getMlbPitcher(row.original, "winningPitcher"),
|
|
1965
|
+
meta: { cellSize: "s" }
|
|
1966
|
+
},
|
|
1967
|
+
{
|
|
1968
|
+
id: "loss",
|
|
1969
|
+
header: "Loss",
|
|
1970
|
+
cell: ({ row }) => getMlbPitcher(row.original, "losingPitcher"),
|
|
1971
|
+
meta: { cellSize: "s" }
|
|
1972
|
+
},
|
|
1973
|
+
{
|
|
1974
|
+
id: "save",
|
|
1975
|
+
header: "Save",
|
|
1976
|
+
cell: ({ row }) => getMlbPitcher(row.original, "savingPitcher"),
|
|
1977
|
+
meta: { cellSize: "s" }
|
|
1978
|
+
}
|
|
1979
|
+
] : [],
|
|
1980
|
+
...showsBasketballLeaders(leagueId) ? [
|
|
1981
|
+
{
|
|
1982
|
+
id: "topPts",
|
|
1983
|
+
header: "Top Pts",
|
|
1984
|
+
cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "points"), true),
|
|
1985
|
+
meta: { cellSize: "s" }
|
|
1986
|
+
},
|
|
1987
|
+
{
|
|
1988
|
+
id: "topReb",
|
|
1989
|
+
header: "Top Reb",
|
|
1990
|
+
cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rebounds"), true),
|
|
1991
|
+
meta: { cellSize: "s" }
|
|
1992
|
+
},
|
|
1993
|
+
{
|
|
1994
|
+
id: "topAst",
|
|
1995
|
+
header: "Top Ast",
|
|
1996
|
+
cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "assists"), true),
|
|
1997
|
+
meta: { cellSize: "s" }
|
|
1998
|
+
}
|
|
1999
|
+
] : [],
|
|
2000
|
+
...showsHockey ? [
|
|
2001
|
+
{
|
|
2002
|
+
id: "wGoalie",
|
|
2003
|
+
header: "W Goalie",
|
|
2004
|
+
cell: ({ row }) => getWinningGoalie(row.original),
|
|
2005
|
+
meta: { cellSize: "s" }
|
|
2006
|
+
},
|
|
2007
|
+
{
|
|
2008
|
+
id: "topPlayer",
|
|
2009
|
+
header: "Top Player",
|
|
2010
|
+
cell: ({ row }) => getHockeyTopPlayer(row.original),
|
|
2011
|
+
meta: { cellSize: "s" }
|
|
2012
|
+
}
|
|
2013
|
+
] : [],
|
|
2014
|
+
...showsFootballLeaders(leagueId) ? [
|
|
2015
|
+
{
|
|
2016
|
+
id: "topPass",
|
|
2017
|
+
header: "Top Pass",
|
|
2018
|
+
cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "passingLeader")),
|
|
2019
|
+
meta: { cellSize: "l" }
|
|
2020
|
+
},
|
|
2021
|
+
{
|
|
2022
|
+
id: "topRush",
|
|
2023
|
+
header: "Top Rush",
|
|
2024
|
+
cell: ({ row }) => leaderCell(findLeader(firstCompetition(row.original)?.competitors, "rushingLeader")),
|
|
2025
|
+
meta: { cellSize: "l" }
|
|
2026
|
+
},
|
|
2027
|
+
{
|
|
2028
|
+
id: "topRec",
|
|
2029
|
+
header: "Top Rec",
|
|
2030
|
+
cell: ({ row }) => leaderCell(
|
|
2031
|
+
findLeader(firstCompetition(row.original)?.competitors, "receivingLeader")
|
|
2032
|
+
),
|
|
2033
|
+
meta: { cellSize: "l" }
|
|
2034
|
+
}
|
|
2035
|
+
] : []
|
|
2036
|
+
];
|
|
2037
|
+
}
|
|
2038
|
+
function ScheduleBody({
|
|
2039
|
+
seasonsLoading,
|
|
2040
|
+
seasons,
|
|
2041
|
+
isSeasonsError,
|
|
2042
|
+
columns,
|
|
2043
|
+
games,
|
|
2044
|
+
gamesLoading,
|
|
2045
|
+
isGamesError,
|
|
2046
|
+
isSm,
|
|
2047
|
+
isSmallLaptop
|
|
2048
|
+
}) {
|
|
2049
|
+
if (seasonsLoading) {
|
|
2050
|
+
return /* @__PURE__ */ jsx16("div", { className: "flex justify-center py-8", children: /* @__PURE__ */ jsx16("div", { className: "text-sm text-text-primary", children: "Loading seasons..." }) });
|
|
2051
|
+
}
|
|
2052
|
+
if (!seasons || seasons.years.length === 0) {
|
|
2053
|
+
return /* @__PURE__ */ jsx16("div", { className: "text-center py-8", children: /* @__PURE__ */ jsx16("p", { className: "text-text-primary", children: isSeasonsError ? "Couldn't load seasons. Please try again." : "No seasons found" }) });
|
|
2054
|
+
}
|
|
2055
|
+
return /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-3", children: [
|
|
2056
|
+
/* @__PURE__ */ jsx16(SeasonSelector, { ...seasons, className: "gap-2 min-[360px]:gap-3" }),
|
|
2057
|
+
/* @__PURE__ */ jsx16("div", { children: /* @__PURE__ */ jsx16(
|
|
2058
|
+
BaseTable4,
|
|
2059
|
+
{
|
|
2060
|
+
columns,
|
|
2061
|
+
data: games,
|
|
2062
|
+
pageSize: games.length || 10,
|
|
2063
|
+
splitLayout: isSmallLaptop || !isSm,
|
|
2064
|
+
splitLayoutGridCols: isSm ? "sm:!grid-cols-[minmax(232px,auto)_1fr]" : "!grid-cols-[minmax(117px,auto)_1fr]",
|
|
2065
|
+
loading: gamesLoading,
|
|
2066
|
+
containerClassName: "border-0 rounded-none h-full",
|
|
2067
|
+
className: "h-full border-none",
|
|
2068
|
+
numberOfColumns: 2,
|
|
2069
|
+
emptyMessage: isGamesError ? "Couldn't load games. Please try again." : "No games found for this season"
|
|
2070
|
+
}
|
|
2071
|
+
) })
|
|
2072
|
+
] });
|
|
2073
|
+
}
|
|
2074
|
+
function TeamScheduleTable({
|
|
2075
|
+
games,
|
|
2076
|
+
gamesLoading = false,
|
|
2077
|
+
isGamesError = false,
|
|
2078
|
+
leagueId,
|
|
2079
|
+
leagueAbbreviation,
|
|
2080
|
+
isTeamError = false,
|
|
2081
|
+
teamEspnId,
|
|
2082
|
+
resolveLogoUrl,
|
|
2083
|
+
defaultLogoUrl,
|
|
2084
|
+
seasons,
|
|
2085
|
+
seasonsLoading = false,
|
|
2086
|
+
isSeasonsError = false,
|
|
2087
|
+
isSm,
|
|
2088
|
+
isSmallLaptop,
|
|
2089
|
+
className
|
|
2090
|
+
}) {
|
|
2091
|
+
const columns = buildScheduleColumns({
|
|
2092
|
+
leagueId,
|
|
2093
|
+
leagueAbbreviation,
|
|
2094
|
+
teamEspnId,
|
|
2095
|
+
resolveLogoUrl,
|
|
2096
|
+
defaultLogoUrl,
|
|
2097
|
+
isSm,
|
|
2098
|
+
isSmallLaptop
|
|
2099
|
+
});
|
|
2100
|
+
if (isTeamError) {
|
|
2101
|
+
return /* @__PURE__ */ jsx16(Card8, { className: cn14("border-0", className), children: /* @__PURE__ */ jsx16(CardContent8, { className: "p-4 flex justify-center items-center", children: /* @__PURE__ */ jsx16("p", { className: "text-text-secondary", children: "Couldn't load team information. Please try again." }) }) });
|
|
2102
|
+
}
|
|
2103
|
+
if (leagueId === null) {
|
|
2104
|
+
return /* @__PURE__ */ jsx16(Card8, { className: cn14("border-0", className), children: /* @__PURE__ */ jsxs16(CardContent8, { className: "p-4 flex justify-center items-center gap-2", children: [
|
|
2105
|
+
/* @__PURE__ */ jsx16(IconLoader3, {}),
|
|
2106
|
+
/* @__PURE__ */ jsx16("p", { className: "text-text-secondary", children: "Loading team information..." })
|
|
2107
|
+
] }) });
|
|
2108
|
+
}
|
|
2109
|
+
return /* @__PURE__ */ jsxs16(Card8, { className: cn14("border-none p-4 flex flex-col gap-3", className), children: [
|
|
2110
|
+
/* @__PURE__ */ jsx16(CardHeader7, { className: "p-0 flex flex-row items-center justify-between space-y-0", children: /* @__PURE__ */ jsx16(CardTitle7, { children: "Schedule" }) }),
|
|
2111
|
+
/* @__PURE__ */ jsx16(CardContent8, { className: "space-y-0 p-0 flex flex-col gap-3", children: /* @__PURE__ */ jsx16(
|
|
2112
|
+
ScheduleBody,
|
|
2113
|
+
{
|
|
2114
|
+
seasonsLoading,
|
|
2115
|
+
seasons,
|
|
2116
|
+
isSeasonsError,
|
|
2117
|
+
columns,
|
|
2118
|
+
games,
|
|
2119
|
+
gamesLoading,
|
|
2120
|
+
isGamesError,
|
|
2121
|
+
isSm,
|
|
2122
|
+
isSmallLaptop
|
|
2123
|
+
}
|
|
2124
|
+
) })
|
|
2125
|
+
] });
|
|
2126
|
+
}
|
|
2127
|
+
export {
|
|
2128
|
+
EmptyValue,
|
|
2129
|
+
FactField,
|
|
2130
|
+
FactPills,
|
|
2131
|
+
FieldLabel,
|
|
2132
|
+
RecentGamesWidget,
|
|
2133
|
+
SeasonSelector,
|
|
2134
|
+
StatColumn,
|
|
2135
|
+
StatRankingLeaderboardDialog,
|
|
2136
|
+
TeamFactsContent,
|
|
2137
|
+
TeamFactsWidget,
|
|
2138
|
+
TeamInfoCard,
|
|
2139
|
+
TeamScheduleTable,
|
|
2140
|
+
TeamSeasonScheduleSummaryPanel,
|
|
2141
|
+
TeamSeasonStatsSummaryPanel,
|
|
2142
|
+
TeamSeasonStatsWidget,
|
|
2143
|
+
TeamStaffTable,
|
|
2144
|
+
TeamStatsTable,
|
|
2145
|
+
VenuePhoto
|
|
2146
|
+
};
|
|
2147
|
+
//# sourceMappingURL=team.js.map
|