@diagrammo/dgmo 0.87.0 → 0.88.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/advanced.d.ts +6 -0
- package/dist/advanced.js +8 -6
- package/dist/block.js +3 -2
- package/dist/{chunk-FBKPSU3A.js → chunk-5LD7SHXO.js} +1 -1
- package/dist/{chunk-Q2U5635V.js → chunk-ABP5BUD6.js} +9 -430
- package/dist/{chunk-LPXC4I4R.js → chunk-JLETTWUJ.js} +12 -9
- package/dist/{chunk-AGO3PFGS.js → chunk-MVCPO6LI.js} +15 -10
- package/dist/{chunk-PJQZWJ5I.js → chunk-VW52W5F6.js} +934 -82
- package/dist/chunk-WXPBP4IT.js +438 -0
- package/dist/index.js +3 -2
- package/dist/{renderer-NX4YKWCJ.js → renderer-RNCYODNF.js} +1 -1
- package/dist/{renderer-3CTUWCO7.js → renderer-TPOZOAXR.js} +2 -2
- package/dist/{renderer-ELYPDPNF.js → renderer-XUPLAO4B.js} +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderInlineText
|
|
3
|
+
} from "./chunk-S7W75MIM.js";
|
|
4
|
+
import {
|
|
5
|
+
BOX_H,
|
|
6
|
+
BOX_W,
|
|
7
|
+
COMMENT_W,
|
|
8
|
+
PAIR_GAP,
|
|
9
|
+
layoutBracket,
|
|
10
|
+
wrapText
|
|
11
|
+
} from "./chunk-ABP5BUD6.js";
|
|
12
|
+
import {
|
|
13
|
+
layoutInlineHeader
|
|
14
|
+
} from "./chunk-3DOQOXXI.js";
|
|
15
|
+
import {
|
|
16
|
+
TITLE_FONT_SIZE,
|
|
17
|
+
TITLE_FONT_WEIGHT,
|
|
18
|
+
TITLE_Y
|
|
19
|
+
} from "./chunk-VLC6WNRD.js";
|
|
20
|
+
import {
|
|
21
|
+
renderIntegratedLegend
|
|
22
|
+
} from "./chunk-LHL6HDUL.js";
|
|
23
|
+
import {
|
|
24
|
+
getLegendExtent,
|
|
25
|
+
getMaxLegendReservedHeight
|
|
26
|
+
} from "./chunk-FM3WAVB6.js";
|
|
27
|
+
import {
|
|
28
|
+
FONT_FAMILY
|
|
29
|
+
} from "./chunk-ICLB27PZ.js";
|
|
30
|
+
import {
|
|
31
|
+
LEGEND_GROUP_GAP
|
|
32
|
+
} from "./chunk-RH2PROYG.js";
|
|
33
|
+
import {
|
|
34
|
+
measureText
|
|
35
|
+
} from "./chunk-KAO7JL4I.js";
|
|
36
|
+
import {
|
|
37
|
+
resolveTagColor,
|
|
38
|
+
tagAttrKey
|
|
39
|
+
} from "./chunk-L5AFONQU.js";
|
|
40
|
+
import {
|
|
41
|
+
contrastText,
|
|
42
|
+
getSeriesColors,
|
|
43
|
+
mix,
|
|
44
|
+
shapeFill,
|
|
45
|
+
themeBaseBg
|
|
46
|
+
} from "./chunk-7HWY4QAJ.js";
|
|
47
|
+
import {
|
|
48
|
+
resolveColor
|
|
49
|
+
} from "./chunk-2M4IGSCY.js";
|
|
50
|
+
|
|
51
|
+
// src/bracket/renderer.ts
|
|
52
|
+
import * as d3Selection from "d3-selection";
|
|
53
|
+
var PADDING = 16;
|
|
54
|
+
var TITLE_BAND = 40;
|
|
55
|
+
var HALF_SPAN = (BOX_H + PAIR_GAP) / 2;
|
|
56
|
+
var COMMENT_LH = 15;
|
|
57
|
+
var LEGEND_POSITION = {
|
|
58
|
+
placement: "top-center",
|
|
59
|
+
titleRelation: "below-title"
|
|
60
|
+
};
|
|
61
|
+
function clip(s, maxW, fs, bold) {
|
|
62
|
+
if (measureText(s, fs, { bold }) <= maxW) return s;
|
|
63
|
+
let lo = 0;
|
|
64
|
+
let hi = s.length;
|
|
65
|
+
while (lo < hi) {
|
|
66
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
67
|
+
if (measureText(s.slice(0, mid) + "\u2026", fs, { bold }) <= maxW) lo = mid;
|
|
68
|
+
else hi = mid - 1;
|
|
69
|
+
}
|
|
70
|
+
return lo <= 0 ? "" : s.slice(0, lo) + "\u2026";
|
|
71
|
+
}
|
|
72
|
+
function paintForAccent(palette, isDark, accent, fillMode) {
|
|
73
|
+
const base = themeBaseBg(palette, isDark);
|
|
74
|
+
return {
|
|
75
|
+
accent,
|
|
76
|
+
ink: palette.text,
|
|
77
|
+
muted: mix(palette.text, base, 52),
|
|
78
|
+
// Loser / TBD outlines + connectors are ink-based (not the pale border) so
|
|
79
|
+
// they stay legible on top of a colored, shaded column band.
|
|
80
|
+
hair: mix(palette.text, base, 34),
|
|
81
|
+
wire: mix(palette.text, base, 30),
|
|
82
|
+
track: mix(palette.border, base, 55),
|
|
83
|
+
// §1.9 fill family rides through shapeFill: solid ⇒ raw accent,
|
|
84
|
+
// outline ⇒ theme base bg (accent stays on the stroke), absent ⇒ 25% tint.
|
|
85
|
+
tint: shapeFill(palette, accent, isDark, { mode: fillMode })
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function paintFor(palette, isDark, sideColor, fillMode) {
|
|
89
|
+
const accent = sideColor && resolveColor(sideColor, palette) || sideColor || getSeriesColors(palette)[0];
|
|
90
|
+
return paintForAccent(palette, isDark, accent, fillMode);
|
|
91
|
+
}
|
|
92
|
+
function resolveBracketLegend(parsed, palette) {
|
|
93
|
+
const activeTag = parsed.activeTag;
|
|
94
|
+
const activeGroup = activeTag ? parsed.tagGroups.find((g) => tagAttrKey(g.name) === tagAttrKey(activeTag)) : void 0;
|
|
95
|
+
const legendGroups = activeGroup && !parsed.noLegend ? [
|
|
96
|
+
{
|
|
97
|
+
name: activeGroup.name,
|
|
98
|
+
entries: activeGroup.entries.map((e) => ({
|
|
99
|
+
value: e.value,
|
|
100
|
+
color: resolveColor(e.color, palette) ?? e.color
|
|
101
|
+
}))
|
|
102
|
+
}
|
|
103
|
+
] : [];
|
|
104
|
+
return { activeGroup, legendGroups };
|
|
105
|
+
}
|
|
106
|
+
function bracketExportDimensions(parsed, palette) {
|
|
107
|
+
const layout = layoutBracket(parsed);
|
|
108
|
+
const width = layout.width + PADDING * 2;
|
|
109
|
+
const titleH = parsed.title ? TITLE_BAND : 0;
|
|
110
|
+
const { legendGroups } = resolveBracketLegend(parsed, palette);
|
|
111
|
+
const legendReserve = legendGroups.length > 0 ? getMaxLegendReservedHeight(
|
|
112
|
+
{ groups: legendGroups, position: LEGEND_POSITION, mode: "export" },
|
|
113
|
+
width
|
|
114
|
+
) + LEGEND_GROUP_GAP : 0;
|
|
115
|
+
const height = titleH + legendReserve + PADDING + layout.height + PADDING;
|
|
116
|
+
return { width, height };
|
|
117
|
+
}
|
|
118
|
+
function renderBracket(container, parsed, palette, isDark, exportDims) {
|
|
119
|
+
d3Selection.select(container).selectAll(":not([data-d3-tooltip])").remove();
|
|
120
|
+
if (parsed.error) return;
|
|
121
|
+
const layout = layoutBracket(parsed);
|
|
122
|
+
const width = exportDims?.width ?? container.clientWidth;
|
|
123
|
+
const height = exportDims?.height ?? container.clientHeight;
|
|
124
|
+
if (width <= 0 || height <= 0) return;
|
|
125
|
+
const showTitle = !!parsed.title;
|
|
126
|
+
const titleH = showTitle ? TITLE_BAND : 0;
|
|
127
|
+
const exportMode = exportDims !== void 0;
|
|
128
|
+
const seedByName = /* @__PURE__ */ new Map();
|
|
129
|
+
for (const s of parsed.seeds)
|
|
130
|
+
if (!seedByName.has(s.name)) seedByName.set(s.name, s.seed);
|
|
131
|
+
const activeTag = parsed.activeTag;
|
|
132
|
+
const activeKey = activeTag ? tagAttrKey(activeTag) : null;
|
|
133
|
+
const tagValueOf = (name) => {
|
|
134
|
+
if (!name || !activeKey) return null;
|
|
135
|
+
const meta = parsed.competitorMeta.get(name);
|
|
136
|
+
return meta?.[activeKey] ?? null;
|
|
137
|
+
};
|
|
138
|
+
const tagColorOf = (name) => {
|
|
139
|
+
if (!name || !activeTag) return null;
|
|
140
|
+
const meta = parsed.competitorMeta.get(name);
|
|
141
|
+
if (!meta || !activeKey || !meta[activeKey]) return null;
|
|
142
|
+
const c = resolveTagColor(meta, [...parsed.tagGroups], activeTag);
|
|
143
|
+
return c ? resolveColor(c, palette) ?? c : null;
|
|
144
|
+
};
|
|
145
|
+
const { activeGroup, legendGroups } = resolveBracketLegend(parsed, palette);
|
|
146
|
+
const legendReserve = legendGroups.length > 0 ? getMaxLegendReservedHeight(
|
|
147
|
+
{ groups: legendGroups, position: LEGEND_POSITION, mode: "preview" },
|
|
148
|
+
width
|
|
149
|
+
) + LEGEND_GROUP_GAP : 0;
|
|
150
|
+
const inlineRequested = parsed.legendInline === true;
|
|
151
|
+
const legendExtent = inlineRequested && legendGroups.length > 0 ? getLegendExtent(
|
|
152
|
+
{
|
|
153
|
+
groups: legendGroups,
|
|
154
|
+
position: {
|
|
155
|
+
placement: "top-center",
|
|
156
|
+
titleRelation: "inline-with-title"
|
|
157
|
+
},
|
|
158
|
+
mode: exportMode ? "export" : "preview"
|
|
159
|
+
},
|
|
160
|
+
{ activeGroup: activeGroup?.name ?? null },
|
|
161
|
+
width
|
|
162
|
+
) : { width: 0, height: 0 };
|
|
163
|
+
const header = layoutInlineHeader({
|
|
164
|
+
requested: inlineRequested,
|
|
165
|
+
title: parsed.title ?? "",
|
|
166
|
+
hasLegend: legendGroups.length > 0,
|
|
167
|
+
legendWidth: legendExtent.width,
|
|
168
|
+
legendHeight: legendExtent.height,
|
|
169
|
+
containerWidth: width,
|
|
170
|
+
titleBandHeight: titleH,
|
|
171
|
+
legendReserve,
|
|
172
|
+
titleBaselineY: TITLE_Y,
|
|
173
|
+
titleFontSize: TITLE_FONT_SIZE
|
|
174
|
+
});
|
|
175
|
+
const svg = d3Selection.select(container).append("svg").attr("width", width).attr("height", height).attr("viewBox", `0 0 ${width} ${height}`).attr("preserveAspectRatio", "xMidYMin meet").attr("xmlns", "http://www.w3.org/2000/svg").attr("class", "dgmo-bracket").attr("role", "img").attr(
|
|
176
|
+
"aria-label",
|
|
177
|
+
`Tournament bracket${parsed.title ? ` \u2014 ${parsed.title}` : ""}${layout.champion ? `, champion ${layout.champion}` : ""}`
|
|
178
|
+
).style("font-family", FONT_FAMILY);
|
|
179
|
+
if (showTitle) {
|
|
180
|
+
const t = svg.append("text").attr("class", "chart-title").attr("x", header.titleX).attr("y", TITLE_Y).attr("text-anchor", header.titleAnchor).attr("fill", palette.text).attr("font-family", FONT_FAMILY).attr("font-size", TITLE_FONT_SIZE).attr("font-weight", TITLE_FONT_WEIGHT).text(parsed.title);
|
|
181
|
+
if (parsed.titleLineNumber !== null)
|
|
182
|
+
t.attr("data-line-number", parsed.titleLineNumber);
|
|
183
|
+
}
|
|
184
|
+
const areaY = (header.inline ? titleH : titleH + legendReserve) + PADDING;
|
|
185
|
+
const areaX = PADDING;
|
|
186
|
+
const areaW = Math.max(1, width - PADDING * 2);
|
|
187
|
+
const areaH = Math.max(1, height - areaY - PADDING);
|
|
188
|
+
const scale = Math.min(1, areaW / layout.width, areaH / layout.height);
|
|
189
|
+
const offsetX = areaX + (areaW - layout.width * scale) / 2;
|
|
190
|
+
const offsetY = areaY;
|
|
191
|
+
const root = svg.append("g").attr("class", "dgmo-bracket-body").attr("transform", `translate(${offsetX},${offsetY}) scale(${scale})`);
|
|
192
|
+
if (legendGroups.length > 0) {
|
|
193
|
+
const legendG = svg.append("g").attr("class", "dgmo-bracket-legend").attr(
|
|
194
|
+
"transform",
|
|
195
|
+
header.inline ? `translate(${header.legendX}, ${header.legendY})` : `translate(0, ${titleH})`
|
|
196
|
+
);
|
|
197
|
+
renderIntegratedLegend(legendG, {
|
|
198
|
+
groups: legendGroups,
|
|
199
|
+
palette: {
|
|
200
|
+
bg: palette.bg,
|
|
201
|
+
surface: palette.surface,
|
|
202
|
+
text: palette.text,
|
|
203
|
+
textMuted: palette.textMuted,
|
|
204
|
+
primary: palette.primary
|
|
205
|
+
},
|
|
206
|
+
isDark,
|
|
207
|
+
width,
|
|
208
|
+
mode: exportMode ? "export" : "preview",
|
|
209
|
+
position: {
|
|
210
|
+
placement: "top-center",
|
|
211
|
+
titleRelation: header.inline ? "inline-with-title" : "below-title"
|
|
212
|
+
},
|
|
213
|
+
activeGroup: activeGroup?.name ?? null
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const baseAccent = parsed.accentColor ?? resolveColor("blue", palette) ?? getSeriesColors(palette)[0];
|
|
217
|
+
const fillMode = parsed.fillMode;
|
|
218
|
+
const basePaint = paintForAccent(palette, isDark, baseAccent, fillMode);
|
|
219
|
+
const sideColorByLabel = /* @__PURE__ */ new Map();
|
|
220
|
+
for (const s of parsed.sides) sideColorByLabel.set(s.label, s.color);
|
|
221
|
+
const sideBarH = layout.sideLabels.length ? 30 : 0;
|
|
222
|
+
const bandTop = sideBarH + 2;
|
|
223
|
+
const roundY = sideBarH + 24;
|
|
224
|
+
for (const col of layout.columns) {
|
|
225
|
+
if (!col.color) continue;
|
|
226
|
+
const covered = layout.sideLabels.some(
|
|
227
|
+
(s) => col.x >= s.x0 && col.x <= s.x1
|
|
228
|
+
);
|
|
229
|
+
const top = covered ? bandTop : 2;
|
|
230
|
+
const c = resolveColor(col.color, palette) ?? col.color;
|
|
231
|
+
root.append("rect").attr("x", col.x - BOX_W / 2 - 10).attr("y", top).attr("width", BOX_W + 20).attr("height", Math.max(0, layout.height - top)).attr("rx", 10).attr(
|
|
232
|
+
"fill",
|
|
233
|
+
fillMode === "outline" ? themeBaseBg(palette, isDark) : mix(c, palette.bg, isDark ? 12 : 8)
|
|
234
|
+
).call((sel) => {
|
|
235
|
+
if (fillMode === "outline")
|
|
236
|
+
sel.attr("stroke", mix(c, palette.bg, 35)).attr("stroke-width", 1);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
for (const s of layout.sideLabels) {
|
|
240
|
+
const c = s.color ? resolveColor(s.color, palette) ?? s.color : basePaint.accent;
|
|
241
|
+
root.append("rect").attr("x", s.x0 - 8).attr("y", 2).attr("width", s.x1 - s.x0 + 16).attr("height", 24).attr("rx", 8).attr(
|
|
242
|
+
"fill",
|
|
243
|
+
fillMode === "outline" ? themeBaseBg(palette, isDark) : mix(c, palette.bg, isDark ? 20 : 14)
|
|
244
|
+
).attr("stroke", fillMode === "outline" ? c : mix(c, palette.bg, 55)).attr("stroke-width", 1);
|
|
245
|
+
root.append("text").attr("x", (s.x0 + s.x1) / 2).attr("y", 18).attr("text-anchor", "middle").attr("font-size", 13).attr("font-weight", "bold").attr("letter-spacing", 0.3).attr("fill", c).text(clip(s.label, s.x1 - s.x0, 13, true));
|
|
246
|
+
}
|
|
247
|
+
for (const col of layout.columns) {
|
|
248
|
+
const c = col.color ? resolveColor(col.color, palette) ?? col.color : basePaint.muted;
|
|
249
|
+
const covered = layout.sideLabels.some(
|
|
250
|
+
(s) => col.x >= s.x0 && col.x <= s.x1
|
|
251
|
+
);
|
|
252
|
+
root.append("text").attr("x", col.x).attr("y", covered ? roundY : 22).attr("text-anchor", "middle").attr("font-size", covered ? 14 : 15).attr("font-weight", "bold").attr("fill", c).attr("letter-spacing", 0.4).text(clip(col.label, BOX_W + 20, covered ? 14 : 15, true));
|
|
253
|
+
}
|
|
254
|
+
for (const m of layout.matches) {
|
|
255
|
+
drawConnector(root, m, m.topFrom, m.y - HALF_SPAN, basePaint);
|
|
256
|
+
drawConnector(root, m, m.botFrom, m.y + HALF_SPAN, basePaint);
|
|
257
|
+
}
|
|
258
|
+
for (const m of layout.matches) {
|
|
259
|
+
const sidePaint = m.side && sideColorByLabel.get(m.side) ? paintFor(palette, isDark, sideColorByLabel.get(m.side), fillMode) : basePaint;
|
|
260
|
+
const topSeed = seedByName.get(m.top ?? "") ?? null;
|
|
261
|
+
const botSeed = seedByName.get(m.bot ?? "") ?? null;
|
|
262
|
+
let homeName = m.home;
|
|
263
|
+
if (!homeName && topSeed !== null && botSeed !== null) {
|
|
264
|
+
homeName = topSeed <= botSeed ? m.top : m.bot;
|
|
265
|
+
}
|
|
266
|
+
const [wSeed, lSeed] = m.winner === "top" ? [topSeed, botSeed] : m.winner === "bot" ? [botSeed, topSeed] : [null, null];
|
|
267
|
+
const isUpset = wSeed !== null && lSeed !== null && wSeed > lSeed && !m.isChampionship;
|
|
268
|
+
const scoreParts = m.score ? m.score.split(/[-–]/).map((p) => p.trim()) : null;
|
|
269
|
+
const winScore = scoreParts?.length === 2 ? scoreParts[0] : "";
|
|
270
|
+
const loseScore = scoreParts?.length === 2 ? scoreParts[1] : "";
|
|
271
|
+
const champWinner = m.isChampionship ? layout.champion : null;
|
|
272
|
+
const mkInfo = (side, name) => {
|
|
273
|
+
const isWinner = m.winner === side;
|
|
274
|
+
const isLoser = m.winner !== null && m.winner !== side;
|
|
275
|
+
return {
|
|
276
|
+
isWinner,
|
|
277
|
+
isLoser,
|
|
278
|
+
pending: m.pending,
|
|
279
|
+
isChampion: champWinner !== null && isWinner,
|
|
280
|
+
score: isWinner ? winScore : isLoser ? loseScore : "",
|
|
281
|
+
seed: seedByName.get(name ?? "") ?? null,
|
|
282
|
+
tagColor: tagColorOf(name),
|
|
283
|
+
tagValue: tagValueOf(name),
|
|
284
|
+
isHome: homeName !== null && homeName === name
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
drawBox(
|
|
288
|
+
root,
|
|
289
|
+
m.x,
|
|
290
|
+
m.y - HALF_SPAN,
|
|
291
|
+
m.top,
|
|
292
|
+
mkInfo("top", m.top),
|
|
293
|
+
sidePaint,
|
|
294
|
+
palette,
|
|
295
|
+
isDark,
|
|
296
|
+
m,
|
|
297
|
+
activeKey,
|
|
298
|
+
fillMode
|
|
299
|
+
);
|
|
300
|
+
drawBox(
|
|
301
|
+
root,
|
|
302
|
+
m.x,
|
|
303
|
+
m.y + HALF_SPAN,
|
|
304
|
+
m.bot,
|
|
305
|
+
mkInfo("bot", m.bot),
|
|
306
|
+
sidePaint,
|
|
307
|
+
palette,
|
|
308
|
+
isDark,
|
|
309
|
+
m,
|
|
310
|
+
activeKey,
|
|
311
|
+
fillMode
|
|
312
|
+
);
|
|
313
|
+
if (isUpset) drawUpset(root, m, sidePaint);
|
|
314
|
+
if (m.commentary.length) drawCommentary(root, m, palette);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function drawConnector(g, m, from, toCy, paint) {
|
|
318
|
+
if (!from) return;
|
|
319
|
+
const parentLeft = m.x - BOX_W / 2;
|
|
320
|
+
const parentRight = m.x + BOX_W / 2;
|
|
321
|
+
const childIsLeft = from.x < m.x;
|
|
322
|
+
const childEdge = childIsLeft ? from.x + BOX_W / 2 : from.x - BOX_W / 2;
|
|
323
|
+
const parentEdge = childIsLeft ? parentLeft : parentRight;
|
|
324
|
+
const midX = (childEdge + parentEdge) / 2;
|
|
325
|
+
const vLo = Math.min(from.yA, from.yB, toCy);
|
|
326
|
+
const vHi = Math.max(from.yA, from.yB, toCy);
|
|
327
|
+
const d = from.yA !== from.yB ? `M ${childEdge} ${from.yA} H ${midX} M ${childEdge} ${from.yB} H ${midX} M ${midX} ${vLo} V ${vHi} M ${midX} ${toCy} H ${parentEdge}` : `M ${childEdge} ${from.y} H ${midX} V ${toCy} H ${parentEdge}`;
|
|
328
|
+
g.append("path").attr("d", d).attr("fill", "none").attr("stroke", paint.wire).attr("stroke-width", 1.5);
|
|
329
|
+
}
|
|
330
|
+
function drawBox(g, cx, cy, name, info, sidePaint, palette, isDark, m, activeKey, fillMode) {
|
|
331
|
+
const x = cx - BOX_W / 2;
|
|
332
|
+
const y = cy - BOX_H / 2;
|
|
333
|
+
const paint = info.tagColor ? paintForAccent(palette, isDark, info.tagColor, fillMode) : sidePaint;
|
|
334
|
+
const cell = g.append("g").attr("class", "dgmo-bracket-box");
|
|
335
|
+
if (m.lineNumber !== null) cell.attr("data-line-number", m.lineNumber);
|
|
336
|
+
if (activeKey && info.tagValue)
|
|
337
|
+
cell.attr(`data-tag-${activeKey}`, info.tagValue.toLowerCase());
|
|
338
|
+
const isTBD = name === null;
|
|
339
|
+
let fill = "none";
|
|
340
|
+
let stroke = paint.hair;
|
|
341
|
+
let sw = 1.25;
|
|
342
|
+
let dash = null;
|
|
343
|
+
let textColor = paint.ink;
|
|
344
|
+
let weight = "bold";
|
|
345
|
+
if (info.isChampion) {
|
|
346
|
+
fill = paint.tint;
|
|
347
|
+
stroke = paint.accent;
|
|
348
|
+
sw = 3;
|
|
349
|
+
weight = "bold";
|
|
350
|
+
} else if (isTBD) {
|
|
351
|
+
fill = paint.track;
|
|
352
|
+
dash = "4 4";
|
|
353
|
+
textColor = paint.muted;
|
|
354
|
+
weight = "normal";
|
|
355
|
+
} else if (info.isWinner) {
|
|
356
|
+
fill = paint.tint;
|
|
357
|
+
stroke = paint.accent;
|
|
358
|
+
sw = 2;
|
|
359
|
+
weight = "bold";
|
|
360
|
+
} else if (info.isLoser) {
|
|
361
|
+
stroke = paint.hair;
|
|
362
|
+
textColor = paint.muted;
|
|
363
|
+
weight = "normal";
|
|
364
|
+
} else if (info.pending) {
|
|
365
|
+
stroke = mix(paint.accent, paint.hair, 50);
|
|
366
|
+
}
|
|
367
|
+
const onSolid = fillMode === "solid" && (info.isChampion || info.isWinner) ? contrastText(
|
|
368
|
+
paint.tint,
|
|
369
|
+
palette.textOnFillLight,
|
|
370
|
+
palette.textOnFillDark
|
|
371
|
+
) : null;
|
|
372
|
+
if (onSolid) textColor = onSolid;
|
|
373
|
+
const gutterColor = onSolid ?? paint.muted;
|
|
374
|
+
const rect = cell.append("rect").attr("x", x).attr("y", y).attr("width", BOX_W).attr("height", BOX_H).attr("rx", 6).attr("fill", fill).attr("stroke", stroke).attr("stroke-width", sw);
|
|
375
|
+
if (dash) rect.attr("stroke-dasharray", dash);
|
|
376
|
+
let leftPad = 11;
|
|
377
|
+
if (info.seed !== null) {
|
|
378
|
+
cell.append("text").attr("x", x + 9).attr("y", cy + 4).attr("text-anchor", "start").attr("font-size", 10).attr("font-weight", "bold").attr("fill", gutterColor).text(info.seed);
|
|
379
|
+
leftPad = 9 + Math.max(12, measureText(String(info.seed), 10, { bold: true })) + 6;
|
|
380
|
+
}
|
|
381
|
+
let rightPad = 11;
|
|
382
|
+
if (info.score) rightPad += 20;
|
|
383
|
+
if (info.isHome) {
|
|
384
|
+
drawHome(cell, x + BOX_W - rightPad - 6, cy, gutterColor);
|
|
385
|
+
rightPad += 16;
|
|
386
|
+
}
|
|
387
|
+
cell.append("text").attr("x", x + leftPad).attr("y", cy + 4).attr("text-anchor", "start").attr("font-size", 12.5).attr("font-weight", weight).attr("fill", textColor).text(
|
|
388
|
+
clip(
|
|
389
|
+
isTBD ? "TBD" : name,
|
|
390
|
+
BOX_W - leftPad - rightPad,
|
|
391
|
+
12.5,
|
|
392
|
+
weight === "bold"
|
|
393
|
+
)
|
|
394
|
+
);
|
|
395
|
+
if (info.score) {
|
|
396
|
+
cell.append("text").attr("x", x + BOX_W - 11).attr("y", cy + 4).attr("text-anchor", "end").attr("font-size", 12).attr("font-weight", info.isWinner ? "bold" : "normal").attr("fill", info.isWinner ? textColor : gutterColor).text(info.score);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function drawHome(cell, hx, cy, color) {
|
|
400
|
+
const s = 5;
|
|
401
|
+
const yTop = cy - s - 1;
|
|
402
|
+
const d = `M ${hx - s} ${cy - 1} L ${hx} ${yTop} L ${hx + s} ${cy - 1} L ${hx + s} ${cy + s} L ${hx - s} ${cy + s} Z`;
|
|
403
|
+
cell.append("path").attr("d", d).attr("fill", "none").attr("stroke", color).attr("stroke-width", 1.2).attr("stroke-linejoin", "round");
|
|
404
|
+
}
|
|
405
|
+
function drawUpset(g, m, paint) {
|
|
406
|
+
g.append("text").attr("x", m.x + BOX_W / 2).attr("y", m.y - HALF_SPAN - BOX_H / 2 - 4).attr("text-anchor", "end").attr("font-size", 9).attr("font-weight", "bold").attr("letter-spacing", 0.6).attr("fill", paint.accent).text("UPSET");
|
|
407
|
+
}
|
|
408
|
+
function drawCommentary(g, m, palette) {
|
|
409
|
+
const x = m.x - BOX_W / 2 + 2;
|
|
410
|
+
let y = m.y + HALF_SPAN + BOX_H / 2 + 13;
|
|
411
|
+
const muted = mix(palette.text, palette.bg, 45);
|
|
412
|
+
const bulletW = measureText("\u2022 ", 11);
|
|
413
|
+
const emit = (line, lx) => {
|
|
414
|
+
const t = g.append("text").attr("x", lx).attr("y", y).attr("text-anchor", "start").attr("font-size", 11).attr("font-style", "italic").attr("fill", muted);
|
|
415
|
+
renderInlineText(t, line, palette, 11);
|
|
416
|
+
y += COMMENT_LH;
|
|
417
|
+
};
|
|
418
|
+
for (const raw of m.commentary) {
|
|
419
|
+
const isBullet = raw.startsWith("\u2022 ");
|
|
420
|
+
if (isBullet) {
|
|
421
|
+
const body = raw.slice(2);
|
|
422
|
+
wrapText(body, COMMENT_W - bulletW, 11).forEach(
|
|
423
|
+
(line, i) => i === 0 ? emit(`\u2022 ${line}`, x) : emit(line, x + bulletW)
|
|
424
|
+
);
|
|
425
|
+
} else {
|
|
426
|
+
for (const line of wrapText(raw, COMMENT_W, 11)) emit(line, x);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function renderBracketForExport(container, parsed, palette, isDark, exportDims) {
|
|
431
|
+
renderBracket(container, parsed, palette, isDark, exportDims);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export {
|
|
435
|
+
bracketExportDimensions,
|
|
436
|
+
renderBracket,
|
|
437
|
+
renderBracketForExport
|
|
438
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
} from "./chunk-Z6DXWULM.js";
|
|
15
15
|
import {
|
|
16
16
|
render
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-VW52W5F6.js";
|
|
18
|
+
import "./chunk-ABP5BUD6.js";
|
|
18
19
|
import {
|
|
19
20
|
renderErrorCard
|
|
20
21
|
} from "./chunk-D4M25W6R.js";
|
|
@@ -37,7 +38,7 @@ import "./chunk-KMU65FYM.js";
|
|
|
37
38
|
import "./chunk-EPDBWATV.js";
|
|
38
39
|
import "./chunk-7UDAIP6W.js";
|
|
39
40
|
import "./chunk-2CW5ZTNH.js";
|
|
40
|
-
import "./chunk-
|
|
41
|
+
import "./chunk-JLETTWUJ.js";
|
|
41
42
|
import "./chunk-YRYKTYMQ.js";
|
|
42
43
|
import "./chunk-24YPR5EH.js";
|
|
43
44
|
import {
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
focusEventLine,
|
|
4
4
|
renderEventLine,
|
|
5
5
|
renderEventLineForExport
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5LD7SHXO.js";
|
|
7
7
|
import "./chunk-NPWVOFB3.js";
|
|
8
8
|
import "./chunk-R2K5L4UA.js";
|
|
9
9
|
import "./chunk-S7W75MIM.js";
|
|
10
10
|
import "./chunk-Z6DXWULM.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-JLETTWUJ.js";
|
|
12
12
|
import "./chunk-YRYKTYMQ.js";
|
|
13
13
|
import "./chunk-24YPR5EH.js";
|
|
14
14
|
import "./chunk-XCKNFFKM.js";
|
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
bracketExportDimensions,
|
|
3
3
|
renderBracket,
|
|
4
4
|
renderBracketForExport
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WXPBP4IT.js";
|
|
6
6
|
import "./chunk-S7W75MIM.js";
|
|
7
7
|
import "./chunk-Z6DXWULM.js";
|
|
8
|
+
import "./chunk-ABP5BUD6.js";
|
|
8
9
|
import "./chunk-3DOQOXXI.js";
|
|
9
10
|
import "./chunk-VLC6WNRD.js";
|
|
10
11
|
import "./chunk-LHL6HDUL.js";
|