@digilogiclabs/saas-factory-ui 2.1.0 → 2.2.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.mjs CHANGED
@@ -40663,6 +40663,27 @@ function generateSchedule(teams, roundLabel) {
40663
40663
  }
40664
40664
  return rounds;
40665
40665
  }
40666
+ function hydrateResumeRounds(resume, teams) {
40667
+ if (!resume?.length || teams.length < 2) return [];
40668
+ const expected = teams.length % 2 === 0 ? teams.length - 1 : teams.length;
40669
+ if (resume.length !== expected) return [];
40670
+ const roster = new Set(teams.map((t) => t.toLowerCase()));
40671
+ for (const round of resume) {
40672
+ for (const m of round.matchups) {
40673
+ for (const side of [m.home, m.away]) {
40674
+ if (side !== BYE_TOKEN && !roster.has(side.toLowerCase())) return [];
40675
+ }
40676
+ }
40677
+ }
40678
+ return resume.map((round) => ({
40679
+ label: round.label,
40680
+ matchups: round.matchups.map((m) => ({
40681
+ home: m.home,
40682
+ away: m.away,
40683
+ isBye: m.home === BYE_TOKEN || m.away === BYE_TOKEN
40684
+ }))
40685
+ }));
40686
+ }
40666
40687
  var DEFAULT_LABELS4 = {
40667
40688
  inputPlaceholder: "Team or player name (comma-separated for batch)",
40668
40689
  addButton: "Add",
@@ -40683,6 +40704,7 @@ function RoundRobinScheduler({
40683
40704
  darkMode,
40684
40705
  minTeams = 3,
40685
40706
  defaultTeams = [],
40707
+ resumeRounds,
40686
40708
  onTeamsChange,
40687
40709
  onGenerate,
40688
40710
  labels,
@@ -40696,7 +40718,9 @@ function RoundRobinScheduler({
40696
40718
  const L = { ...DEFAULT_LABELS4, ...labels };
40697
40719
  const [teams, setTeams] = useState80(defaultTeams);
40698
40720
  const [input, setInput] = useState80("");
40699
- const [rounds, setRounds] = useState80([]);
40721
+ const [rounds, setRounds] = useState80(
40722
+ () => hydrateResumeRounds(resumeRounds, defaultTeams)
40723
+ );
40700
40724
  const inputRef = useRef49(null);
40701
40725
  useEffect64(() => {
40702
40726
  onTeamsChange?.(teams);
@@ -41222,6 +41246,8 @@ function Scoreboard({
41222
41246
  maxTeams = 8,
41223
41247
  scoreButtons = [-1, 1, 5, 10],
41224
41248
  defaultTeams,
41249
+ initialRound = 1,
41250
+ initialHistory,
41225
41251
  onTeamsChange,
41226
41252
  onRoundAdvance,
41227
41253
  onNewGame,
@@ -41237,8 +41263,12 @@ function Scoreboard({
41237
41263
  const [teams, setTeams] = useState81(
41238
41264
  () => defaultTeams && defaultTeams.length >= minTeams ? defaultTeams.slice(0, maxTeams) : createDefaultTeams(seedCount, L.teamNamePrefix)
41239
41265
  );
41240
- const [round, setRound] = useState81(1);
41241
- const [history, setHistory] = useState81([]);
41266
+ const [round, setRound] = useState81(
41267
+ () => Number.isFinite(initialRound) ? Math.max(1, Math.floor(initialRound)) : 1
41268
+ );
41269
+ const [history, setHistory] = useState81(
41270
+ () => initialHistory && initialHistory.length > 0 ? initialHistory.slice() : []
41271
+ );
41242
41272
  const [historyOpen, setHistoryOpen] = useState81(false);
41243
41273
  const rootRef = useRef50(null);
41244
41274
  const [containerWidth, setContainerWidth] = useState81(0);