@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.
@@ -40361,6 +40361,27 @@ function generateSchedule(teams, roundLabel) {
40361
40361
  }
40362
40362
  return rounds;
40363
40363
  }
40364
+ function hydrateResumeRounds(resume, teams) {
40365
+ if (!resume?.length || teams.length < 2) return [];
40366
+ const expected = teams.length % 2 === 0 ? teams.length - 1 : teams.length;
40367
+ if (resume.length !== expected) return [];
40368
+ const roster = new Set(teams.map((t) => t.toLowerCase()));
40369
+ for (const round of resume) {
40370
+ for (const m of round.matchups) {
40371
+ for (const side of [m.home, m.away]) {
40372
+ if (side !== BYE_TOKEN && !roster.has(side.toLowerCase())) return [];
40373
+ }
40374
+ }
40375
+ }
40376
+ return resume.map((round) => ({
40377
+ label: round.label,
40378
+ matchups: round.matchups.map((m) => ({
40379
+ home: m.home,
40380
+ away: m.away,
40381
+ isBye: m.home === BYE_TOKEN || m.away === BYE_TOKEN
40382
+ }))
40383
+ }));
40384
+ }
40364
40385
  var DEFAULT_LABELS4 = {
40365
40386
  inputPlaceholder: "Team or player name (comma-separated for batch)",
40366
40387
  addButton: "Add",
@@ -40381,6 +40402,7 @@ function RoundRobinScheduler({
40381
40402
  darkMode,
40382
40403
  minTeams = 3,
40383
40404
  defaultTeams = [],
40405
+ resumeRounds,
40384
40406
  onTeamsChange,
40385
40407
  onGenerate,
40386
40408
  labels,
@@ -40394,7 +40416,9 @@ function RoundRobinScheduler({
40394
40416
  const L = { ...DEFAULT_LABELS4, ...labels };
40395
40417
  const [teams, setTeams] = useState77(defaultTeams);
40396
40418
  const [input, setInput] = useState77("");
40397
- const [rounds, setRounds] = useState77([]);
40419
+ const [rounds, setRounds] = useState77(
40420
+ () => hydrateResumeRounds(resumeRounds, defaultTeams)
40421
+ );
40398
40422
  const inputRef = useRef50(null);
40399
40423
  useEffect62(() => {
40400
40424
  onTeamsChange?.(teams);
@@ -40920,6 +40944,8 @@ function Scoreboard({
40920
40944
  maxTeams = 8,
40921
40945
  scoreButtons = [-1, 1, 5, 10],
40922
40946
  defaultTeams,
40947
+ initialRound = 1,
40948
+ initialHistory,
40923
40949
  onTeamsChange,
40924
40950
  onRoundAdvance,
40925
40951
  onNewGame,
@@ -40935,8 +40961,12 @@ function Scoreboard({
40935
40961
  const [teams, setTeams] = useState78(
40936
40962
  () => defaultTeams && defaultTeams.length >= minTeams ? defaultTeams.slice(0, maxTeams) : createDefaultTeams(seedCount, L.teamNamePrefix)
40937
40963
  );
40938
- const [round, setRound] = useState78(1);
40939
- const [history, setHistory] = useState78([]);
40964
+ const [round, setRound] = useState78(
40965
+ () => Number.isFinite(initialRound) ? Math.max(1, Math.floor(initialRound)) : 1
40966
+ );
40967
+ const [history, setHistory] = useState78(
40968
+ () => initialHistory && initialHistory.length > 0 ? initialHistory.slice() : []
40969
+ );
40940
40970
  const [historyOpen, setHistoryOpen] = useState78(false);
40941
40971
  const rootRef = useRef51(null);
40942
40972
  const [containerWidth, setContainerWidth] = useState78(0);