@nukleus-sports/core 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +120 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -6
- package/dist/index.d.ts +31 -6
- package/dist/index.js +116 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -87,11 +87,6 @@ interface SeasonRecordGame {
|
|
|
87
87
|
/** Derives a W-L(-OTL/-T) record from a season's raw ESPN game payloads -- see RECONCILIATION.md. */
|
|
88
88
|
declare function computeSeasonSummary(games: SeasonRecordGame[], espnId: string, leagueId: number): SeasonSummary;
|
|
89
89
|
|
|
90
|
-
type RosterColumnKey = "first_name" | "number" | "position" | "height" | "weight" | "age" | "experience" | "college" | "birthplace" | "hometown";
|
|
91
|
-
interface RosterColumnDef {
|
|
92
|
-
key: RosterColumnKey;
|
|
93
|
-
label: string;
|
|
94
|
-
}
|
|
95
90
|
/** The subset of a player's specific_data (jsonb) the roster table reads. */
|
|
96
91
|
interface RosterPlayerSpecificData {
|
|
97
92
|
height?: string | number | null;
|
|
@@ -102,6 +97,12 @@ interface RosterPlayerSpecificData {
|
|
|
102
97
|
birth_state?: string | null;
|
|
103
98
|
birth_country?: string | null;
|
|
104
99
|
}
|
|
100
|
+
|
|
101
|
+
type RosterColumnKey = "first_name" | "number" | "position" | "height" | "weight" | "age" | "experience" | "college" | "birthplace" | "hometown";
|
|
102
|
+
interface RosterColumnDef {
|
|
103
|
+
key: RosterColumnKey;
|
|
104
|
+
label: string;
|
|
105
|
+
}
|
|
105
106
|
interface RosterPlayerLike {
|
|
106
107
|
first_name: string | null;
|
|
107
108
|
last_name: string | null;
|
|
@@ -159,6 +160,8 @@ declare function getTeamPlaceSummaries(specificData: unknown, leagueAbbreviation
|
|
|
159
160
|
};
|
|
160
161
|
/** "Seattle Seahawks" from the `team` + `nickname` columns; either part may be missing. */
|
|
161
162
|
declare function formatTeamName(team: string | null | undefined, nickname: string | null | undefined): string;
|
|
163
|
+
/** Prefixes a scheme-less official website with `http://` so it works as an anchor href. */
|
|
164
|
+
declare function getTeamWebsiteHref(officialWebsite: string): string;
|
|
162
165
|
|
|
163
166
|
interface StaffMember {
|
|
164
167
|
id: number;
|
|
@@ -174,6 +177,21 @@ interface StaffSort {
|
|
|
174
177
|
/** Sorts staff by name, position, or (by default) saved display order -- see RECONCILIATION.md. */
|
|
175
178
|
declare function sortTeamStaff<T extends StaffMember>(staff: T[], sorting: StaffSort[]): T[];
|
|
176
179
|
|
|
180
|
+
interface RosterSort {
|
|
181
|
+
id: string;
|
|
182
|
+
desc: boolean;
|
|
183
|
+
}
|
|
184
|
+
interface SortableRosterPlayer {
|
|
185
|
+
first_name: string | null;
|
|
186
|
+
last_name: string | null;
|
|
187
|
+
number: string | number | null;
|
|
188
|
+
position: string | null;
|
|
189
|
+
experience: string | null;
|
|
190
|
+
specific_data: RosterPlayerSpecificData | null;
|
|
191
|
+
}
|
|
192
|
+
/** Sorts roster players by the first active sort; missing values always last. See RECONCILIATION.md. */
|
|
193
|
+
declare function sortTeamPlayers<T extends SortableRosterPlayer>(players: T[], sorting: RosterSort[], leagueId?: number): T[];
|
|
194
|
+
|
|
177
195
|
interface StatColumnDef {
|
|
178
196
|
label: string;
|
|
179
197
|
suffix?: string;
|
|
@@ -589,4 +607,11 @@ interface BuildRecentGameRowsArgs {
|
|
|
589
607
|
/** One render-ready row per game, in the order given. */
|
|
590
608
|
declare function buildRecentGameRows({ games, teamId, teamEspnId, teams, espnTeams, todayStart, }: BuildRecentGameRowsArgs): RecentGameRow[];
|
|
591
609
|
|
|
592
|
-
|
|
610
|
+
/** Avatar fallback for a team: first letter of the first two words, else the first two
|
|
611
|
+
* characters; "T" when missing or whitespace-only. Case is preserved, not uppercased -- matching
|
|
612
|
+
* both real apps' original behavior. */
|
|
613
|
+
declare function getTeamInitials(team: string | null | undefined): string;
|
|
614
|
+
/** "Conference - Division" fallback when a team has neither set. */
|
|
615
|
+
declare function getTeamConferenceInfo(conference: string | null | undefined, division: string | null | undefined): string;
|
|
616
|
+
|
|
617
|
+
export { BASEBALL_TEAM_STAT_IDS, BASKETBALL_TEAM_STAT_IDS, type BuildRecentGameRowsArgs, CONFIGURED_TEAM_FACTS_LEAGUES, type DatedGame, type DealStatus, EMPTY_FACT_VALUE, FOOTBALL_TEAM_STAT_IDS, HOCKEY_TEAM_STAT_IDS, type MarketingPermission, type ProjectMemberRole, type RecentGameCompetitor, type RecentGameLogo, type RecentGameOpponent, type RecentGameOutcome, type RecentGameRecord, type RecentGameResult, type RecentGameRow, type RecentGameTeamRow, type ResolveOpponentArgs, type RosterColumnDef, type RosterColumnKey, type RosterPlayerLike, type RosterPlayerSpecificData, type RosterSort, type SeasonRecordGame, type SeasonSelectorOption, type SeasonSelectorSeason, type SeasonSummary, type SortableRosterPlayer, type StaffMember, type StaffSort, type StatColumnDef, type StatRanking, type StatRankingFootnoteConfig, TEAM_FACT_KINDS, TEAM_FACT_YEAR_PAIRS, type TeamFacilityImage, type TeamFacilityKind, type TeamFactKey, type TeamFactKind, type TeamFacts, type TeamFactsLeagueConfig, type TeamFactsRival, type TeamFactsRivalState, type TeamFactsRivalTeamRow, type TeamFactsSectionConfig, type TeamFactsSectionLayout, type TeamFactsTeamRow, type TeamFactsWidgetData, type TeamFactsWidgetState, type TeamPlace, type TeamPlaceKind, type TeamPlaceSummary, type TeamSeasonStatEntry, type TeamSeasonStatRecord, type TeamSeasonStatTotal, type TeamSeasonStatsResult, type TeamSeasonSummaryRecord, type TeamStatTypeLike, type TeamVenue, type TeamVenueKind, abbreviatePersonName, buildRecentGameRows, canEditMarketingDeals, canEditProject, canEditTaskStatus, canManageMembers, canViewMarketingDeals, collectRecentGameEspnIds, collectRecentGameTeamIds, computeSeasonSummary, computeTeamSeasonStats, computeTeamSeasonStatsFromSummary, facilityImageCredit, fmt, fmtCurrency, fmtDate, fmtUSD, fmtUSDCompact, fmtUSDWhole, formatDealDate, formatStatNumber, formatStatRank, formatStatRankByConfig, formatSuperBowlYear, formatTeamFactNumber, formatTeamName, formatTeamPlaceAddress, formatYearPills, getDealStatus, getEffectiveMemberRole, getOrderedTeamStatTypesForCategory, getPreferredSeasonType, getRecentGameResult, getRosterCellValue, getRosterColumns, getSeasonTypeOptions, getSeasonYearOptions, getStatRankingFootnotes, getTeamConferenceInfo, getTeamFacilityConfig, getTeamFactsConfig, getTeamInitials, getTeamPlaceSummaries, getTeamRankingConfigIds, getTeamStatColumns, getTeamVenueConfig, getTeamWebsiteHref, getVisibleTeamStatTypes, hasTeamFacts, isGameBeforeDay, isGameCompleted, isJsonRecord, isProjectCancelled, isSupportedTeamStatsSport, isTrueUpcomingGame, parseTeamFacts, parseTeamPlace, parseTeamVenue, resolveRecentGameOpponent, selectRecentGames, showsTeamStatCategoryPicker, sortTeamPlayers, sortTeamStaff, startOfLocalDay, teamFactsDisplayFields, toJsonRecord, toOrdinal, toRivalState, toRomanNumeral, toTeamFactsView, toTrimmedText, topPercentileLabel };
|
package/dist/index.d.ts
CHANGED
|
@@ -87,11 +87,6 @@ interface SeasonRecordGame {
|
|
|
87
87
|
/** Derives a W-L(-OTL/-T) record from a season's raw ESPN game payloads -- see RECONCILIATION.md. */
|
|
88
88
|
declare function computeSeasonSummary(games: SeasonRecordGame[], espnId: string, leagueId: number): SeasonSummary;
|
|
89
89
|
|
|
90
|
-
type RosterColumnKey = "first_name" | "number" | "position" | "height" | "weight" | "age" | "experience" | "college" | "birthplace" | "hometown";
|
|
91
|
-
interface RosterColumnDef {
|
|
92
|
-
key: RosterColumnKey;
|
|
93
|
-
label: string;
|
|
94
|
-
}
|
|
95
90
|
/** The subset of a player's specific_data (jsonb) the roster table reads. */
|
|
96
91
|
interface RosterPlayerSpecificData {
|
|
97
92
|
height?: string | number | null;
|
|
@@ -102,6 +97,12 @@ interface RosterPlayerSpecificData {
|
|
|
102
97
|
birth_state?: string | null;
|
|
103
98
|
birth_country?: string | null;
|
|
104
99
|
}
|
|
100
|
+
|
|
101
|
+
type RosterColumnKey = "first_name" | "number" | "position" | "height" | "weight" | "age" | "experience" | "college" | "birthplace" | "hometown";
|
|
102
|
+
interface RosterColumnDef {
|
|
103
|
+
key: RosterColumnKey;
|
|
104
|
+
label: string;
|
|
105
|
+
}
|
|
105
106
|
interface RosterPlayerLike {
|
|
106
107
|
first_name: string | null;
|
|
107
108
|
last_name: string | null;
|
|
@@ -159,6 +160,8 @@ declare function getTeamPlaceSummaries(specificData: unknown, leagueAbbreviation
|
|
|
159
160
|
};
|
|
160
161
|
/** "Seattle Seahawks" from the `team` + `nickname` columns; either part may be missing. */
|
|
161
162
|
declare function formatTeamName(team: string | null | undefined, nickname: string | null | undefined): string;
|
|
163
|
+
/** Prefixes a scheme-less official website with `http://` so it works as an anchor href. */
|
|
164
|
+
declare function getTeamWebsiteHref(officialWebsite: string): string;
|
|
162
165
|
|
|
163
166
|
interface StaffMember {
|
|
164
167
|
id: number;
|
|
@@ -174,6 +177,21 @@ interface StaffSort {
|
|
|
174
177
|
/** Sorts staff by name, position, or (by default) saved display order -- see RECONCILIATION.md. */
|
|
175
178
|
declare function sortTeamStaff<T extends StaffMember>(staff: T[], sorting: StaffSort[]): T[];
|
|
176
179
|
|
|
180
|
+
interface RosterSort {
|
|
181
|
+
id: string;
|
|
182
|
+
desc: boolean;
|
|
183
|
+
}
|
|
184
|
+
interface SortableRosterPlayer {
|
|
185
|
+
first_name: string | null;
|
|
186
|
+
last_name: string | null;
|
|
187
|
+
number: string | number | null;
|
|
188
|
+
position: string | null;
|
|
189
|
+
experience: string | null;
|
|
190
|
+
specific_data: RosterPlayerSpecificData | null;
|
|
191
|
+
}
|
|
192
|
+
/** Sorts roster players by the first active sort; missing values always last. See RECONCILIATION.md. */
|
|
193
|
+
declare function sortTeamPlayers<T extends SortableRosterPlayer>(players: T[], sorting: RosterSort[], leagueId?: number): T[];
|
|
194
|
+
|
|
177
195
|
interface StatColumnDef {
|
|
178
196
|
label: string;
|
|
179
197
|
suffix?: string;
|
|
@@ -589,4 +607,11 @@ interface BuildRecentGameRowsArgs {
|
|
|
589
607
|
/** One render-ready row per game, in the order given. */
|
|
590
608
|
declare function buildRecentGameRows({ games, teamId, teamEspnId, teams, espnTeams, todayStart, }: BuildRecentGameRowsArgs): RecentGameRow[];
|
|
591
609
|
|
|
592
|
-
|
|
610
|
+
/** Avatar fallback for a team: first letter of the first two words, else the first two
|
|
611
|
+
* characters; "T" when missing or whitespace-only. Case is preserved, not uppercased -- matching
|
|
612
|
+
* both real apps' original behavior. */
|
|
613
|
+
declare function getTeamInitials(team: string | null | undefined): string;
|
|
614
|
+
/** "Conference - Division" fallback when a team has neither set. */
|
|
615
|
+
declare function getTeamConferenceInfo(conference: string | null | undefined, division: string | null | undefined): string;
|
|
616
|
+
|
|
617
|
+
export { BASEBALL_TEAM_STAT_IDS, BASKETBALL_TEAM_STAT_IDS, type BuildRecentGameRowsArgs, CONFIGURED_TEAM_FACTS_LEAGUES, type DatedGame, type DealStatus, EMPTY_FACT_VALUE, FOOTBALL_TEAM_STAT_IDS, HOCKEY_TEAM_STAT_IDS, type MarketingPermission, type ProjectMemberRole, type RecentGameCompetitor, type RecentGameLogo, type RecentGameOpponent, type RecentGameOutcome, type RecentGameRecord, type RecentGameResult, type RecentGameRow, type RecentGameTeamRow, type ResolveOpponentArgs, type RosterColumnDef, type RosterColumnKey, type RosterPlayerLike, type RosterPlayerSpecificData, type RosterSort, type SeasonRecordGame, type SeasonSelectorOption, type SeasonSelectorSeason, type SeasonSummary, type SortableRosterPlayer, type StaffMember, type StaffSort, type StatColumnDef, type StatRanking, type StatRankingFootnoteConfig, TEAM_FACT_KINDS, TEAM_FACT_YEAR_PAIRS, type TeamFacilityImage, type TeamFacilityKind, type TeamFactKey, type TeamFactKind, type TeamFacts, type TeamFactsLeagueConfig, type TeamFactsRival, type TeamFactsRivalState, type TeamFactsRivalTeamRow, type TeamFactsSectionConfig, type TeamFactsSectionLayout, type TeamFactsTeamRow, type TeamFactsWidgetData, type TeamFactsWidgetState, type TeamPlace, type TeamPlaceKind, type TeamPlaceSummary, type TeamSeasonStatEntry, type TeamSeasonStatRecord, type TeamSeasonStatTotal, type TeamSeasonStatsResult, type TeamSeasonSummaryRecord, type TeamStatTypeLike, type TeamVenue, type TeamVenueKind, abbreviatePersonName, buildRecentGameRows, canEditMarketingDeals, canEditProject, canEditTaskStatus, canManageMembers, canViewMarketingDeals, collectRecentGameEspnIds, collectRecentGameTeamIds, computeSeasonSummary, computeTeamSeasonStats, computeTeamSeasonStatsFromSummary, facilityImageCredit, fmt, fmtCurrency, fmtDate, fmtUSD, fmtUSDCompact, fmtUSDWhole, formatDealDate, formatStatNumber, formatStatRank, formatStatRankByConfig, formatSuperBowlYear, formatTeamFactNumber, formatTeamName, formatTeamPlaceAddress, formatYearPills, getDealStatus, getEffectiveMemberRole, getOrderedTeamStatTypesForCategory, getPreferredSeasonType, getRecentGameResult, getRosterCellValue, getRosterColumns, getSeasonTypeOptions, getSeasonYearOptions, getStatRankingFootnotes, getTeamConferenceInfo, getTeamFacilityConfig, getTeamFactsConfig, getTeamInitials, getTeamPlaceSummaries, getTeamRankingConfigIds, getTeamStatColumns, getTeamVenueConfig, getTeamWebsiteHref, getVisibleTeamStatTypes, hasTeamFacts, isGameBeforeDay, isGameCompleted, isJsonRecord, isProjectCancelled, isSupportedTeamStatsSport, isTrueUpcomingGame, parseTeamFacts, parseTeamPlace, parseTeamVenue, resolveRecentGameOpponent, selectRecentGames, showsTeamStatCategoryPicker, sortTeamPlayers, sortTeamStaff, startOfLocalDay, teamFactsDisplayFields, toJsonRecord, toOrdinal, toRivalState, toRomanNumeral, toTeamFactsView, toTrimmedText, topPercentileLabel };
|
package/dist/index.js
CHANGED
|
@@ -133,55 +133,9 @@ function computeSeasonSummary(games, espnId, leagueId) {
|
|
|
133
133
|
return { record, gamesPlayed: completedGames, totalGames };
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
// src/
|
|
137
|
-
var NFL_NBA_WNBA_LEAGUE_IDS = [1, 4, 5];
|
|
138
|
-
var MLB_NHL_LEAGUE_IDS = [7, 14];
|
|
139
|
-
var NCAAF_LEAGUE_IDS = [2, 13];
|
|
140
|
-
var NCAAM_LEAGUE_ID = 6;
|
|
136
|
+
// src/teamRosterFormat.ts
|
|
141
137
|
var MLS_LEAGUE_ID = 10;
|
|
142
138
|
var MLB_LEAGUE_ID = 7;
|
|
143
|
-
var BASE_COLUMNS = [
|
|
144
|
-
{ key: "first_name", label: "Name" },
|
|
145
|
-
{ key: "number", label: "No." },
|
|
146
|
-
{ key: "position", label: "Position" },
|
|
147
|
-
{ key: "height", label: "Height" },
|
|
148
|
-
{ key: "weight", label: "Weight" },
|
|
149
|
-
{ key: "age", label: "Age" }
|
|
150
|
-
];
|
|
151
|
-
function getRosterColumns(leagueId) {
|
|
152
|
-
if (NFL_NBA_WNBA_LEAGUE_IDS.includes(leagueId)) {
|
|
153
|
-
return [
|
|
154
|
-
...BASE_COLUMNS,
|
|
155
|
-
{ key: "experience", label: "Exp." },
|
|
156
|
-
{ key: "college", label: "College" }
|
|
157
|
-
];
|
|
158
|
-
}
|
|
159
|
-
if (MLB_NHL_LEAGUE_IDS.includes(leagueId)) {
|
|
160
|
-
return [
|
|
161
|
-
...BASE_COLUMNS,
|
|
162
|
-
{ key: "experience", label: "Exp" },
|
|
163
|
-
{ key: "birthplace", label: "Birthplace" }
|
|
164
|
-
];
|
|
165
|
-
}
|
|
166
|
-
if (NCAAF_LEAGUE_IDS.includes(leagueId)) {
|
|
167
|
-
return [
|
|
168
|
-
...BASE_COLUMNS,
|
|
169
|
-
{ key: "experience", label: "Class" },
|
|
170
|
-
{ key: "hometown", label: "Hometown" }
|
|
171
|
-
];
|
|
172
|
-
}
|
|
173
|
-
if (leagueId === NCAAM_LEAGUE_ID) {
|
|
174
|
-
return [
|
|
175
|
-
...BASE_COLUMNS,
|
|
176
|
-
{ key: "experience", label: "Class" },
|
|
177
|
-
{ key: "birthplace", label: "Birthplace" }
|
|
178
|
-
];
|
|
179
|
-
}
|
|
180
|
-
if (leagueId === MLS_LEAGUE_ID) {
|
|
181
|
-
return [...BASE_COLUMNS, { key: "birthplace", label: "Birthplace" }];
|
|
182
|
-
}
|
|
183
|
-
return [];
|
|
184
|
-
}
|
|
185
139
|
function calculateAge(birthDateString) {
|
|
186
140
|
const birthDate = new Date(birthDateString);
|
|
187
141
|
const today = /* @__PURE__ */ new Date();
|
|
@@ -232,6 +186,54 @@ function formatHometown(specificData) {
|
|
|
232
186
|
if (state) return state;
|
|
233
187
|
return "--";
|
|
234
188
|
}
|
|
189
|
+
|
|
190
|
+
// src/teamRosterColumns.ts
|
|
191
|
+
var NFL_NBA_WNBA_LEAGUE_IDS = [1, 4, 5];
|
|
192
|
+
var MLB_NHL_LEAGUE_IDS = [7, 14];
|
|
193
|
+
var NCAAF_LEAGUE_IDS = [2, 13];
|
|
194
|
+
var NCAAM_LEAGUE_ID = 6;
|
|
195
|
+
var BASE_COLUMNS = [
|
|
196
|
+
{ key: "first_name", label: "Name" },
|
|
197
|
+
{ key: "number", label: "No." },
|
|
198
|
+
{ key: "position", label: "Position" },
|
|
199
|
+
{ key: "height", label: "Height" },
|
|
200
|
+
{ key: "weight", label: "Weight" },
|
|
201
|
+
{ key: "age", label: "Age" }
|
|
202
|
+
];
|
|
203
|
+
function getRosterColumns(leagueId) {
|
|
204
|
+
if (NFL_NBA_WNBA_LEAGUE_IDS.includes(leagueId)) {
|
|
205
|
+
return [
|
|
206
|
+
...BASE_COLUMNS,
|
|
207
|
+
{ key: "experience", label: "Exp." },
|
|
208
|
+
{ key: "college", label: "College" }
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
if (MLB_NHL_LEAGUE_IDS.includes(leagueId)) {
|
|
212
|
+
return [
|
|
213
|
+
...BASE_COLUMNS,
|
|
214
|
+
{ key: "experience", label: "Exp" },
|
|
215
|
+
{ key: "birthplace", label: "Birthplace" }
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
if (NCAAF_LEAGUE_IDS.includes(leagueId)) {
|
|
219
|
+
return [
|
|
220
|
+
...BASE_COLUMNS,
|
|
221
|
+
{ key: "experience", label: "Class" },
|
|
222
|
+
{ key: "hometown", label: "Hometown" }
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
if (leagueId === NCAAM_LEAGUE_ID) {
|
|
226
|
+
return [
|
|
227
|
+
...BASE_COLUMNS,
|
|
228
|
+
{ key: "experience", label: "Class" },
|
|
229
|
+
{ key: "birthplace", label: "Birthplace" }
|
|
230
|
+
];
|
|
231
|
+
}
|
|
232
|
+
if (leagueId === MLS_LEAGUE_ID) {
|
|
233
|
+
return [...BASE_COLUMNS, { key: "birthplace", label: "Birthplace" }];
|
|
234
|
+
}
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
235
237
|
function getRosterCellValue(player, columnKey, leagueId) {
|
|
236
238
|
switch (columnKey) {
|
|
237
239
|
case "first_name":
|
|
@@ -315,10 +317,13 @@ function getTeamPlaceSummaries(specificData, leagueAbbreviation) {
|
|
|
315
317
|
function formatTeamName(team, nickname) {
|
|
316
318
|
return [team, nickname].map((part) => part?.trim()).filter(Boolean).join(" ");
|
|
317
319
|
}
|
|
320
|
+
function getTeamWebsiteHref(officialWebsite) {
|
|
321
|
+
return /^https?:\/\//i.test(officialWebsite) ? officialWebsite : `http://${officialWebsite}`;
|
|
322
|
+
}
|
|
318
323
|
|
|
319
|
-
// src/
|
|
320
|
-
var EMPTY_VALUES = /* @__PURE__ */ new Set(["", "-"]);
|
|
321
|
-
function
|
|
324
|
+
// src/compareSortValues.ts
|
|
325
|
+
var EMPTY_VALUES = /* @__PURE__ */ new Set(["", "-", "--"]);
|
|
326
|
+
function compareSortValues(left, right, desc) {
|
|
322
327
|
const leftMissing = typeof left === "string" && EMPTY_VALUES.has(left);
|
|
323
328
|
const rightMissing = typeof right === "string" && EMPTY_VALUES.has(right);
|
|
324
329
|
if (leftMissing && rightMissing) return 0;
|
|
@@ -330,6 +335,8 @@ function compareValues(left, right, desc) {
|
|
|
330
335
|
}
|
|
331
336
|
return String(left).localeCompare(String(right), void 0, { numeric: true, sensitivity: "base" }) * direction;
|
|
332
337
|
}
|
|
338
|
+
|
|
339
|
+
// src/teamStaffSort.ts
|
|
333
340
|
function sortTeamStaff(staff, sorting) {
|
|
334
341
|
const activeSort = sorting[0];
|
|
335
342
|
if (!activeSort) return staff;
|
|
@@ -344,10 +351,53 @@ function sortTeamStaff(staff, sorting) {
|
|
|
344
351
|
return member.display_order;
|
|
345
352
|
}
|
|
346
353
|
};
|
|
347
|
-
return
|
|
354
|
+
return compareSortValues(value(left), value(right), activeSort.desc);
|
|
348
355
|
});
|
|
349
356
|
}
|
|
350
357
|
|
|
358
|
+
// src/teamRosterSort.ts
|
|
359
|
+
function sortValue(player, columnId, leagueId) {
|
|
360
|
+
const data = player.specific_data;
|
|
361
|
+
switch (columnId) {
|
|
362
|
+
case "first_name":
|
|
363
|
+
return [player.first_name, player.last_name].filter(Boolean).join(" ");
|
|
364
|
+
case "number": {
|
|
365
|
+
if (player.number === null || player.number === void 0 || player.number === "") return "-";
|
|
366
|
+
return Number.parseInt(String(player.number), 10) || String(player.number);
|
|
367
|
+
}
|
|
368
|
+
case "position":
|
|
369
|
+
return player.position ?? "-";
|
|
370
|
+
case "height":
|
|
371
|
+
return String(data?.height ?? "-");
|
|
372
|
+
case "weight":
|
|
373
|
+
return Number(data?.weight) || "-";
|
|
374
|
+
case "age":
|
|
375
|
+
return data?.birth_date ? calculateAge(data.birth_date) : "-";
|
|
376
|
+
case "experience":
|
|
377
|
+
if (player.experience === "0") return 0;
|
|
378
|
+
return Number(player.experience) || player.experience || "-";
|
|
379
|
+
case "college":
|
|
380
|
+
return String(data?.college_name ?? "-");
|
|
381
|
+
case "birthplace":
|
|
382
|
+
return formatBirthplace(data ?? null, leagueId ?? 0);
|
|
383
|
+
case "hometown":
|
|
384
|
+
return formatHometown(data ?? null);
|
|
385
|
+
default:
|
|
386
|
+
return "-";
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
function sortTeamPlayers(players, sorting, leagueId) {
|
|
390
|
+
const activeSort = sorting[0];
|
|
391
|
+
if (!activeSort) return players;
|
|
392
|
+
return [...players].sort(
|
|
393
|
+
(left, right) => compareSortValues(
|
|
394
|
+
sortValue(left, activeSort.id, leagueId),
|
|
395
|
+
sortValue(right, activeSort.id, leagueId),
|
|
396
|
+
activeSort.desc
|
|
397
|
+
)
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
|
|
351
401
|
// src/teamSeasonStats.ts
|
|
352
402
|
var FOOTBALL_TEAM_STAT_IDS = {
|
|
353
403
|
PASSING_YARDS: 255,
|
|
@@ -1356,6 +1406,17 @@ function buildRecentGameRows({
|
|
|
1356
1406
|
};
|
|
1357
1407
|
});
|
|
1358
1408
|
}
|
|
1409
|
+
|
|
1410
|
+
// src/teamHeader.ts
|
|
1411
|
+
function getTeamInitials(team) {
|
|
1412
|
+
const words = team?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
1413
|
+
if (words.length === 0) return "T";
|
|
1414
|
+
return words.length > 1 ? words[0][0] + words[1][0] : words[0].substring(0, 2);
|
|
1415
|
+
}
|
|
1416
|
+
function getTeamConferenceInfo(conference, division) {
|
|
1417
|
+
if (!conference && !division) return "Conference - Division";
|
|
1418
|
+
return `${conference || ""} ${division || ""}`.trim();
|
|
1419
|
+
}
|
|
1359
1420
|
export {
|
|
1360
1421
|
BASEBALL_TEAM_STAT_IDS,
|
|
1361
1422
|
BASKETBALL_TEAM_STAT_IDS,
|
|
@@ -1403,12 +1464,15 @@ export {
|
|
|
1403
1464
|
getSeasonTypeOptions,
|
|
1404
1465
|
getSeasonYearOptions,
|
|
1405
1466
|
getStatRankingFootnotes,
|
|
1467
|
+
getTeamConferenceInfo,
|
|
1406
1468
|
getTeamFacilityConfig,
|
|
1407
1469
|
getTeamFactsConfig,
|
|
1470
|
+
getTeamInitials,
|
|
1408
1471
|
getTeamPlaceSummaries,
|
|
1409
1472
|
getTeamRankingConfigIds,
|
|
1410
1473
|
getTeamStatColumns,
|
|
1411
1474
|
getTeamVenueConfig,
|
|
1475
|
+
getTeamWebsiteHref,
|
|
1412
1476
|
getVisibleTeamStatTypes,
|
|
1413
1477
|
hasTeamFacts,
|
|
1414
1478
|
isGameBeforeDay,
|
|
@@ -1423,6 +1487,7 @@ export {
|
|
|
1423
1487
|
resolveRecentGameOpponent,
|
|
1424
1488
|
selectRecentGames,
|
|
1425
1489
|
showsTeamStatCategoryPicker,
|
|
1490
|
+
sortTeamPlayers,
|
|
1426
1491
|
sortTeamStaff,
|
|
1427
1492
|
startOfLocalDay,
|
|
1428
1493
|
teamFactsDisplayFields,
|