@nukleus-sports/core 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +58 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -4
- package/dist/index.d.ts +26 -4
- package/dist/index.js +55 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -58,6 +58,7 @@ __export(src_exports, {
|
|
|
58
58
|
formatYearPills: () => formatYearPills,
|
|
59
59
|
getDealStatus: () => getDealStatus,
|
|
60
60
|
getEffectiveMemberRole: () => getEffectiveMemberRole,
|
|
61
|
+
getOrderedTeamStatTypesForCategory: () => getOrderedTeamStatTypesForCategory,
|
|
61
62
|
getPreferredSeasonType: () => getPreferredSeasonType,
|
|
62
63
|
getRecentGameResult: () => getRecentGameResult,
|
|
63
64
|
getRosterCellValue: () => getRosterCellValue,
|
|
@@ -71,6 +72,7 @@ __export(src_exports, {
|
|
|
71
72
|
getTeamRankingConfigIds: () => getTeamRankingConfigIds,
|
|
72
73
|
getTeamStatColumns: () => getTeamStatColumns,
|
|
73
74
|
getTeamVenueConfig: () => getTeamVenueConfig,
|
|
75
|
+
getVisibleTeamStatTypes: () => getVisibleTeamStatTypes,
|
|
74
76
|
hasTeamFacts: () => hasTeamFacts,
|
|
75
77
|
isGameBeforeDay: () => isGameBeforeDay,
|
|
76
78
|
isGameCompleted: () => isGameCompleted,
|
|
@@ -83,6 +85,7 @@ __export(src_exports, {
|
|
|
83
85
|
parseTeamVenue: () => parseTeamVenue,
|
|
84
86
|
resolveRecentGameOpponent: () => resolveRecentGameOpponent,
|
|
85
87
|
selectRecentGames: () => selectRecentGames,
|
|
88
|
+
showsTeamStatCategoryPicker: () => showsTeamStatCategoryPicker,
|
|
86
89
|
sortTeamStaff: () => sortTeamStaff,
|
|
87
90
|
startOfLocalDay: () => startOfLocalDay,
|
|
88
91
|
teamFactsDisplayFields: () => teamFactsDisplayFields,
|
|
@@ -693,6 +696,55 @@ function computeTeamSeasonStatsFromSummary(summary, sportId) {
|
|
|
693
696
|
return null;
|
|
694
697
|
}
|
|
695
698
|
|
|
699
|
+
// src/teamStatsTable.ts
|
|
700
|
+
var HIDDEN_TEAM_STAT_TYPES_CONFIG = {
|
|
701
|
+
// Football (sport_id = 1)
|
|
702
|
+
1: [250, 253, 254, 263, 264, 271, 272, 268, 257, 267],
|
|
703
|
+
// Basketball (sport_id = 2)
|
|
704
|
+
2: [293, 295, 297, 300, 281, 283],
|
|
705
|
+
// Baseball (sport_id = 3)
|
|
706
|
+
3: [307, 311, 312, 319, 320, 321],
|
|
707
|
+
// Hockey (sport_id = 5)
|
|
708
|
+
5: [338, 340, 346]
|
|
709
|
+
};
|
|
710
|
+
var TEAM_STAT_DISPLAY_ORDER_CONFIG = {
|
|
711
|
+
// Football (sport_id = 1)
|
|
712
|
+
1: {
|
|
713
|
+
offense: [251, 255, 261, 244, 246, 248, 266, 268, 257, 259, 265, 270],
|
|
714
|
+
defense: [252, 256, 262, 245, 247, 249, 267, 269, 258, 260]
|
|
715
|
+
},
|
|
716
|
+
// Hockey (sport_id = 5)
|
|
717
|
+
5: {
|
|
718
|
+
offense: [332, 334, 336, 328, 326, 330, 342, 344]
|
|
719
|
+
},
|
|
720
|
+
// Baseball (sport_id = 3)
|
|
721
|
+
3: {
|
|
722
|
+
batting: [303, 308, 304, 309, 306, 302, 310, 305, 313],
|
|
723
|
+
pitching: [325, 323, 316, 324, 317, 322, 318, 315, 314]
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
var SPORTS_WITHOUT_STAT_CATEGORIES = [2, 5];
|
|
727
|
+
function getVisibleTeamStatTypes(statTypes, sportId) {
|
|
728
|
+
const hidden = new Set(HIDDEN_TEAM_STAT_TYPES_CONFIG[sportId] ?? []);
|
|
729
|
+
return statTypes.filter((statType) => statType.sport_id === sportId && !hidden.has(statType.id));
|
|
730
|
+
}
|
|
731
|
+
function getOrderedTeamStatTypesForCategory(statTypes, sportId, category) {
|
|
732
|
+
const filtered = statTypes.filter((statType) => statType.type_source_name === category);
|
|
733
|
+
const order = TEAM_STAT_DISPLAY_ORDER_CONFIG[sportId]?.[category];
|
|
734
|
+
if (!order) return filtered;
|
|
735
|
+
return [...filtered].sort((a, b) => {
|
|
736
|
+
const indexA = order.indexOf(a.id);
|
|
737
|
+
const indexB = order.indexOf(b.id);
|
|
738
|
+
if (indexA !== -1 && indexB !== -1) return indexA - indexB;
|
|
739
|
+
if (indexA !== -1) return -1;
|
|
740
|
+
if (indexB !== -1) return 1;
|
|
741
|
+
return a.id - b.id;
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
function showsTeamStatCategoryPicker(sportId) {
|
|
745
|
+
return !SPORTS_WITHOUT_STAT_CATEGORIES.includes(sportId);
|
|
746
|
+
}
|
|
747
|
+
|
|
696
748
|
// src/teamSeasonSelector.ts
|
|
697
749
|
function getPreferredSeasonType(types) {
|
|
698
750
|
if (types.length === 0) return null;
|
|
@@ -700,15 +752,15 @@ function getPreferredSeasonType(types) {
|
|
|
700
752
|
return Math.max(...types);
|
|
701
753
|
}
|
|
702
754
|
function getSeasonYearOptions(seasons) {
|
|
703
|
-
const years = [...new Set(seasons.map((s) => s.
|
|
755
|
+
const years = [...new Set(seasons.map((s) => s.year))].sort((a, b) => b - a);
|
|
704
756
|
return years.map((year) => ({
|
|
705
757
|
value: year,
|
|
706
|
-
label: seasons.find((s) => s.
|
|
758
|
+
label: seasons.find((s) => s.year === year)?.year_display ?? String(year)
|
|
707
759
|
}));
|
|
708
760
|
}
|
|
709
761
|
function getSeasonTypeOptions(seasons, selectedYear) {
|
|
710
762
|
if (selectedYear === null) return [];
|
|
711
|
-
return seasons.filter((s) => s.
|
|
763
|
+
return seasons.filter((s) => s.year === selectedYear).sort((a, b) => a.type - b.type).map((s) => ({ value: s.type, label: s.type_name }));
|
|
712
764
|
}
|
|
713
765
|
|
|
714
766
|
// src/recentGamesSelection.ts
|
|
@@ -1445,6 +1497,7 @@ function buildRecentGameRows({
|
|
|
1445
1497
|
formatYearPills,
|
|
1446
1498
|
getDealStatus,
|
|
1447
1499
|
getEffectiveMemberRole,
|
|
1500
|
+
getOrderedTeamStatTypesForCategory,
|
|
1448
1501
|
getPreferredSeasonType,
|
|
1449
1502
|
getRecentGameResult,
|
|
1450
1503
|
getRosterCellValue,
|
|
@@ -1458,6 +1511,7 @@ function buildRecentGameRows({
|
|
|
1458
1511
|
getTeamRankingConfigIds,
|
|
1459
1512
|
getTeamStatColumns,
|
|
1460
1513
|
getTeamVenueConfig,
|
|
1514
|
+
getVisibleTeamStatTypes,
|
|
1461
1515
|
hasTeamFacts,
|
|
1462
1516
|
isGameBeforeDay,
|
|
1463
1517
|
isGameCompleted,
|
|
@@ -1470,6 +1524,7 @@ function buildRecentGameRows({
|
|
|
1470
1524
|
parseTeamVenue,
|
|
1471
1525
|
resolveRecentGameOpponent,
|
|
1472
1526
|
selectRecentGames,
|
|
1527
|
+
showsTeamStatCategoryPicker,
|
|
1473
1528
|
sortTeamStaff,
|
|
1474
1529
|
startOfLocalDay,
|
|
1475
1530
|
teamFactsDisplayFields,
|