@ethlete/components 1.0.0-next.105 → 1.0.0-next.106
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/CHANGELOG.md +21 -0
- package/design/bracket.ts +2 -2
- package/design/dialog.ts +5 -0
- package/design/sdk/components/anchored-dialog/anchored-dialog.ts +4 -2
- package/design/sdk/components/bracket/bracket.ts +2 -2
- package/design/sdk/components/dialog/dialog.ts +12 -38
- package/design/sdk/ready.json +48 -14
- package/design/table.ts +7 -3
- package/fesm2022/ethlete-components-bracket.mjs +3498 -0
- package/fesm2022/ethlete-components-bracket.mjs.map +1 -0
- package/fesm2022/ethlete-components.mjs +38 -14
- package/fesm2022/ethlete-components.mjs.map +1 -1
- package/generators/generators.json +5 -0
- package/generators/migrate-bracket-entry-point/bracket-entry-point.js +27 -0
- package/generators/migrate-bracket-entry-point/migration.js +60 -0
- package/generators/migrate-bracket-entry-point/schema.json +26 -0
- package/generators/migrate-overlay-and-column-api/migration.js +6 -8
- package/generators/migrate-overlay-and-column-api/overlay-result.js +47 -0
- package/migrations.json +9 -0
- package/package.json +9 -6
- package/src/lib/bracket/bracket.component.css +3 -1
- package/src/lib/button/button.component.css +1 -0
- package/src/lib/button/window-control-button.component.css +2 -2
- package/src/lib/overlay/overlay-main-styles.component.css +6 -0
- package/src/lib/scrollable/headless/scrollable-masks.component.css +2 -0
- package/types/ethlete-components-bracket.d.ts +1177 -0
- package/types/ethlete-components.d.ts +21 -12
|
@@ -0,0 +1,1177 @@
|
|
|
1
|
+
export declare const BRACKET_ERROR_CODES: {
|
|
2
|
+
/** The source has no rounds/matches to render. */
|
|
3
|
+
readonly SOURCE_EMPTY: 3401;
|
|
4
|
+
/** An integration received a tournament mode it does not support. */
|
|
5
|
+
readonly MODE_UNSUPPORTED: 3402;
|
|
6
|
+
/** Two rounds in the source share an id. */
|
|
7
|
+
readonly DUPLICATE_ROUND: 3403;
|
|
8
|
+
/** Two matches in the source share an id. */
|
|
9
|
+
readonly DUPLICATE_MATCH: 3404;
|
|
10
|
+
/** A round-to-round relation could not be resolved (malformed round structure). */
|
|
11
|
+
readonly ROUND_RELATION_INVALID: 3405;
|
|
12
|
+
/** A match-to-match relation could not be resolved (match counts don't line up). */
|
|
13
|
+
readonly MATCH_RELATION_INVALID: 3406;
|
|
14
|
+
/** The computed layout grid is in an inconsistent state. */
|
|
15
|
+
readonly GRID_INVALID: 3407;
|
|
16
|
+
/** Swiss groups could not be generated from the source. */
|
|
17
|
+
readonly SWISS_GROUPING_FAILED: 3408;
|
|
18
|
+
/** A Swiss group ended up without any matches while headers are enabled. */
|
|
19
|
+
readonly SWISS_GROUP_EMPTY: 3409;
|
|
20
|
+
/** A match's resolved winner id is not among its participants. */
|
|
21
|
+
readonly WINNER_NOT_FOUND: 3410;
|
|
22
|
+
/** A required key was missing from an internal bracket lookup map. */
|
|
23
|
+
readonly DATA_LOOKUP_FAILED: 3411;
|
|
24
|
+
/** The default cards are rendering but no `matchNormalizer` was registered to feed them. */
|
|
25
|
+
readonly MISSING_MATCH_NORMALIZER: 3412;
|
|
26
|
+
/** No registered {@link BracketLayout} matches the source's tournament `mode`. */
|
|
27
|
+
readonly LAYOUT_NOT_REGISTERED: 3413;
|
|
28
|
+
/** A cell the bracket draws has no card - neither an input, the layout, nor the config names one. */
|
|
29
|
+
readonly CARD_NOT_REGISTERED: 3414;
|
|
30
|
+
/** `createPlaceholderBracketSource` got a `participantCount` that is not a power of two, or too small for its mode. */
|
|
31
|
+
readonly PLACEHOLDER_SHAPE_INVALID: 3415;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The error every `@ethlete/components/bracket` engine function throws for a malformed source. `code` is one of
|
|
35
|
+
* {@link BRACKET_ERROR_CODES}; the message starts with `ET<code>: `.
|
|
36
|
+
*/
|
|
37
|
+
export declare class BracketRuntimeError extends Error {
|
|
38
|
+
readonly code: number;
|
|
39
|
+
constructor(code: number, message: string);
|
|
40
|
+
}
|
|
41
|
+
export type BracketSlotSourceKind = BracketSlotSource['kind'];
|
|
42
|
+
type BracketSlotSourceShared = {
|
|
43
|
+
/** Competition wording for the empty slot. The library never invents one. */
|
|
44
|
+
label?: string | null;
|
|
45
|
+
/** The seeding position this slot is reserved for. Optional - a source may carry no seeding at all. */
|
|
46
|
+
seed?: number | null;
|
|
47
|
+
};
|
|
48
|
+
/** The winner or loser of an earlier match. A `null` role is the winner. */
|
|
49
|
+
export type BracketMatchOutcomeSlotSource = BracketSlotSourceShared & {
|
|
50
|
+
kind: 'match-outcome';
|
|
51
|
+
matchId: string;
|
|
52
|
+
role: 'winner' | 'loser' | null;
|
|
53
|
+
};
|
|
54
|
+
/** A position in a standing, such as "group A, 2nd". */
|
|
55
|
+
export type BracketStandingRankSlotSource = BracketSlotSourceShared & {
|
|
56
|
+
kind: 'standing-rank';
|
|
57
|
+
standingId: string;
|
|
58
|
+
rank: number;
|
|
59
|
+
/** What {@link standingId} is called, for a slot that has to be worded without a lookup. */
|
|
60
|
+
standingName?: string | null;
|
|
61
|
+
};
|
|
62
|
+
export type BracketSeedSlotSource = BracketSlotSourceShared & {
|
|
63
|
+
kind: 'seed';
|
|
64
|
+
};
|
|
65
|
+
export type BracketSwissBucketSlotSource = BracketSlotSourceShared & {
|
|
66
|
+
kind: 'swiss-bucket';
|
|
67
|
+
};
|
|
68
|
+
export type BracketByeSlotSource = BracketSlotSourceShared & {
|
|
69
|
+
kind: 'bye';
|
|
70
|
+
};
|
|
71
|
+
export type BracketExternalSlotSource = BracketSlotSourceShared & {
|
|
72
|
+
kind: 'external';
|
|
73
|
+
};
|
|
74
|
+
/** A slot whose provenance the data does not describe. It keeps its `label` and links no feeder. */
|
|
75
|
+
export type BracketUnknownSlotSource = BracketSlotSourceShared & {
|
|
76
|
+
kind: 'unknown';
|
|
77
|
+
};
|
|
78
|
+
/** Where the participant of a match side comes from, discriminated by `kind`. Build one with {@link bracketSlot}. */
|
|
79
|
+
export type BracketSlotSource = BracketMatchOutcomeSlotSource | BracketStandingRankSlotSource | BracketSeedSlotSource | BracketSwissBucketSlotSource | BracketByeSlotSource | BracketExternalSlotSource | BracketUnknownSlotSource;
|
|
80
|
+
export type BracketMatchSlot = {
|
|
81
|
+
participantId: string | null;
|
|
82
|
+
source: BracketSlotSource | null;
|
|
83
|
+
};
|
|
84
|
+
export type BracketMatchSource<TMatchData> = {
|
|
85
|
+
data: TMatchData;
|
|
86
|
+
id: string;
|
|
87
|
+
roundId: string;
|
|
88
|
+
home: string | null;
|
|
89
|
+
away: string | null;
|
|
90
|
+
/** Where the home participant comes from. Omit for legacy sources that do not carry provenance. */
|
|
91
|
+
homeSource?: BracketSlotSource | null;
|
|
92
|
+
/** Where the away participant comes from. Omit for legacy sources that do not carry provenance. */
|
|
93
|
+
awaySource?: BracketSlotSource | null;
|
|
94
|
+
winner: MatchParticipantSide | null;
|
|
95
|
+
status: BracketMatchStatus;
|
|
96
|
+
};
|
|
97
|
+
export type BracketDataSource<TRoundData, TMatchData> = {
|
|
98
|
+
rounds: BracketRoundSource<TRoundData>[];
|
|
99
|
+
matches: BracketMatchSource<TMatchData>[];
|
|
100
|
+
mode: TournamentMode;
|
|
101
|
+
};
|
|
102
|
+
export type BracketRoundSource<TRoundData> = {
|
|
103
|
+
type: BracketRoundType;
|
|
104
|
+
id: string;
|
|
105
|
+
data: TRoundData;
|
|
106
|
+
name: string;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Constructors for every {@link BracketSlotSource} kind, each taking an optional competition `label`.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* homeSource: bracketSlot.matchOutcome('semi-final-1', 'winner'),
|
|
113
|
+
* awaySource: bracketSlot.standingRank('group-a', 2, 'Group A'),
|
|
114
|
+
*/
|
|
115
|
+
export declare const bracketSlot: {
|
|
116
|
+
readonly matchOutcome: (matchId: string, role: "winner" | "loser" | null, label?: string | null) => BracketMatchOutcomeSlotSource;
|
|
117
|
+
readonly standingRank: (standingId: string, rank: number, standingName?: string | null, label?: string | null) => BracketStandingRankSlotSource;
|
|
118
|
+
readonly seed: (seed: number, label?: string | null) => BracketSeedSlotSource;
|
|
119
|
+
readonly swissBucket: (label?: string | null) => BracketSwissBucketSlotSource;
|
|
120
|
+
readonly bye: (label?: string | null) => BracketByeSlotSource;
|
|
121
|
+
readonly external: (label: string) => BracketExternalSlotSource;
|
|
122
|
+
readonly unknown: (label?: string | null) => BracketUnknownSlotSource;
|
|
123
|
+
};
|
|
124
|
+
export declare class BracketMap<TKey, TValue> extends Map<TKey, TValue> {
|
|
125
|
+
constructor();
|
|
126
|
+
getOrThrow(key: TKey): TValue;
|
|
127
|
+
first(): TValue | undefined;
|
|
128
|
+
last(): TValue | undefined;
|
|
129
|
+
}
|
|
130
|
+
export declare const BRACKET_DATA_LAYOUT: {
|
|
131
|
+
readonly LEFT_TO_RIGHT: "left-to-right";
|
|
132
|
+
/**
|
|
133
|
+
* Folded in half: each round up to the first one too small to halve is drawn twice, once on each
|
|
134
|
+
* side, converging on that round and the ones after it. Halves the height and roughly doubles the
|
|
135
|
+
* width, which is what a poster or a broadcast graphic wants.
|
|
136
|
+
*
|
|
137
|
+
* Carried by the mirrored layout factories - a layout that has no fold to make (swiss) simply has no
|
|
138
|
+
* mirrored variant.
|
|
139
|
+
*/
|
|
140
|
+
readonly MIRRORED: "mirrored";
|
|
141
|
+
};
|
|
142
|
+
export type BracketDataLayout = (typeof BRACKET_DATA_LAYOUT)[keyof typeof BRACKET_DATA_LAYOUT];
|
|
143
|
+
export type MatchParticipantId = string & {
|
|
144
|
+
_brand: 'MatchParticipantId';
|
|
145
|
+
};
|
|
146
|
+
export type MatchParticipantShortId = string & {
|
|
147
|
+
_brand: 'MatchParticipantShortId';
|
|
148
|
+
};
|
|
149
|
+
export type BracketParticipantBase = {
|
|
150
|
+
id: MatchParticipantId;
|
|
151
|
+
shortId: MatchParticipantShortId;
|
|
152
|
+
};
|
|
153
|
+
export type BracketParticipantWithRelationsBase = BracketParticipantBase & {
|
|
154
|
+
matchIds: BracketMatchId[];
|
|
155
|
+
};
|
|
156
|
+
export declare const createParticipantsMapBase: <TRoundData, TMatchData>(source: BracketDataSource<TRoundData, TMatchData>) => BracketMap<MatchParticipantId, BracketParticipantWithRelationsBase>;
|
|
157
|
+
export type BracketRoundId = string & {
|
|
158
|
+
_brand: 'BracketRoundId';
|
|
159
|
+
};
|
|
160
|
+
export type BracketRoundShortId = string & {
|
|
161
|
+
_brand: 'BracketRoundShortId';
|
|
162
|
+
};
|
|
163
|
+
export type BracketRoundPosition = number & {
|
|
164
|
+
_brand: 'BracketRoundPosition';
|
|
165
|
+
};
|
|
166
|
+
export type BracketRoundMirrorType = (typeof BRACKET_ROUND_MIRROR_TYPE)[keyof typeof BRACKET_ROUND_MIRROR_TYPE];
|
|
167
|
+
export declare const BRACKET_ROUND_MIRROR_TYPE: {
|
|
168
|
+
readonly LEFT: "left";
|
|
169
|
+
readonly RIGHT: "right";
|
|
170
|
+
};
|
|
171
|
+
export declare const COMMON_BRACKET_ROUND_TYPE: {
|
|
172
|
+
readonly THIRD_PLACE: "third-place";
|
|
173
|
+
readonly FINAL: "final";
|
|
174
|
+
};
|
|
175
|
+
export declare const SINGLE_ELIMINATION_BRACKET_ROUND_TYPE: {
|
|
176
|
+
readonly SINGLE_ELIMINATION_BRACKET: "single-elimination-bracket";
|
|
177
|
+
};
|
|
178
|
+
export declare const DOUBLE_ELIMINATION_BRACKET_ROUND_TYPE: {
|
|
179
|
+
readonly UPPER_BRACKET: "upper-bracket";
|
|
180
|
+
readonly LOWER_BRACKET: "lower-bracket";
|
|
181
|
+
readonly REVERSE_FINAL: "reverse-final";
|
|
182
|
+
};
|
|
183
|
+
export declare const SWISS_BRACKET_ROUND_TYPE: {
|
|
184
|
+
readonly SWISS: "swiss";
|
|
185
|
+
};
|
|
186
|
+
export declare const GROUP_BRACKET_ROUND_TYPE: {
|
|
187
|
+
readonly GROUP: "group";
|
|
188
|
+
};
|
|
189
|
+
export type CommonBracketRoundType = (typeof COMMON_BRACKET_ROUND_TYPE)[keyof typeof COMMON_BRACKET_ROUND_TYPE];
|
|
190
|
+
export type SingleEliminationBracketRoundType = CommonBracketRoundType | (typeof SINGLE_ELIMINATION_BRACKET_ROUND_TYPE)[keyof typeof SINGLE_ELIMINATION_BRACKET_ROUND_TYPE];
|
|
191
|
+
export type DoubleEliminationBracketRoundType = CommonBracketRoundType | (typeof DOUBLE_ELIMINATION_BRACKET_ROUND_TYPE)[keyof typeof DOUBLE_ELIMINATION_BRACKET_ROUND_TYPE];
|
|
192
|
+
export type SwissBracketRoundType = (typeof SWISS_BRACKET_ROUND_TYPE)[keyof typeof SWISS_BRACKET_ROUND_TYPE];
|
|
193
|
+
export type GroupBracketRoundType = (typeof GROUP_BRACKET_ROUND_TYPE)[keyof typeof GROUP_BRACKET_ROUND_TYPE];
|
|
194
|
+
export type BracketRoundType = SingleEliminationBracketRoundType | DoubleEliminationBracketRoundType | SwissBracketRoundType | GroupBracketRoundType;
|
|
195
|
+
export declare const TERMINAL_ROUND_SORT_PRIORITY: Partial<Record<string, number>>;
|
|
196
|
+
export type BracketRoundBase<TRoundData> = {
|
|
197
|
+
/**
|
|
198
|
+
* How deep this round sits in its own bracket - 0 for the opening round, counted separately for the
|
|
199
|
+
* upper and lower halves of a double elimination.
|
|
200
|
+
*
|
|
201
|
+
* **Both halves of a mirrored round share it.** That is what makes it the fold's coordinate: a
|
|
202
|
+
* mirrored layout draws each depth twice, once on each side, so the depth is the only thing that says
|
|
203
|
+
* which right-hand column belongs opposite which left-hand one.
|
|
204
|
+
*/
|
|
205
|
+
logicalIndex: number;
|
|
206
|
+
type: BracketRoundType;
|
|
207
|
+
id: BracketRoundId;
|
|
208
|
+
shortId: BracketRoundShortId;
|
|
209
|
+
data: TRoundData;
|
|
210
|
+
position: BracketRoundPosition;
|
|
211
|
+
name: string;
|
|
212
|
+
matchCount: number;
|
|
213
|
+
mirrorRoundType: BracketRoundMirrorType | null;
|
|
214
|
+
isFirstRound: boolean;
|
|
215
|
+
isLastRound: boolean;
|
|
216
|
+
isFirstOfType: boolean;
|
|
217
|
+
isLastOfType: boolean;
|
|
218
|
+
};
|
|
219
|
+
export type BracketRoundWithRelationsBase<TRoundData> = BracketRoundBase<TRoundData> & {
|
|
220
|
+
matchIds: BracketMatchId[];
|
|
221
|
+
};
|
|
222
|
+
export declare const createRoundsMapBase: <TRoundData, TMatchData>(source: BracketDataSource<TRoundData, TMatchData>, options: GenerateBracketDataOptions) => BracketMap<BracketRoundId, BracketRoundWithRelationsBase<TRoundData>>;
|
|
223
|
+
export type ParticipantMatchResult = 'win' | 'loss' | 'tie';
|
|
224
|
+
export type MatchParticipantSide = 'home' | 'away';
|
|
225
|
+
export type BracketMatchParticipantBase = BracketParticipantBase & {
|
|
226
|
+
result: ParticipantMatchResult | null;
|
|
227
|
+
isEliminated: boolean;
|
|
228
|
+
isEliminationMatch: boolean;
|
|
229
|
+
tieCount: number;
|
|
230
|
+
winCount: number;
|
|
231
|
+
lossCount: number;
|
|
232
|
+
side: MatchParticipantSide;
|
|
233
|
+
};
|
|
234
|
+
export type BracketMatchParticipantWithRelationsBase = BracketMatchParticipantBase & BracketParticipantWithRelationsBase;
|
|
235
|
+
export declare const createNewMatchParticipantBase: <TRoundData, TMatchData>(source: BracketDataSource<TRoundData, TMatchData>, participantId: MatchParticipantId | null, match: BracketMatchSource<TMatchData>, rounds: BracketMap<BracketRoundId, BracketRoundWithRelationsBase<TRoundData>>, matchRoundId: BracketRoundId, participants: BracketMap<MatchParticipantId, BracketParticipantWithRelationsBase>, sourceMatchesById?: ReadonlyMap<string, BracketMatchSource<TMatchData>>) => BracketMatchParticipantWithRelationsBase | null;
|
|
236
|
+
export type BracketMatchId = string & {
|
|
237
|
+
_brand: 'BracketMatchId';
|
|
238
|
+
};
|
|
239
|
+
export type BracketMatchShortId = string & {
|
|
240
|
+
_brand: 'BracketMatchShortId';
|
|
241
|
+
};
|
|
242
|
+
export type BracketMatchPosition = number & {
|
|
243
|
+
_brand: 'BracketMatchPosition';
|
|
244
|
+
};
|
|
245
|
+
export type BracketMatchStatus = 'completed' | 'pending';
|
|
246
|
+
export type BracketMatchBase<TMatchData> = {
|
|
247
|
+
data: TMatchData;
|
|
248
|
+
indexInRound: number;
|
|
249
|
+
id: BracketMatchId;
|
|
250
|
+
shortId: BracketMatchShortId;
|
|
251
|
+
position: BracketMatchPosition;
|
|
252
|
+
winnerSide: MatchParticipantSide | null;
|
|
253
|
+
status: BracketMatchStatus;
|
|
254
|
+
homeSource: BracketSlotSource | null;
|
|
255
|
+
awaySource: BracketSlotSource | null;
|
|
256
|
+
};
|
|
257
|
+
export type BracketMatchWithRelationsBase<TMatchData> = BracketMatchBase<TMatchData> & {
|
|
258
|
+
roundId: BracketRoundId;
|
|
259
|
+
home: BracketMatchParticipantWithRelationsBase | null;
|
|
260
|
+
away: BracketMatchParticipantWithRelationsBase | null;
|
|
261
|
+
winner: BracketMatchParticipantWithRelationsBase | null;
|
|
262
|
+
};
|
|
263
|
+
export declare const createMatchesMapBase: <TRoundData, TMatchData>(source: BracketDataSource<TRoundData, TMatchData>, rounds: BracketMap<BracketRoundId, BracketRoundWithRelationsBase<TRoundData>>, participants: BracketMap<MatchParticipantId, BracketParticipantWithRelationsBase>) => BracketMap<BracketMatchId, BracketMatchWithRelationsBase<TMatchData>>;
|
|
264
|
+
export declare const TOURNAMENT_MODE: {
|
|
265
|
+
readonly SINGLE_ELIMINATION: "single-elimination";
|
|
266
|
+
readonly DOUBLE_ELIMINATION: "double-elimination";
|
|
267
|
+
readonly SWISS_WITH_ELIMINATION: "swiss-with-elimination";
|
|
268
|
+
};
|
|
269
|
+
export type TournamentMode = (typeof TOURNAMENT_MODE)[keyof typeof TOURNAMENT_MODE];
|
|
270
|
+
/** Wins that advance a participant out of a swiss stage. */
|
|
271
|
+
export declare const SWISS_ADVANCE_WINS = 3;
|
|
272
|
+
/** Losses that eliminate a participant from a swiss stage. */
|
|
273
|
+
export declare const SWISS_ELIMINATE_LOSSES = 3;
|
|
274
|
+
export type BracketBase<TRoundData, TMatchData> = {
|
|
275
|
+
rounds: BracketMap<BracketRoundId, BracketRoundWithRelationsBase<TRoundData>>;
|
|
276
|
+
matches: BracketMap<BracketMatchId, BracketMatchWithRelationsBase<TMatchData>>;
|
|
277
|
+
participants: BracketMap<MatchParticipantId, BracketParticipantWithRelationsBase>;
|
|
278
|
+
mode: TournamentMode;
|
|
279
|
+
};
|
|
280
|
+
export type GenerateBracketDataOptions = {
|
|
281
|
+
layout: BracketDataLayout;
|
|
282
|
+
};
|
|
283
|
+
/**
|
|
284
|
+
* Something in a source `createBracket` accepted but probably did not mean: a feeder id that names no
|
|
285
|
+
* match, or a match the declared graph links to nothing because it carries no provenance.
|
|
286
|
+
*/
|
|
287
|
+
export type BracketWarning = {
|
|
288
|
+
type: 'unknown-feeder';
|
|
289
|
+
matchId: string;
|
|
290
|
+
feederId: string;
|
|
291
|
+
message: string;
|
|
292
|
+
} | {
|
|
293
|
+
type: 'unlinked-match';
|
|
294
|
+
matchId: string;
|
|
295
|
+
message: string;
|
|
296
|
+
};
|
|
297
|
+
export type CreateBracketOptions<TMatchData> = GenerateBracketDataOptions & {
|
|
298
|
+
/** The matches feeding this one, upper arm first. Slot provenance is used when omitted. */
|
|
299
|
+
previousMatchIds?: (match: BracketMatchSource<TMatchData>) => string[];
|
|
300
|
+
/** Called once per {@link BracketWarning} while the bracket is linked from a declared graph. */
|
|
301
|
+
onWarning?: (warning: BracketWarning) => void;
|
|
302
|
+
};
|
|
303
|
+
export declare const createBracketBase: <TRoundData, TMatchData>(source: BracketDataSource<TRoundData, TMatchData>, options: GenerateBracketDataOptions) => BracketBase<TRoundData, TMatchData>;
|
|
304
|
+
export type BracketPosition = {
|
|
305
|
+
inline: {
|
|
306
|
+
start: number;
|
|
307
|
+
end: number;
|
|
308
|
+
center: number;
|
|
309
|
+
};
|
|
310
|
+
block: {
|
|
311
|
+
start: number;
|
|
312
|
+
end: number;
|
|
313
|
+
center: number;
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
export type BracketRoundRelationNothingToOne<TRoundData, TMatchData> = {
|
|
317
|
+
type: 'nothing-to-one';
|
|
318
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
319
|
+
nextRound: BracketRound<TRoundData, TMatchData>;
|
|
320
|
+
nextRoundMatchFactor: number;
|
|
321
|
+
};
|
|
322
|
+
export type BracketRoundRelationOneToNothing<TRoundData, TMatchData> = {
|
|
323
|
+
type: 'one-to-nothing';
|
|
324
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
325
|
+
previousRound: BracketRound<TRoundData, TMatchData>;
|
|
326
|
+
previousRoundMatchFactor: number;
|
|
327
|
+
rootRoundMatchFactor: number;
|
|
328
|
+
};
|
|
329
|
+
export type BracketRoundRelationOneToOne<TRoundData, TMatchData> = {
|
|
330
|
+
type: 'one-to-one';
|
|
331
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
332
|
+
previousRound: BracketRound<TRoundData, TMatchData>;
|
|
333
|
+
nextRound: BracketRound<TRoundData, TMatchData>;
|
|
334
|
+
nextRoundMatchFactor: number;
|
|
335
|
+
previousRoundMatchFactor: number;
|
|
336
|
+
rootRoundMatchFactor: number;
|
|
337
|
+
};
|
|
338
|
+
export type BracketRoundRelationTwoToOne<TRoundData, TMatchData> = {
|
|
339
|
+
type: 'two-to-one';
|
|
340
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
341
|
+
previousUpperRound: BracketRound<TRoundData, TMatchData>;
|
|
342
|
+
previousLowerRound: BracketRound<TRoundData, TMatchData>;
|
|
343
|
+
nextRound: BracketRound<TRoundData, TMatchData>;
|
|
344
|
+
nextRoundMatchFactor: number;
|
|
345
|
+
previousUpperRoundMatchFactor: number;
|
|
346
|
+
previousLowerRoundMatchFactor: number;
|
|
347
|
+
upperRootRoundMatchFactor: number;
|
|
348
|
+
lowerRootRoundMatchFactor: number;
|
|
349
|
+
};
|
|
350
|
+
export type BracketRoundRelationTwoToNothing<TRoundData, TMatchData> = {
|
|
351
|
+
type: 'two-to-nothing';
|
|
352
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
353
|
+
previousUpperRound: BracketRound<TRoundData, TMatchData>;
|
|
354
|
+
previousLowerRound: BracketRound<TRoundData, TMatchData>;
|
|
355
|
+
previousUpperRoundMatchFactor: number;
|
|
356
|
+
previousLowerRoundMatchFactor: number;
|
|
357
|
+
upperRootRoundMatchFactor: number;
|
|
358
|
+
lowerRootRoundMatchFactor: number;
|
|
359
|
+
};
|
|
360
|
+
export type BracketRoundRelationNone<TRoundData, TMatchData> = {
|
|
361
|
+
type: 'none';
|
|
362
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
363
|
+
};
|
|
364
|
+
export type BracketRoundRelation<TRoundData, TMatchData> = BracketRoundRelationNone<TRoundData, TMatchData> | BracketRoundRelationNothingToOne<TRoundData, TMatchData> | BracketRoundRelationOneToNothing<TRoundData, TMatchData> | BracketRoundRelationOneToOne<TRoundData, TMatchData> | BracketRoundRelationTwoToOne<TRoundData, TMatchData> | BracketRoundRelationTwoToNothing<TRoundData, TMatchData>;
|
|
365
|
+
export declare const generateRoundRelationsNew: <TRoundData, TMatchData>(bracketData: Bracket<TRoundData, TMatchData>) => BracketRoundRelation<TRoundData, TMatchData>[];
|
|
366
|
+
export type BracketMatchFactor = number;
|
|
367
|
+
export type BracketMatchRelationOneToOne<TRoundData, TMatchData> = {
|
|
368
|
+
type: 'one-to-one';
|
|
369
|
+
currentMatch: BracketMatch<TRoundData, TMatchData>;
|
|
370
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
371
|
+
previousMatch: BracketMatch<TRoundData, TMatchData>;
|
|
372
|
+
previousRound: BracketRound<TRoundData, TMatchData>;
|
|
373
|
+
nextMatch: BracketMatch<TRoundData, TMatchData>;
|
|
374
|
+
nextRound: BracketRound<TRoundData, TMatchData>;
|
|
375
|
+
};
|
|
376
|
+
export type BracketMatchRelationNothingToOne<TRoundData, TMatchData> = {
|
|
377
|
+
type: 'nothing-to-one';
|
|
378
|
+
currentMatch: BracketMatch<TRoundData, TMatchData>;
|
|
379
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
380
|
+
nextMatch: BracketMatch<TRoundData, TMatchData>;
|
|
381
|
+
nextRound: BracketRound<TRoundData, TMatchData>;
|
|
382
|
+
};
|
|
383
|
+
export type BracketMatchRelationOneToNothing<TRoundData, TMatchData> = {
|
|
384
|
+
type: 'one-to-nothing';
|
|
385
|
+
currentMatch: BracketMatch<TRoundData, TMatchData>;
|
|
386
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
387
|
+
previousMatch: BracketMatch<TRoundData, TMatchData>;
|
|
388
|
+
previousRound: BracketRound<TRoundData, TMatchData>;
|
|
389
|
+
};
|
|
390
|
+
export type BracketMatchRelationTwoToOne<TRoundData, TMatchData> = {
|
|
391
|
+
type: 'two-to-one';
|
|
392
|
+
currentMatch: BracketMatch<TRoundData, TMatchData>;
|
|
393
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
394
|
+
previousUpperMatch: BracketMatch<TRoundData, TMatchData>;
|
|
395
|
+
previousUpperRound: BracketRound<TRoundData, TMatchData>;
|
|
396
|
+
previousLowerMatch: BracketMatch<TRoundData, TMatchData>;
|
|
397
|
+
previousLowerRound: BracketRound<TRoundData, TMatchData>;
|
|
398
|
+
nextMatch: BracketMatch<TRoundData, TMatchData>;
|
|
399
|
+
nextRound: BracketRound<TRoundData, TMatchData>;
|
|
400
|
+
};
|
|
401
|
+
export type BracketMatchRelationTwoToNothing<TRoundData, TMatchData> = {
|
|
402
|
+
type: 'two-to-nothing';
|
|
403
|
+
currentMatch: BracketMatch<TRoundData, TMatchData>;
|
|
404
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
405
|
+
previousUpperMatch: BracketMatch<TRoundData, TMatchData>;
|
|
406
|
+
previousUpperRound: BracketRound<TRoundData, TMatchData>;
|
|
407
|
+
previousLowerMatch: BracketMatch<TRoundData, TMatchData>;
|
|
408
|
+
previousLowerRound: BracketRound<TRoundData, TMatchData>;
|
|
409
|
+
};
|
|
410
|
+
export type BracketMatchRelationNone<TRoundData, TMatchData> = {
|
|
411
|
+
type: 'none';
|
|
412
|
+
currentMatch: BracketMatch<TRoundData, TMatchData>;
|
|
413
|
+
currentRound: BracketRound<TRoundData, TMatchData>;
|
|
414
|
+
};
|
|
415
|
+
export type BracketMatchRelation<TRoundData, TMatchData> = BracketMatchRelationNone<TRoundData, TMatchData> | BracketMatchRelationOneToOne<TRoundData, TMatchData> | BracketMatchRelationTwoToOne<TRoundData, TMatchData> | BracketMatchRelationNothingToOne<TRoundData, TMatchData> | BracketMatchRelationOneToNothing<TRoundData, TMatchData> | BracketMatchRelationTwoToNothing<TRoundData, TMatchData>;
|
|
416
|
+
export type MatchPositionMaps<TRoundData, TMatchData> = Map<BracketRoundId, Map<BracketMatchPosition, BracketMatch<TRoundData, TMatchData>>>;
|
|
417
|
+
export declare const generateMatchPosition: (match: BracketMatch<unknown, unknown>, factor: BracketMatchFactor) => BracketMatchPosition;
|
|
418
|
+
export declare const generateMatchRelationPositions: <TRoundData, TMatchData>(relation: BracketRoundRelation<TRoundData, TMatchData>, match: BracketMatch<TRoundData, TMatchData>) => {
|
|
419
|
+
nextRoundMatchPosition: BracketMatchPosition;
|
|
420
|
+
previousUpperRoundMatchPosition: BracketMatchPosition;
|
|
421
|
+
previousLowerRoundMatchPosition: BracketMatchPosition;
|
|
422
|
+
} | null;
|
|
423
|
+
export declare const generateMatchRelationsNew: <TRoundData, TMatchData>(bracketData: Bracket<TRoundData, TMatchData>, options?: {
|
|
424
|
+
source?: {
|
|
425
|
+
matches: BracketMatchSource<TMatchData>[];
|
|
426
|
+
};
|
|
427
|
+
previousMatchIds?: (match: BracketMatchSource<TMatchData>) => string[];
|
|
428
|
+
onWarning?: (warning: BracketWarning) => void;
|
|
429
|
+
}) => BracketMatchRelation<TRoundData, TMatchData>[];
|
|
430
|
+
export type Bracket<TRoundData, TMatchData> = {
|
|
431
|
+
rounds: BracketMap<BracketRoundId, BracketRound<TRoundData, TMatchData>>;
|
|
432
|
+
roundsByType: BracketMap<BracketRoundType, BracketMap<BracketRoundId, BracketRound<TRoundData, TMatchData>>>;
|
|
433
|
+
matches: BracketMap<BracketMatchId, BracketMatch<TRoundData, TMatchData>>;
|
|
434
|
+
participants: BracketMap<MatchParticipantId, BracketParticipant<TRoundData, TMatchData>>;
|
|
435
|
+
mode: TournamentMode;
|
|
436
|
+
};
|
|
437
|
+
export type BracketRound<TRoundData, TMatchData> = BracketRoundBase<TRoundData> & {
|
|
438
|
+
matches: BracketMap<BracketMatchId, BracketMatch<TRoundData, TMatchData>>;
|
|
439
|
+
relation: BracketRoundRelation<TRoundData, TMatchData>;
|
|
440
|
+
};
|
|
441
|
+
export type BracketMatch<TRoundData, TMatchData> = BracketMatchBase<TMatchData> & {
|
|
442
|
+
round: BracketRound<TRoundData, TMatchData>;
|
|
443
|
+
home: BracketMatchParticipant<TRoundData, TMatchData> | null;
|
|
444
|
+
away: BracketMatchParticipant<TRoundData, TMatchData> | null;
|
|
445
|
+
winner: BracketMatchParticipant<TRoundData, TMatchData> | null;
|
|
446
|
+
relation: BracketMatchRelation<TRoundData, TMatchData>;
|
|
447
|
+
};
|
|
448
|
+
export type BracketParticipantMatch<TRoundData, TMatchData> = BracketMatch<TRoundData, TMatchData> & {
|
|
449
|
+
me: BracketMatchParticipant<TRoundData, TMatchData>;
|
|
450
|
+
opponent: BracketMatchParticipant<TRoundData, TMatchData> | null;
|
|
451
|
+
};
|
|
452
|
+
export type BracketParticipant<TRoundData, TMatchData> = BracketParticipantBase & {
|
|
453
|
+
matches: BracketMap<BracketMatchId, BracketParticipantMatch<TRoundData, TMatchData>>;
|
|
454
|
+
};
|
|
455
|
+
export type BracketMatchParticipant<TRoundData, TMatchData> = BracketMatchParticipantBase & {
|
|
456
|
+
matches: BracketMap<BracketMatchId, BracketMatch<TRoundData, TMatchData>>;
|
|
457
|
+
};
|
|
458
|
+
export declare const createBracket: <TRoundData, TMatchData>(source: BracketDataSource<TRoundData, TMatchData>, options: CreateBracketOptions<TMatchData>) => Bracket<TRoundData, TMatchData>;
|
|
459
|
+
export type BracketRoundSwissGroupId = string & {
|
|
460
|
+
_brand: 'BracketRoundSwissGroupId';
|
|
461
|
+
};
|
|
462
|
+
export type BracketRoundSwissGroup<TRoundData, TMatchData> = {
|
|
463
|
+
id: BracketRoundSwissGroupId;
|
|
464
|
+
name: string;
|
|
465
|
+
matches: BracketMap<BracketMatchId, BracketMatch<TRoundData, TMatchData>>;
|
|
466
|
+
allowedMatchCount: number;
|
|
467
|
+
};
|
|
468
|
+
export type BracketRoundSwissGroupMap<TRoundData, TMatchData> = Map<BracketRoundSwissGroupId, BracketRoundSwissGroup<TRoundData, TMatchData>>;
|
|
469
|
+
export type BracketRoundSwissData<TRoundData, TMatchData> = {
|
|
470
|
+
groups: BracketRoundSwissGroupMap<TRoundData, TMatchData>;
|
|
471
|
+
};
|
|
472
|
+
export type BracketRoundMapWithSwissData<TRoundData, TMatchData> = Map<BracketRoundId, BracketRoundSwissData<TRoundData, TMatchData>>;
|
|
473
|
+
export declare const BRACKET_SWISS_GROUP_COLOR_TYPE: {
|
|
474
|
+
/** The starting group (0-0) */
|
|
475
|
+
readonly NEUTRAL: "neutral";
|
|
476
|
+
/** The group has more wins than losses */
|
|
477
|
+
readonly POSITIVE: "positive";
|
|
478
|
+
/** The group is one loss away from elimination */
|
|
479
|
+
readonly NEGATIVE: "negative";
|
|
480
|
+
/** Everything in between */
|
|
481
|
+
readonly WARNING: "warning";
|
|
482
|
+
};
|
|
483
|
+
export type BracketSwissGroupColorType = (typeof BRACKET_SWISS_GROUP_COLOR_TYPE)[keyof typeof BRACKET_SWISS_GROUP_COLOR_TYPE];
|
|
484
|
+
/**
|
|
485
|
+
* Colors for the swiss group borders and connection lines, keyed by the group color type
|
|
486
|
+
* (see {@link getSwissGroupColorType}). Connection lines are drawn in the neutral color and fade
|
|
487
|
+
* into the target group color on the last portion before touching its border.
|
|
488
|
+
* Any CSS color value is allowed. Missing entries fall back to the connector/border color
|
|
489
|
+
* (the `--et-bracket-line-color` / `--et-bracket-swiss-group-border-color` custom properties,
|
|
490
|
+
* which default to `--et-surface-border`).
|
|
491
|
+
*/
|
|
492
|
+
export type BracketSwissColors = Partial<Record<BracketSwissGroupColorType, string>>;
|
|
493
|
+
export declare const getSwissGroupColorType: (wins: number, losses: number) => BracketSwissGroupColorType;
|
|
494
|
+
export declare const getAvailableSwissGroupsForRound: (roundNumber: number, totalMatchesInRound: number) => {
|
|
495
|
+
id: BracketRoundSwissGroupId;
|
|
496
|
+
name: string;
|
|
497
|
+
matchesInGroup: number;
|
|
498
|
+
}[];
|
|
499
|
+
export declare const generateBracketRoundSwissGroupMaps: <TRoundData, TMatchData>(bracketData: Bracket<TRoundData, TMatchData>) => BracketRoundMapWithSwissData<TRoundData, TMatchData> | null;
|
|
500
|
+
/** One connector between two cards, ready for an SVG `<path>`. */
|
|
501
|
+
export type BracketEdge = {
|
|
502
|
+
/**
|
|
503
|
+
* Stable while only the geometry changes, so a template's `@for` moves the same `<path>` instead of
|
|
504
|
+
* replacing it - which is what lets the `d` transition run. Unique within one drawing.
|
|
505
|
+
*/
|
|
506
|
+
id: string;
|
|
507
|
+
/** The `d` attribute, which is what draws the line. */
|
|
508
|
+
d: string;
|
|
509
|
+
/** The same path as a value for the CSS `d` property - the one a transition can animate. */
|
|
510
|
+
cssPath: string;
|
|
511
|
+
/** The participant short ids the journey highlight matches on, space separated. */
|
|
512
|
+
cssClass: string;
|
|
513
|
+
strokeWidth: number;
|
|
514
|
+
dashArray: number;
|
|
515
|
+
dashOffset: number;
|
|
516
|
+
/** A color, or `url(#id)` naming one of the drawing's {@link BracketGradient}s. */
|
|
517
|
+
stroke: string;
|
|
518
|
+
};
|
|
519
|
+
/** A box drawn behind the connectors - a swiss layout's group border. */
|
|
520
|
+
export type BracketRect = {
|
|
521
|
+
id: string;
|
|
522
|
+
x: number;
|
|
523
|
+
y: number;
|
|
524
|
+
width: number;
|
|
525
|
+
height: number;
|
|
526
|
+
/** The corner radius, as the `rx` attribute. */
|
|
527
|
+
radius: number;
|
|
528
|
+
cssClass: string;
|
|
529
|
+
stroke: string;
|
|
530
|
+
strokeWidth: number;
|
|
531
|
+
/** The record tone of the swiss group the box wraps - see {@link getSwissGroupColorType}. */
|
|
532
|
+
tone?: BracketSwissGroupColorType;
|
|
533
|
+
};
|
|
534
|
+
export type BracketGradientStop = {
|
|
535
|
+
/** A CSS/SVG offset, e.g. `'50%'`. */
|
|
536
|
+
offset: string;
|
|
537
|
+
color: string;
|
|
538
|
+
};
|
|
539
|
+
/** A horizontal gradient in user space, which an edge's `stroke` names by `url(#id)`. */
|
|
540
|
+
export type BracketGradient = {
|
|
541
|
+
id: string;
|
|
542
|
+
fromX: number;
|
|
543
|
+
toX: number;
|
|
544
|
+
stops: BracketGradientStop[];
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* Everything a layout draws between the cells, as data rather than as SVG markup: the host renders it
|
|
548
|
+
* with `@for`, so nothing has to be trusted past the sanitizer and a connector can animate.
|
|
549
|
+
*/
|
|
550
|
+
export type BracketDrawing = {
|
|
551
|
+
edges: BracketEdge[];
|
|
552
|
+
rects: BracketRect[];
|
|
553
|
+
gradients: BracketGradient[];
|
|
554
|
+
};
|
|
555
|
+
export type PathOptions = {
|
|
556
|
+
/** Unique within one drawing - see {@link BracketEdge.id}. */
|
|
557
|
+
id: string;
|
|
558
|
+
width: number;
|
|
559
|
+
dashArray: number;
|
|
560
|
+
dashOffset: number;
|
|
561
|
+
className: string;
|
|
562
|
+
stroke?: string;
|
|
563
|
+
};
|
|
564
|
+
export declare const path: (d: string, options: PathOptions) => BracketEdge;
|
|
565
|
+
export type CurveOptions = {
|
|
566
|
+
lineStartingCurveAmount: number;
|
|
567
|
+
lineEndingCurveAmount: number;
|
|
568
|
+
path: PathOptions;
|
|
569
|
+
inverted?: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Where the vertical part of the connector sits, in px from the feeding card. `null` or omitted turns
|
|
572
|
+
* it at the middle of the gap.
|
|
573
|
+
*/
|
|
574
|
+
turnOffset?: number | null;
|
|
575
|
+
};
|
|
576
|
+
export declare const curvePath: (from: BracketPosition, to: BracketPosition, direction: "up" | "down", options: CurveOptions) => import("@ethlete/components/bracket").BracketEdge;
|
|
577
|
+
/** The table position a `standing-rank` slot asks about, and the slot that asks. */
|
|
578
|
+
export type BracketStandingRankPickQuery = {
|
|
579
|
+
standingId: string;
|
|
580
|
+
rank: number;
|
|
581
|
+
match: BracketMatch<unknown, unknown>;
|
|
582
|
+
side: MatchParticipantSide;
|
|
583
|
+
};
|
|
584
|
+
export type BracketPickSet = {
|
|
585
|
+
/** The participant the viewer picked to win a match. */
|
|
586
|
+
matchWinner: (matchId: string) => string | null;
|
|
587
|
+
/** The participant the viewer put on a table position. */
|
|
588
|
+
standingRank: (options: BracketStandingRankPickQuery) => string | null;
|
|
589
|
+
};
|
|
590
|
+
export declare const isBracketSlotPredictable: (source: BracketSlotSource | null) => boolean;
|
|
591
|
+
/** How a resolution weighs a prediction against what is already known. Both parts default to the stricter answer. */
|
|
592
|
+
export type BracketSlotResolutionPolicy = {
|
|
593
|
+
/**
|
|
594
|
+
* Whether the participant really standing on a slot of the given match outranks whatever the picks
|
|
595
|
+
* predict for it. Must answer from the match alone, and answer the same way throughout one
|
|
596
|
+
* resolution: the walk memoizes per slot.
|
|
597
|
+
*
|
|
598
|
+
* `true` answers with the real participant wherever one is known - the pairing a pick was made
|
|
599
|
+
* against, which is what an open round should show. `false`, the default, answers with the
|
|
600
|
+
* prediction even where reality already disagrees, which is what a locked round should show: the
|
|
601
|
+
* record of the guess.
|
|
602
|
+
*/
|
|
603
|
+
realParticipantOutranksPick?: (match: BracketMatch<unknown, unknown>) => boolean;
|
|
604
|
+
/**
|
|
605
|
+
* Whether a predicted winner still counts while one side of the match it was made on is unknown.
|
|
606
|
+
* `false`, the default, drops it until both sides resolve. `true` keeps it until both sides are
|
|
607
|
+
* known and it is neither of them - until then nothing contradicts it.
|
|
608
|
+
*/
|
|
609
|
+
keepPickWhileFeederSideIsOpen?: boolean;
|
|
610
|
+
/**
|
|
611
|
+
* Whether a `match-outcome` or `standing-rank` slot the picks leave empty answers with the
|
|
612
|
+
* participant really standing there. `false`, the default, leaves it empty.
|
|
613
|
+
*/
|
|
614
|
+
fallBackToRealParticipant?: boolean;
|
|
615
|
+
};
|
|
616
|
+
type BracketSlotResolverOptions = BracketSlotResolutionPolicy & {
|
|
617
|
+
bracket: Bracket<unknown, unknown>;
|
|
618
|
+
picks: BracketPickSet;
|
|
619
|
+
/**
|
|
620
|
+
* Earlier stages a `match-outcome` slot of `bracket` may point into. A feeder is looked up in
|
|
621
|
+
* `bracket` first, then in these in order, so match ids must be unique across all of them.
|
|
622
|
+
*/
|
|
623
|
+
linkedBrackets?: readonly Bracket<unknown, unknown>[];
|
|
624
|
+
};
|
|
625
|
+
type ResolveBracketSlotOptions = BracketSlotResolverOptions & {
|
|
626
|
+
matchId: string;
|
|
627
|
+
side: MatchParticipantSide;
|
|
628
|
+
};
|
|
629
|
+
/** Who the viewer's own picks put in a slot, or `null` while their picks do not reach it. */
|
|
630
|
+
export declare const resolveBracketSlot: (options: ResolveBracketSlotOptions) => string | null;
|
|
631
|
+
export type BracketPickMigrationOptions = BracketSlotResolutionPolicy & {
|
|
632
|
+
bracket: Bracket<unknown, unknown>;
|
|
633
|
+
/**
|
|
634
|
+
* Earlier stages a `match-outcome` slot of `bracket` may point into. Their picks are read from
|
|
635
|
+
* {@link pickAsMade} as given, so migrate an earlier stage first and answer with its result.
|
|
636
|
+
*/
|
|
637
|
+
linkedBrackets?: readonly Bracket<unknown, unknown>[];
|
|
638
|
+
/** The participant the viewer picked on a match, on the match they picked it on. */
|
|
639
|
+
pickAsMade: (matchId: string) => string | null;
|
|
640
|
+
/** The participant the viewer put on a table position, for the `standing-rank` slots a round resolves from. */
|
|
641
|
+
standingRank?: (options: BracketStandingRankPickQuery) => string | null;
|
|
642
|
+
/** Matches whose picks the backend already keeps. Their picks neither travel out nor take one in. */
|
|
643
|
+
lockedMatchIds?: ReadonlySet<string>;
|
|
644
|
+
};
|
|
645
|
+
export type BracketPickMigration = {
|
|
646
|
+
/** The pick that counts on a match: the one made on it, or the one that followed its participant here. */
|
|
647
|
+
pickByMatchId: Record<string, string | undefined>;
|
|
648
|
+
/** For a match that took a pick in, the match that pick was made on. */
|
|
649
|
+
movedFromByMatchId: Record<string, string | undefined>;
|
|
650
|
+
/** For a match whose pick nothing in its round can honour, that pick. Such a match holds no selection. */
|
|
651
|
+
strandedByMatchId: Record<string, string | undefined>;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Where every pick stands once each one has followed its participant into whichever match of its own
|
|
655
|
+
* round that participant now plays. A pick nothing in the round can honour comes back stranded.
|
|
656
|
+
*/
|
|
657
|
+
export declare const migrateBracketPicks: (options: BracketPickMigrationOptions) => BracketPickMigration;
|
|
658
|
+
export type BracketStandingRankSide = {
|
|
659
|
+
side: MatchParticipantSide;
|
|
660
|
+
standingId: string;
|
|
661
|
+
rank: number;
|
|
662
|
+
standingName: string | null;
|
|
663
|
+
/** The participant really standing on the side, or `null` while the standing is not decided. */
|
|
664
|
+
participantId: string | null;
|
|
665
|
+
};
|
|
666
|
+
/** The sides of a match whose source is a `standing-rank` slot, home first. Empty for an unknown match. */
|
|
667
|
+
export declare const standingRankSides: (options: {
|
|
668
|
+
bracket: Bracket<unknown, unknown>;
|
|
669
|
+
matchId: string;
|
|
670
|
+
}) => BracketStandingRankSide[];
|
|
671
|
+
/**
|
|
672
|
+
* Runs {@link createBracket} on `source` and returns the `BracketRuntimeError` it would throw, or `null` for a
|
|
673
|
+
* usable source. Any other error is rethrown.
|
|
674
|
+
*/
|
|
675
|
+
export declare const validateBracketSource: <TRoundData, TMatchData>(source: BracketDataSource<TRoundData, TMatchData>, options: CreateBracketOptions<TMatchData>) => BracketRuntimeError | null;
|
|
676
|
+
export declare const BRACKET_SECTION_KEY: {
|
|
677
|
+
readonly UPPER: "upper";
|
|
678
|
+
readonly LOWER: "lower";
|
|
679
|
+
readonly FINALS: "finals";
|
|
680
|
+
};
|
|
681
|
+
export type BracketSectionKey = (typeof BRACKET_SECTION_KEY)[keyof typeof BRACKET_SECTION_KEY];
|
|
682
|
+
/** The English name of each section, for a renderer that brings no labels of its own. */
|
|
683
|
+
export declare const BRACKET_SECTION_DEFAULT_NAMES: Record<BracketSectionKey, string>;
|
|
684
|
+
/**
|
|
685
|
+
* One part of a bracket - double elimination's upper bracket, lower bracket or finals - as a grid builder
|
|
686
|
+
* placed it.
|
|
687
|
+
*/
|
|
688
|
+
export type BracketGridSection<TRoundData = unknown, TMatchData = unknown> = {
|
|
689
|
+
key: BracketSectionKey;
|
|
690
|
+
name: string;
|
|
691
|
+
rounds: BracketRound<TRoundData, TMatchData>[];
|
|
692
|
+
/** The box around the section's round headers and matches, from the top of the grid rows it occupies. */
|
|
693
|
+
dimensions: Dimensions;
|
|
694
|
+
/** The band the grid reserved for the section's title, `sectionTitleHeight` high and `sectionTitleGap` above `dimensions`. */
|
|
695
|
+
titleDimensions: Dimensions;
|
|
696
|
+
};
|
|
697
|
+
/** The section a double elimination round belongs to: the third place playoff counts as one of the finals. */
|
|
698
|
+
export declare const doubleEliminationRoundSection: (round: BracketRound<unknown, unknown>) => BracketSectionKey;
|
|
699
|
+
/**
|
|
700
|
+
* Groups a finalized grid's headers and matches into sections and measures each one, with its title band
|
|
701
|
+
* `titleHeight` px high, `titleGap` px above it. A section starts at its `tops` entry, where the grid builder gives one, so the
|
|
702
|
+
* titles of sections that share a row line up; otherwise at its highest element. Sections come in
|
|
703
|
+
* {@link BRACKET_SECTION_KEY} order; an empty one is left out.
|
|
704
|
+
*/
|
|
705
|
+
export declare const createBracketGridSections: <TRoundData, TMatchData>(config: {
|
|
706
|
+
columns: FinalizedBracketColumn<TRoundData, TMatchData>[];
|
|
707
|
+
sectionOf: (round: BracketRound<TRoundData, TMatchData>) => BracketSectionKey;
|
|
708
|
+
titleHeight: number;
|
|
709
|
+
titleGap?: number;
|
|
710
|
+
tops?: Partial<Record<BracketSectionKey, number>>;
|
|
711
|
+
}) => BracketGridSection<TRoundData, TMatchData>[];
|
|
712
|
+
export type BracketComponentType<TInputs> = new (...args: never[]) => TInputs;
|
|
713
|
+
export type BracketComponentInput<TValue> = () => TValue;
|
|
714
|
+
export type Dimensions = {
|
|
715
|
+
width: number;
|
|
716
|
+
height: number;
|
|
717
|
+
top: number;
|
|
718
|
+
left: number;
|
|
719
|
+
};
|
|
720
|
+
export type Spacing = {
|
|
721
|
+
top: number;
|
|
722
|
+
bottom: number;
|
|
723
|
+
left: number;
|
|
724
|
+
right: number;
|
|
725
|
+
};
|
|
726
|
+
export type BracketRoundHeaderComponent<TRoundData, TMatchData> = BracketComponentType<{
|
|
727
|
+
bracketRound: BracketComponentInput<BracketRound<TRoundData, TMatchData>>;
|
|
728
|
+
bracketRoundSwissGroup?: BracketComponentInput<BracketRoundSwissGroup<TRoundData, TMatchData> | null>;
|
|
729
|
+
}>;
|
|
730
|
+
export type ComponentInputValue<T> = () => { [P in keyof T]: T[P] extends BracketComponentInput<infer TValue> ? TValue : never; };
|
|
731
|
+
export type BracketMatchComponent<TRoundData, TMatchData> = BracketComponentType<{
|
|
732
|
+
bracketRound: BracketComponentInput<BracketRound<TRoundData, TMatchData>>;
|
|
733
|
+
bracketMatch: BracketComponentInput<BracketMatch<TRoundData, TMatchData>>;
|
|
734
|
+
bracketRoundSwissGroup?: BracketComponentInput<BracketRoundSwissGroup<TRoundData, TMatchData> | null>;
|
|
735
|
+
}>;
|
|
736
|
+
export type BracketContinueComponent<TRoundData, TMatchData> = BracketComponentType<{
|
|
737
|
+
/** The matches whose winners advance to the next competition stage */
|
|
738
|
+
bracketMatches: BracketComponentInput<BracketMatch<TRoundData, TMatchData>[]>;
|
|
739
|
+
}>;
|
|
740
|
+
/** A component that draws a section's title, e.g. "Upper bracket" over a double elimination's upper rounds. */
|
|
741
|
+
export type BracketSectionTitleComponent<TRoundData, TMatchData> = BracketComponentType<{
|
|
742
|
+
bracketSection: BracketComponentInput<BracketGridSection<TRoundData, TMatchData>>;
|
|
743
|
+
}>;
|
|
744
|
+
export type BracketComponents<TRoundData, TMatchData> = {
|
|
745
|
+
roundHeader: BracketRoundHeaderComponent<TRoundData, TMatchData>;
|
|
746
|
+
match: BracketMatchComponent<TRoundData, TMatchData>;
|
|
747
|
+
finalMatch: BracketMatchComponent<TRoundData, TMatchData>;
|
|
748
|
+
continue?: BracketContinueComponent<TRoundData, TMatchData>;
|
|
749
|
+
};
|
|
750
|
+
export type CreateBracketElementPartConfig = {
|
|
751
|
+
elementPartHeight: number;
|
|
752
|
+
};
|
|
753
|
+
export type BracketElementPart = {
|
|
754
|
+
dimensions: Dimensions;
|
|
755
|
+
};
|
|
756
|
+
export declare const createBracketElementPart: (config: CreateBracketElementPartConfig) => BracketElementPart;
|
|
757
|
+
export type BracketElementBase = {
|
|
758
|
+
area: string;
|
|
759
|
+
dimensions: Dimensions;
|
|
760
|
+
containerDimensions: Dimensions;
|
|
761
|
+
parts: ReadonlyArray<BracketElementPart>;
|
|
762
|
+
span?: BracketElementSpanCoordinates;
|
|
763
|
+
};
|
|
764
|
+
export type HeaderBracketElement<TRoundData, TMatchData> = BracketElementBase & HeaderBracketElementDetails<TRoundData, TMatchData>;
|
|
765
|
+
export type MatchBracketElement<TRoundData, TMatchData> = BracketElementBase & MatchBracketElementDetails<TRoundData, TMatchData>;
|
|
766
|
+
export type GapBracketElement = BracketElementBase & GapBracketElementDetails;
|
|
767
|
+
export type ContinueBracketElement<TRoundData, TMatchData> = BracketElementBase & ContinueBracketElementDetails<TRoundData, TMatchData>;
|
|
768
|
+
export type BracketElement<TRoundData, TMatchData> = HeaderBracketElement<TRoundData, TMatchData> | MatchBracketElement<TRoundData, TMatchData> | GapBracketElement | ContinueBracketElement<TRoundData, TMatchData>;
|
|
769
|
+
export type BracketElementSpanCoordinates = {
|
|
770
|
+
masterColumnStart: number;
|
|
771
|
+
masterColumnEnd: number;
|
|
772
|
+
sectionStart: number;
|
|
773
|
+
sectionEnd: number;
|
|
774
|
+
subColumnStart: number;
|
|
775
|
+
subColumnEnd: number;
|
|
776
|
+
};
|
|
777
|
+
export type BracketElementToCreateBase = {
|
|
778
|
+
area: string;
|
|
779
|
+
partHeights: number[];
|
|
780
|
+
elementHeight: number;
|
|
781
|
+
};
|
|
782
|
+
export type HeaderBracketElementDetails<TRoundData, TMatchData> = {
|
|
783
|
+
type: 'header';
|
|
784
|
+
component: BracketRoundHeaderComponent<TRoundData, TMatchData>;
|
|
785
|
+
round: BracketRound<TRoundData, TMatchData>;
|
|
786
|
+
roundSwissGroup: BracketRoundSwissGroup<TRoundData, TMatchData> | null;
|
|
787
|
+
};
|
|
788
|
+
export type HeaderBracketElementToCreate<TRoundData, TMatchData> = BracketElementToCreateBase & HeaderBracketElementDetails<TRoundData, TMatchData>;
|
|
789
|
+
type MatchBracketElementDetails<TRoundData, TMatchData> = {
|
|
790
|
+
type: 'match';
|
|
791
|
+
component: BracketMatchComponent<TRoundData, TMatchData>;
|
|
792
|
+
match: BracketMatch<TRoundData, TMatchData>;
|
|
793
|
+
round: BracketRound<TRoundData, TMatchData>;
|
|
794
|
+
roundSwissGroup: BracketRoundSwissGroup<TRoundData, TMatchData> | null;
|
|
795
|
+
};
|
|
796
|
+
export type MatchBracketElementToCreate<TRoundData, TMatchData> = BracketElementToCreateBase & MatchBracketElementDetails<TRoundData, TMatchData>;
|
|
797
|
+
export type GapBracketElementDetails = {
|
|
798
|
+
type: 'matchGap' | 'roundHeaderGap' | 'roundGap' | 'colGap';
|
|
799
|
+
};
|
|
800
|
+
export type GapBracketElementToCreate = BracketElementToCreateBase & GapBracketElementDetails;
|
|
801
|
+
export type ContinueBracketElementDetails<TRoundData, TMatchData> = {
|
|
802
|
+
type: 'continue';
|
|
803
|
+
component: BracketContinueComponent<TRoundData, TMatchData>;
|
|
804
|
+
matches: BracketMatch<TRoundData, TMatchData>[];
|
|
805
|
+
};
|
|
806
|
+
export type ContinueBracketElementToCreate<TRoundData, TMatchData> = BracketElementToCreateBase & ContinueBracketElementDetails<TRoundData, TMatchData>;
|
|
807
|
+
export type BracketElementToCreate<TRoundData, TMatchData> = HeaderBracketElementToCreate<TRoundData, TMatchData> | MatchBracketElementToCreate<TRoundData, TMatchData> | GapBracketElementToCreate | ContinueBracketElementToCreate<TRoundData, TMatchData>;
|
|
808
|
+
export declare const createBracketElement: <TRoundData, TMatchData>(config: BracketElementToCreate<TRoundData, TMatchData>) => BracketElement<TRoundData, TMatchData>;
|
|
809
|
+
export type BracketSubColumn<TRoundData, TMatchData> = {
|
|
810
|
+
dimensions: Dimensions;
|
|
811
|
+
elements: ReadonlyArray<BracketElement<TRoundData, TMatchData>>;
|
|
812
|
+
span: BracketSubColumnSpan;
|
|
813
|
+
};
|
|
814
|
+
export type BracketSubColumnSpan = {
|
|
815
|
+
isStart: boolean;
|
|
816
|
+
isEnd: boolean;
|
|
817
|
+
};
|
|
818
|
+
export type CreateBracketSubColumnConfig = {
|
|
819
|
+
span: BracketSubColumnSpan;
|
|
820
|
+
};
|
|
821
|
+
export type MutableBracketSubColumn<TRoundData, TMatchData> = {
|
|
822
|
+
subColumn: BracketSubColumn<TRoundData, TMatchData>;
|
|
823
|
+
pushElement: (...elements: BracketElement<TRoundData, TMatchData>[]) => void;
|
|
824
|
+
};
|
|
825
|
+
export declare const createBracketSubColumn: <TRoundData, TMatchData>(config: CreateBracketSubColumnConfig) => MutableBracketSubColumn<TRoundData, TMatchData>;
|
|
826
|
+
export type BracketMasterColumnSectionType = 'round' | 'gap';
|
|
827
|
+
export type BracketMasterColumnSection<TRoundData, TMatchData> = {
|
|
828
|
+
subColumns: ReadonlyArray<BracketSubColumn<TRoundData, TMatchData>>;
|
|
829
|
+
dimensions: Dimensions;
|
|
830
|
+
type: BracketMasterColumnSectionType;
|
|
831
|
+
/** Overrides the master column padding for this section */
|
|
832
|
+
padding?: Spacing;
|
|
833
|
+
};
|
|
834
|
+
export type CreateBracketMasterColumnSectionConfig = {
|
|
835
|
+
type: BracketMasterColumnSectionType;
|
|
836
|
+
padding?: Spacing;
|
|
837
|
+
};
|
|
838
|
+
export type MutableBracketMasterColumnSection<TRoundData, TMatchData> = {
|
|
839
|
+
masterColumnSection: BracketMasterColumnSection<TRoundData, TMatchData>;
|
|
840
|
+
pushSubColumn: (...subColumns: BracketSubColumn<TRoundData, TMatchData>[]) => void;
|
|
841
|
+
};
|
|
842
|
+
export declare const createBracketMasterColumnSection: <TRoundData, TMatchData>(config: CreateBracketMasterColumnSectionConfig) => MutableBracketMasterColumnSection<TRoundData, TMatchData>;
|
|
843
|
+
export type BracketMasterColumn<TRoundData, TMatchData> = {
|
|
844
|
+
sections: ReadonlyArray<BracketMasterColumnSection<TRoundData, TMatchData>>;
|
|
845
|
+
dimensions: Dimensions;
|
|
846
|
+
padding: Spacing;
|
|
847
|
+
};
|
|
848
|
+
export type CreateBracketMasterColumnConfig = {
|
|
849
|
+
columnWidth: number;
|
|
850
|
+
padding: Spacing;
|
|
851
|
+
};
|
|
852
|
+
export type MutableBracketMasterColumn<TRoundData, TMatchData> = {
|
|
853
|
+
masterColumn: BracketMasterColumn<TRoundData, TMatchData>;
|
|
854
|
+
pushSection: (...sections: BracketMasterColumnSection<TRoundData, TMatchData>[]) => void;
|
|
855
|
+
};
|
|
856
|
+
export declare const createBracketMasterColumn: <TRoundData, TMatchData>(config: CreateBracketMasterColumnConfig) => MutableBracketMasterColumn<TRoundData, TMatchData>;
|
|
857
|
+
export type BracketGrid<TRoundData, TMatchData> = {
|
|
858
|
+
masterColumns: ReadonlyArray<BracketMasterColumn<TRoundData, TMatchData>>;
|
|
859
|
+
dimensions: Dimensions;
|
|
860
|
+
};
|
|
861
|
+
export type MutableBracketGrid<TRoundData, TMatchData> = {
|
|
862
|
+
grid: BracketGrid<TRoundData, TMatchData>;
|
|
863
|
+
pushMasterColumn: (...masterColumns: BracketMasterColumn<TRoundData, TMatchData>[]) => void;
|
|
864
|
+
calculateDimensions: () => void;
|
|
865
|
+
setupElementSpans: () => void;
|
|
866
|
+
};
|
|
867
|
+
export declare const createBracketGrid: <TRoundData, TMatchData>(config: {
|
|
868
|
+
spanElementWidth: number;
|
|
869
|
+
}) => MutableBracketGrid<TRoundData, TMatchData>;
|
|
870
|
+
export type FinalizedBracketColumn<TRoundData = unknown, TMatchData = unknown> = {
|
|
871
|
+
dimensions: Dimensions;
|
|
872
|
+
elements: FinalizedBracketElement<TRoundData, TMatchData>[];
|
|
873
|
+
};
|
|
874
|
+
export type FinalizedHeaderBracketElement<TRoundData, TMatchData> = {
|
|
875
|
+
type: 'header';
|
|
876
|
+
dimensions: Dimensions;
|
|
877
|
+
component: BracketRoundHeaderComponent<TRoundData, TMatchData>;
|
|
878
|
+
round: BracketRound<TRoundData, TMatchData>;
|
|
879
|
+
roundSwissGroup: BracketRoundSwissGroup<TRoundData, TMatchData> | null;
|
|
880
|
+
};
|
|
881
|
+
export type FinalizedMatchBracketElement<TRoundData, TMatchData> = {
|
|
882
|
+
type: 'match';
|
|
883
|
+
dimensions: Dimensions;
|
|
884
|
+
component: BracketMatchComponent<TRoundData, TMatchData>;
|
|
885
|
+
match: BracketMatch<TRoundData, TMatchData>;
|
|
886
|
+
round: BracketRound<TRoundData, TMatchData>;
|
|
887
|
+
roundSwissGroup: BracketRoundSwissGroup<TRoundData, TMatchData> | null;
|
|
888
|
+
classes: string;
|
|
889
|
+
};
|
|
890
|
+
export type FinalizedContinueBracketElement<TRoundData, TMatchData> = {
|
|
891
|
+
type: 'continue';
|
|
892
|
+
dimensions: Dimensions;
|
|
893
|
+
component: BracketContinueComponent<TRoundData, TMatchData>;
|
|
894
|
+
matches: BracketMatch<TRoundData, TMatchData>[];
|
|
895
|
+
};
|
|
896
|
+
export type FinalizedBracketElement<TRoundData = unknown, TMatchData = unknown> = FinalizedHeaderBracketElement<TRoundData, TMatchData> | FinalizedMatchBracketElement<TRoundData, TMatchData> | FinalizedContinueBracketElement<TRoundData, TMatchData>;
|
|
897
|
+
export type FinalizedBracketMatchElementMap<TRoundData, TMatchData> = BracketMap<string, FinalizedMatchBracketElement<TRoundData, TMatchData>>;
|
|
898
|
+
export declare const finalizeBracketGrid: <TRoundData, TMatchData>(grid: MutableBracketGrid<TRoundData, TMatchData>) => {
|
|
899
|
+
columns: FinalizedBracketColumn<TRoundData, TMatchData>[];
|
|
900
|
+
elementMap: FinalizedBracketMatchElementMap<TRoundData, TMatchData>;
|
|
901
|
+
};
|
|
902
|
+
export type ComputedBracketGrid<TRoundData, TMatchData> = {
|
|
903
|
+
raw: MutableBracketGrid<TRoundData, TMatchData>;
|
|
904
|
+
columns: FinalizedBracketColumn<TRoundData, TMatchData>[];
|
|
905
|
+
matchElementMap: FinalizedBracketMatchElementMap<TRoundData, TMatchData>;
|
|
906
|
+
/** The parts of the bracket and where they sit. Only the left-to-right double elimination grid sets it. */
|
|
907
|
+
sections?: BracketGridSection<TRoundData, TMatchData>[];
|
|
908
|
+
};
|
|
909
|
+
/** Returns the width needed to render a computed bracket grid without horizontal clipping. */
|
|
910
|
+
export declare const bracketGridNaturalWidth: <TRoundData, TMatchData>(grid: ComputedBracketGrid<TRoundData, TMatchData>) => number;
|
|
911
|
+
export declare const BRACKET_FINAL_ALIGNMENT: {
|
|
912
|
+
readonly UPPER: "upper";
|
|
913
|
+
readonly CENTER: "center";
|
|
914
|
+
};
|
|
915
|
+
/**
|
|
916
|
+
* Where a left-to-right double elimination puts its finals: `'upper'` level with the upper bracket final,
|
|
917
|
+
* `'center'` on the midpoint between the centres of the upper bracket final and the lower bracket final.
|
|
918
|
+
*/
|
|
919
|
+
export type BracketFinalAlignment = (typeof BRACKET_FINAL_ALIGNMENT)[keyof typeof BRACKET_FINAL_ALIGNMENT];
|
|
920
|
+
export type CreateBracketGridConfig = {
|
|
921
|
+
includeRoundHeaders: boolean;
|
|
922
|
+
columnWidth: number;
|
|
923
|
+
matchHeight: number;
|
|
924
|
+
roundHeaderHeight: number;
|
|
925
|
+
roundHeaderGap: number;
|
|
926
|
+
columnGap: number;
|
|
927
|
+
rowRoundGap: number;
|
|
928
|
+
rowGap: number;
|
|
929
|
+
rowSpanRoundId: string | null;
|
|
930
|
+
finalMatchHeight: number;
|
|
931
|
+
finalColumnWidth: number;
|
|
932
|
+
/**
|
|
933
|
+
* What the final keeps between its round header and its card, in px, where that is more than
|
|
934
|
+
* `roundHeaderGap`. The room goes to the final's column alone. Unset gives it the same gap as every
|
|
935
|
+
* other round.
|
|
936
|
+
*/
|
|
937
|
+
finalRoundHeaderGap?: number | null;
|
|
938
|
+
/**
|
|
939
|
+
* How far below the top of the final's card a third place match sits, in px, when the two share a
|
|
940
|
+
* column. Unset (or `null`) gives the third place a column of its own, except in a mirrored layout,
|
|
941
|
+
* which folds it one `rowGap` below the final's card.
|
|
942
|
+
*/
|
|
943
|
+
thirdPlaceTopOffset?: number | null;
|
|
944
|
+
swissGroupPadding: number;
|
|
945
|
+
swissGroupBorderWidth: number;
|
|
946
|
+
/**
|
|
947
|
+
* The band reserved above each section for its title, in px. Only the left-to-right double elimination
|
|
948
|
+
* grid reserves it; unset or `0` reserves none.
|
|
949
|
+
*/
|
|
950
|
+
sectionTitleHeight?: number;
|
|
951
|
+
/** The space between a section title band and the first row of its section, in px. Unset reserves none. */
|
|
952
|
+
sectionTitleGap?: number;
|
|
953
|
+
/**
|
|
954
|
+
* Where the left-to-right double elimination grid puts the final and the bracket reset, see
|
|
955
|
+
* {@link BracketFinalAlignment}. Unset means `'upper'`; a centred final never overlaps a third place below it.
|
|
956
|
+
*/
|
|
957
|
+
finalAlignment?: BracketFinalAlignment;
|
|
958
|
+
layout: BracketDataLayout;
|
|
959
|
+
continueElement?: {
|
|
960
|
+
columnWidth: number;
|
|
961
|
+
elementHeight: number;
|
|
962
|
+
} | null;
|
|
963
|
+
};
|
|
964
|
+
export type DrawManDimensions<TRoundData, TMatchData> = {
|
|
965
|
+
columnWidth: number;
|
|
966
|
+
matchHeight: number;
|
|
967
|
+
roundHeaderHeight: number;
|
|
968
|
+
columnGap: number;
|
|
969
|
+
upperLowerGap: number;
|
|
970
|
+
rowGap: number;
|
|
971
|
+
bracketGrid: ComputedBracketGrid<TRoundData, TMatchData>;
|
|
972
|
+
path: Omit<PathOptions, 'className' | 'id'>;
|
|
973
|
+
curve: Omit<CurveOptions, 'path' | 'inverted'>;
|
|
974
|
+
/** Path options for the lines connecting the continuing matches to the continue element */
|
|
975
|
+
continuePath?: Omit<PathOptions, 'className' | 'id'>;
|
|
976
|
+
};
|
|
977
|
+
export declare const drawMan: <TRoundData, TMatchData>(dimensions: DrawManDimensions<TRoundData, TMatchData>) => BracketDrawing;
|
|
978
|
+
export type DrawSwissManDimensions<TRoundData, TMatchData> = {
|
|
979
|
+
bracketGrid: ComputedBracketGrid<TRoundData, TMatchData>;
|
|
980
|
+
path: Omit<PathOptions, 'className' | 'stroke' | 'id'>;
|
|
981
|
+
curve: {
|
|
982
|
+
lineStartingCurveAmount: number;
|
|
983
|
+
};
|
|
984
|
+
groupBorder: {
|
|
985
|
+
padding: number;
|
|
986
|
+
radius: number;
|
|
987
|
+
width: number;
|
|
988
|
+
};
|
|
989
|
+
colors?: BracketSwissColors;
|
|
990
|
+
/** Used to create document wide unique ids for the connection line gradients */
|
|
991
|
+
idPrefix: string;
|
|
992
|
+
};
|
|
993
|
+
export declare const drawSwissMan: <TRoundData, TMatchData>(dimensions: DrawSwissManDimensions<TRoundData, TMatchData>) => BracketDrawing;
|
|
994
|
+
export declare const createDoubleEliminationGrid: <TRoundData, TMatchData>(bracketData: Bracket<TRoundData, TMatchData>, options: CreateBracketGridConfig, components: BracketComponents<TRoundData, TMatchData>) => ComputedBracketGrid<TRoundData, TMatchData>;
|
|
995
|
+
/**
|
|
996
|
+
* Draws a double elimination as two mirrored blocks, one above the other: the winners bracket folded
|
|
997
|
+
* around its own centre, the losers bracket folded around its own, and nothing but a gap between them.
|
|
998
|
+
* Each block's deciding rounds hang vertically below the round its two halves converge on.
|
|
999
|
+
*/
|
|
1000
|
+
declare const createStackedDoubleEliminationGrid: <TRoundData, TMatchData>(bracketData: Bracket<TRoundData, TMatchData>, options: CreateBracketGridConfig, components: BracketComponents<TRoundData, TMatchData>) => ComputedBracketGrid<TRoundData, TMatchData>;
|
|
1001
|
+
export declare const calculateUpperLowerRatio: (upperRoundsCount: number, lowerRoundsCount: number) => number;
|
|
1002
|
+
export declare const calculateColumnSplitFactor: (upperToLowerRatio: number) => 1 | 2;
|
|
1003
|
+
export declare const calculateLowerRoundIndex: (subColumnIndex: number, splitFactor: number) => number;
|
|
1004
|
+
export declare const calculateUpperRoundIndex: (subColumnIndex: number, upperToLowerRatio: number, splitFactor: number) => number;
|
|
1005
|
+
export declare const isBracketContinueMatch: <TRoundData, TMatchData>(match: BracketMatch<TRoundData, TMatchData>) => boolean;
|
|
1006
|
+
export declare const getBracketContinueMatches: <TRoundData, TMatchData>(bracketData: Bracket<TRoundData, TMatchData>) => BracketMatch<TRoundData, TMatchData>[];
|
|
1007
|
+
export type CreateBracketContinueMasterColumnConfig<TRoundData, TMatchData> = {
|
|
1008
|
+
existingMasterColumns: ReadonlyArray<BracketMasterColumn<TRoundData, TMatchData>>;
|
|
1009
|
+
columnWidth: number;
|
|
1010
|
+
elementHeight: number;
|
|
1011
|
+
/** Vertical space taken by the round header block (header + gap). 0 if headers are hidden. */
|
|
1012
|
+
headerOffset: number;
|
|
1013
|
+
component: BracketContinueComponent<TRoundData, TMatchData>;
|
|
1014
|
+
matches: BracketMatch<TRoundData, TMatchData>[];
|
|
1015
|
+
};
|
|
1016
|
+
export declare const createBracketContinueMasterColumn: <TRoundData, TMatchData>(config: CreateBracketContinueMasterColumnConfig<TRoundData, TMatchData>) => BracketMasterColumn<TRoundData, TMatchData>;
|
|
1017
|
+
export type CreateFoldedThirdPlaceSectionConfig<TRoundData, TMatchData> = {
|
|
1018
|
+
/** The sub column holding the final, which the folded round is placed relative to. */
|
|
1019
|
+
finalSubColumn: BracketSubColumn<TRoundData, TMatchData>;
|
|
1020
|
+
round: BracketRound<TRoundData, TMatchData>;
|
|
1021
|
+
/** How far below the top of the final's card the third place card sits, in px. */
|
|
1022
|
+
topOffset: number;
|
|
1023
|
+
options: CreateBracketGridConfig;
|
|
1024
|
+
components: BracketComponents<TRoundData, TMatchData>;
|
|
1025
|
+
};
|
|
1026
|
+
export type CreateBracketGapMasterColumnConfig<TRoundData, TMatchData> = {
|
|
1027
|
+
existingMasterColumns: ReadonlyArray<BracketMasterColumn<TRoundData, TMatchData>>;
|
|
1028
|
+
columnGap: number;
|
|
1029
|
+
};
|
|
1030
|
+
export declare const createBracketGapMasterColumn: <TRoundData, TMatchData>(config: CreateBracketGapMasterColumnConfig<TRoundData, TMatchData>) => BracketMasterColumn<TRoundData, TMatchData>;
|
|
1031
|
+
export type CreateRoundBracketSubColumnRelativeToFirstRoundConfig<TRoundData, TMatchData> = {
|
|
1032
|
+
firstRound: BracketRound<TRoundData, TMatchData>;
|
|
1033
|
+
round: BracketRound<TRoundData, TMatchData>;
|
|
1034
|
+
span: BracketSubColumnSpan;
|
|
1035
|
+
hasReverseFinal: boolean;
|
|
1036
|
+
options: CreateBracketGridConfig;
|
|
1037
|
+
components: BracketComponents<TRoundData, TMatchData>;
|
|
1038
|
+
/**
|
|
1039
|
+
* Reserved space below the last match, for a layout whose columns are taller than the first round
|
|
1040
|
+
* needs - a stacked bracket's centre chain hanging past the bottom of its block.
|
|
1041
|
+
*/
|
|
1042
|
+
bottomPadding?: number;
|
|
1043
|
+
topPadding?: number;
|
|
1044
|
+
/**
|
|
1045
|
+
* How many first-round rows each of this round's matches owns. Derived from the round's own match
|
|
1046
|
+
* count when unset; a folded round is placed by its offset instead and takes `1`.
|
|
1047
|
+
*/
|
|
1048
|
+
matchFactor?: number;
|
|
1049
|
+
};
|
|
1050
|
+
export declare const createRoundBracketSubColumnRelativeToFirstRound: <TRoundData, TMatchData>(config: CreateRoundBracketSubColumnRelativeToFirstRoundConfig<TRoundData, TMatchData>) => import("@ethlete/components/bracket").BracketSubColumn<TRoundData, TMatchData>;
|
|
1051
|
+
export declare const resolveBracketGridRowSpan: <TRoundData, TMatchData>(bracket: {
|
|
1052
|
+
rounds: {
|
|
1053
|
+
values(): Iterable<BracketRound<TRoundData, TMatchData>>;
|
|
1054
|
+
};
|
|
1055
|
+
}, options: CreateBracketGridConfig) => CreateBracketGridConfig;
|
|
1056
|
+
export declare const createSingleEliminationGrid: <TRoundData, TMatchData>(bracketData: Bracket<TRoundData, TMatchData>, options: CreateBracketGridConfig, components: BracketComponents<TRoundData, TMatchData>) => ComputedBracketGrid<TRoundData, TMatchData>;
|
|
1057
|
+
export declare const createSwissGrid: <TRoundData, TMatchData>(bracketData: Bracket<TRoundData, TMatchData>, options: CreateBracketGridConfig, components: BracketComponents<TRoundData, TMatchData>) => ComputedBracketGrid<TRoundData, TMatchData>;
|
|
1058
|
+
export type LineOptions = {
|
|
1059
|
+
path: PathOptions;
|
|
1060
|
+
/** Draw right to left - the flow direction of a mirrored bracket's way back. */
|
|
1061
|
+
inverted?: boolean;
|
|
1062
|
+
};
|
|
1063
|
+
export declare const linePath: (from: BracketPosition, to: BracketPosition, options: LineOptions) => import("@ethlete/components/bracket").BracketEdge;
|
|
1064
|
+
/**
|
|
1065
|
+
* The connector between two cards sharing a column, where {@link linePath} and `curvePath` both
|
|
1066
|
+
* degenerate to a zero-width horizontal run: straight down (or up) the column, edge to edge.
|
|
1067
|
+
*/
|
|
1068
|
+
export declare const verticalPath: (from: BracketPosition, to: BracketPosition, options: LineOptions) => import("@ethlete/components/bracket").BracketEdge;
|
|
1069
|
+
export type GutterLineOptions = LineOptions & {
|
|
1070
|
+
/** How far past the column's edge the vertical run sits - half a column gap keeps it clear of both. */
|
|
1071
|
+
gutter: number;
|
|
1072
|
+
};
|
|
1073
|
+
/**
|
|
1074
|
+
* A same-column connector for two cards with others stacked between them: out sideways, along the
|
|
1075
|
+
* empty strip beside the column, and back in. {@link verticalPath} would run through everything in
|
|
1076
|
+
* its way.
|
|
1077
|
+
*/
|
|
1078
|
+
export declare const gutterPath: (from: BracketPosition, to: BracketPosition, options: GutterLineOptions) => import("@ethlete/components/bracket").BracketEdge;
|
|
1079
|
+
export type BracketLayoutRegistration = {
|
|
1080
|
+
name: string;
|
|
1081
|
+
mode: TournamentMode;
|
|
1082
|
+
};
|
|
1083
|
+
/** Returns the first registered layout matching the tournament mode. */
|
|
1084
|
+
export declare const resolveBracketLayout: <TLayout extends BracketLayoutRegistration>(layouts: readonly TLayout[] | undefined, mode: TournamentMode) => TLayout;
|
|
1085
|
+
export type SingleEliminationPlaceholderShape = {
|
|
1086
|
+
mode: typeof TOURNAMENT_MODE.SINGLE_ELIMINATION;
|
|
1087
|
+
/** A power of two, at least 2. */
|
|
1088
|
+
participantCount: number;
|
|
1089
|
+
/** @default false */
|
|
1090
|
+
includeThirdPlace?: boolean;
|
|
1091
|
+
};
|
|
1092
|
+
export type DoubleEliminationPlaceholderShape = {
|
|
1093
|
+
mode: typeof TOURNAMENT_MODE.DOUBLE_ELIMINATION;
|
|
1094
|
+
/** A power of two, at least 4. */
|
|
1095
|
+
participantCount: number;
|
|
1096
|
+
/** @default true */
|
|
1097
|
+
includeFinal?: boolean;
|
|
1098
|
+
/** Ignored when `includeFinal` is false. @default true */
|
|
1099
|
+
includeReverseFinal?: boolean;
|
|
1100
|
+
/** @default false */
|
|
1101
|
+
includeThirdPlace?: boolean;
|
|
1102
|
+
};
|
|
1103
|
+
/** The structure a placeholder bracket is drawn with - see {@link createPlaceholderBracketSource}. */
|
|
1104
|
+
export type PlaceholderBracketShape = SingleEliminationPlaceholderShape | DoubleEliminationPlaceholderShape;
|
|
1105
|
+
/**
|
|
1106
|
+
* An empty bracket of the given shape - every match `pending`, both sides `null` - for drawing a loading
|
|
1107
|
+
* state with the real layout before the data arrives. Throws `ET3415` for a `participantCount` that is
|
|
1108
|
+
* not a power of two (or too small for the mode).
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
* const source = createPlaceholderBracketSource({ mode: 'single-elimination', participantCount: 16 });
|
|
1112
|
+
*/
|
|
1113
|
+
export declare const createPlaceholderBracketSource: (shape: PlaceholderBracketShape) => BracketDataSource<null, null>;
|
|
1114
|
+
/** How a group-table prediction scored on one position, once the real order is in. */
|
|
1115
|
+
export declare const STANDING_PICK_OUTCOME: {
|
|
1116
|
+
/** The participant finished on exactly the predicted position. */
|
|
1117
|
+
readonly EXACT: "exact";
|
|
1118
|
+
/** They finished on the predicted side of the advancing line, on another position. */
|
|
1119
|
+
readonly PARTIAL: "partial";
|
|
1120
|
+
/** They finished on the other side of the advancing line. */
|
|
1121
|
+
readonly WRONG: "wrong";
|
|
1122
|
+
};
|
|
1123
|
+
export type StandingPickOutcome = (typeof STANDING_PICK_OUTCOME)[keyof typeof STANDING_PICK_OUTCOME];
|
|
1124
|
+
/**
|
|
1125
|
+
* How the participant predicted on `predictedPosition` scored, given where they really finished.
|
|
1126
|
+
*
|
|
1127
|
+
* `advancingCount` is how many positions advance, so a position is on the advancing side while it is
|
|
1128
|
+
* `<= advancingCount`. Ending up on the other side of that line is `WRONG` whatever the distance; the
|
|
1129
|
+
* predicted side of it is `EXACT` on the predicted position and `PARTIAL` on any other.
|
|
1130
|
+
*
|
|
1131
|
+
* `EXACT` is awarded below the line as well. An app whose API stores only the advancing positions holds no
|
|
1132
|
+
* prediction for the rest - the order there is whatever its UI happened to draw - and should narrow the
|
|
1133
|
+
* result to `PARTIAL`/`WRONG` itself for those positions.
|
|
1134
|
+
*
|
|
1135
|
+
* Returns the outcome and no points: what an outcome is worth is a rule of the competition, and
|
|
1136
|
+
* `POINTS[outcome]` is a lookup the app already owns.
|
|
1137
|
+
*/
|
|
1138
|
+
export declare const standingPickOutcome: (options: {
|
|
1139
|
+
/** The position the participant was predicted to finish on, 1-based. */
|
|
1140
|
+
predictedPosition: number;
|
|
1141
|
+
/** The position they really finished on, 1-based. */
|
|
1142
|
+
actualPosition: number;
|
|
1143
|
+
/** How many positions advance. */
|
|
1144
|
+
advancingCount: number;
|
|
1145
|
+
}) => StandingPickOutcome;
|
|
1146
|
+
/** A prediction already stored for one position of a group table. */
|
|
1147
|
+
export type StandingPick = {
|
|
1148
|
+
/** The position it was stored on, 1-based. */
|
|
1149
|
+
position: number;
|
|
1150
|
+
/** The participant predicted to finish there. */
|
|
1151
|
+
participantId: string;
|
|
1152
|
+
};
|
|
1153
|
+
/**
|
|
1154
|
+
* The order to show a group table in before anyone moves a row: every stored pick takes the position it was
|
|
1155
|
+
* stored on, and the participants without one follow in the order the backend listed them, filling the gaps.
|
|
1156
|
+
*
|
|
1157
|
+
* A pick the field cannot hold is dropped rather than drawn - a position that is not an integer in
|
|
1158
|
+
* `1..participantIds.length`, an id that is not in the field, a second pick for a position or for a
|
|
1159
|
+
* participant already placed (the lowest position keeps it). The result is therefore always a permutation
|
|
1160
|
+
* of `participantIds`.
|
|
1161
|
+
*/
|
|
1162
|
+
export declare const standingPickStartOrder: (options: {
|
|
1163
|
+
/** The participants, in the order the backend listed them. */
|
|
1164
|
+
participantIds: readonly string[];
|
|
1165
|
+
/** What is already stored, in any order. */
|
|
1166
|
+
picks: readonly StandingPick[];
|
|
1167
|
+
}) => string[];
|
|
1168
|
+
/**
|
|
1169
|
+
* Puts `participantId` on `rank` (1-based) of a standing order by swapping it with whoever stood there. Always
|
|
1170
|
+
* returns a new array; it equals `order` when the participant is not in it or `rank` is outside the order.
|
|
1171
|
+
*/
|
|
1172
|
+
export declare const swapStandingRank: (options: {
|
|
1173
|
+
order: readonly string[];
|
|
1174
|
+
rank: number;
|
|
1175
|
+
participantId: string;
|
|
1176
|
+
}) => string[];
|
|
1177
|
+
export { createStackedDoubleEliminationGrid as ɵcreateStackedDoubleEliminationGrid };
|