courthive-components 6.8.2 → 6.9.1
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/README.md +27 -11
- package/dist/components/availability-grid/controller/availabilityGridControl.d.ts +5 -2
- package/dist/components/availability-grid/ui/availabilityGrid.d.ts +1 -0
- package/dist/components/categories/ageCategory/ageCategory.d.ts +1 -0
- package/dist/components/matchUpFormat/matchUpFormat.d.ts +1 -0
- package/dist/components/modal/cmodal.d.ts +2 -1
- package/dist/components/modal/scheduleCellConfigModal.d.ts +1 -0
- package/dist/components/scoring/scoreEntryCard.d.ts +2 -0
- package/dist/courthive-components.es.js +7775 -7686
- package/dist/courthive-components.umd.js +52 -52
- package/dist/courts.mjs +375 -0
- package/dist/features-types/courts/courtSvgUtil.d.ts +10 -0
- package/dist/features-types/courts/courts.d.ts +7 -0
- package/dist/features-types/courts/index.d.ts +3 -0
- package/dist/features-types/segmentedBar/buildSegmentedBar.d.ts +27 -0
- package/dist/features-types/segmentedBar/index.d.ts +5 -0
- package/dist/features.css +2 -0
- package/dist/helpers/createTypeAhead.d.ts +8 -0
- package/dist/helpers/drawStateManager.d.ts +42 -67
- package/dist/helpers/escapeHtml.d.ts +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/segmented-bar.mjs +27 -0
- package/package.json +16 -6
package/dist/courts.mjs
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
//#region src/components/courts/courts.ts
|
|
2
|
+
var e = "court-line";
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
let n = document.createElementNS("http://www.w3.org/2000/svg", e);
|
|
5
|
+
for (let [e, r] of Object.entries(t)) n.setAttribute(e, r);
|
|
6
|
+
return n;
|
|
7
|
+
}
|
|
8
|
+
function n(e, t) {
|
|
9
|
+
let n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
10
|
+
return n.setAttribute("viewBox", e), n.setAttribute("class", t), n.setAttribute("fill", "none"), n.style.width = "100%", n.style.height = "auto", n.style.display = "block", n;
|
|
11
|
+
}
|
|
12
|
+
function r(r) {
|
|
13
|
+
let i = n("0 0 360 780", r);
|
|
14
|
+
for (let n of [
|
|
15
|
+
"M 0 0 L 360 0 L 360 780 L 0 780 Z",
|
|
16
|
+
"M 45 0 L 45 780",
|
|
17
|
+
"M 315 0 L 315 780",
|
|
18
|
+
"M 0 390 L 360 390",
|
|
19
|
+
"M 45 210 L 315 210",
|
|
20
|
+
"M 45 570 L 315 570",
|
|
21
|
+
"M 180 210 L 180 570",
|
|
22
|
+
"M 180 0 L 180 20",
|
|
23
|
+
"M 180 760 L 180 780"
|
|
24
|
+
]) i.appendChild(t("path", {
|
|
25
|
+
d: n,
|
|
26
|
+
class: e
|
|
27
|
+
}));
|
|
28
|
+
return i;
|
|
29
|
+
}
|
|
30
|
+
function i(r) {
|
|
31
|
+
let i = n("0 0 500 470", r), a = [
|
|
32
|
+
t("rect", {
|
|
33
|
+
x: "0",
|
|
34
|
+
y: "0",
|
|
35
|
+
width: "500",
|
|
36
|
+
height: "470",
|
|
37
|
+
class: e
|
|
38
|
+
}),
|
|
39
|
+
t("circle", {
|
|
40
|
+
cx: "250",
|
|
41
|
+
cy: "470",
|
|
42
|
+
r: "60",
|
|
43
|
+
class: e
|
|
44
|
+
}),
|
|
45
|
+
t("line", {
|
|
46
|
+
x1: "0",
|
|
47
|
+
y1: "470",
|
|
48
|
+
x2: "500",
|
|
49
|
+
y2: "470",
|
|
50
|
+
class: e
|
|
51
|
+
}),
|
|
52
|
+
t("rect", {
|
|
53
|
+
x: "170",
|
|
54
|
+
y: "0",
|
|
55
|
+
width: "160",
|
|
56
|
+
height: "190",
|
|
57
|
+
class: e
|
|
58
|
+
}),
|
|
59
|
+
t("circle", {
|
|
60
|
+
cx: "250",
|
|
61
|
+
cy: "190",
|
|
62
|
+
r: "60",
|
|
63
|
+
class: e
|
|
64
|
+
}),
|
|
65
|
+
t("line", {
|
|
66
|
+
x1: "220",
|
|
67
|
+
y1: "40",
|
|
68
|
+
x2: "280",
|
|
69
|
+
y2: "40",
|
|
70
|
+
class: e
|
|
71
|
+
}),
|
|
72
|
+
t("circle", {
|
|
73
|
+
cx: "250",
|
|
74
|
+
cy: "52",
|
|
75
|
+
r: "12",
|
|
76
|
+
class: e
|
|
77
|
+
}),
|
|
78
|
+
t("path", {
|
|
79
|
+
d: "M 30 0 L 30 90 A 220 220 0 0 0 470 90 L 470 0",
|
|
80
|
+
class: e
|
|
81
|
+
})
|
|
82
|
+
];
|
|
83
|
+
for (let e of a) i.appendChild(e);
|
|
84
|
+
return i;
|
|
85
|
+
}
|
|
86
|
+
function a(r) {
|
|
87
|
+
let i = n("0 0 500 440", r), a = [
|
|
88
|
+
t("path", {
|
|
89
|
+
d: "M 20 170 A 350 400 0 0 1 480 170",
|
|
90
|
+
class: e
|
|
91
|
+
}),
|
|
92
|
+
t("line", {
|
|
93
|
+
x1: "250",
|
|
94
|
+
y1: "400",
|
|
95
|
+
x2: "20",
|
|
96
|
+
y2: "170",
|
|
97
|
+
class: e
|
|
98
|
+
}),
|
|
99
|
+
t("line", {
|
|
100
|
+
x1: "250",
|
|
101
|
+
y1: "400",
|
|
102
|
+
x2: "480",
|
|
103
|
+
y2: "170",
|
|
104
|
+
class: e
|
|
105
|
+
}),
|
|
106
|
+
t("path", {
|
|
107
|
+
d: "M 250 400 L 314 336 L 250 273 L 186 336 Z",
|
|
108
|
+
class: e
|
|
109
|
+
}),
|
|
110
|
+
t("path", {
|
|
111
|
+
d: "M 340 355 A 100 100 0 0 1 160 355",
|
|
112
|
+
class: e
|
|
113
|
+
}),
|
|
114
|
+
t("line", {
|
|
115
|
+
x1: "340",
|
|
116
|
+
y1: "355",
|
|
117
|
+
x2: "265",
|
|
118
|
+
y2: "405",
|
|
119
|
+
class: e
|
|
120
|
+
}),
|
|
121
|
+
t("line", {
|
|
122
|
+
x1: "160",
|
|
123
|
+
y1: "355",
|
|
124
|
+
x2: "235",
|
|
125
|
+
y2: "405",
|
|
126
|
+
class: e
|
|
127
|
+
}),
|
|
128
|
+
t("path", {
|
|
129
|
+
d: "M 235 405 A 18 18 0 0 1 265 405",
|
|
130
|
+
class: e
|
|
131
|
+
}),
|
|
132
|
+
t("circle", {
|
|
133
|
+
cx: "250",
|
|
134
|
+
cy: "340",
|
|
135
|
+
r: "9",
|
|
136
|
+
class: e
|
|
137
|
+
}),
|
|
138
|
+
t("line", {
|
|
139
|
+
x1: "247",
|
|
140
|
+
y1: "339",
|
|
141
|
+
x2: "253",
|
|
142
|
+
y2: "339",
|
|
143
|
+
class: e
|
|
144
|
+
}),
|
|
145
|
+
t("path", {
|
|
146
|
+
d: "M 244 398 L 244 404 L 250 408 L 256 404 L 256 398 Z",
|
|
147
|
+
class: e
|
|
148
|
+
}),
|
|
149
|
+
t("rect", {
|
|
150
|
+
x: "310",
|
|
151
|
+
y: "332",
|
|
152
|
+
width: "8",
|
|
153
|
+
height: "8",
|
|
154
|
+
transform: "rotate(45 314 336)",
|
|
155
|
+
class: e
|
|
156
|
+
}),
|
|
157
|
+
t("rect", {
|
|
158
|
+
x: "246",
|
|
159
|
+
y: "269",
|
|
160
|
+
width: "8",
|
|
161
|
+
height: "8",
|
|
162
|
+
transform: "rotate(45 250 273)",
|
|
163
|
+
class: e
|
|
164
|
+
}),
|
|
165
|
+
t("rect", {
|
|
166
|
+
x: "182",
|
|
167
|
+
y: "332",
|
|
168
|
+
width: "8",
|
|
169
|
+
height: "8",
|
|
170
|
+
transform: "rotate(45 186 336)",
|
|
171
|
+
class: e
|
|
172
|
+
}),
|
|
173
|
+
t("rect", {
|
|
174
|
+
x: "230",
|
|
175
|
+
y: "393",
|
|
176
|
+
width: "8",
|
|
177
|
+
height: "18",
|
|
178
|
+
class: e
|
|
179
|
+
}),
|
|
180
|
+
t("rect", {
|
|
181
|
+
x: "262",
|
|
182
|
+
y: "393",
|
|
183
|
+
width: "8",
|
|
184
|
+
height: "18",
|
|
185
|
+
class: e
|
|
186
|
+
})
|
|
187
|
+
];
|
|
188
|
+
for (let e of a) i.appendChild(e);
|
|
189
|
+
return i;
|
|
190
|
+
}
|
|
191
|
+
function o(r) {
|
|
192
|
+
let i = n("0 0 850 2000", r), a = [
|
|
193
|
+
t("rect", {
|
|
194
|
+
x: "0",
|
|
195
|
+
y: "0",
|
|
196
|
+
width: "850",
|
|
197
|
+
height: "2000",
|
|
198
|
+
rx: "280",
|
|
199
|
+
ry: "280",
|
|
200
|
+
class: e
|
|
201
|
+
}),
|
|
202
|
+
t("line", {
|
|
203
|
+
x1: "0",
|
|
204
|
+
y1: "1000",
|
|
205
|
+
x2: "850",
|
|
206
|
+
y2: "1000",
|
|
207
|
+
class: e
|
|
208
|
+
}),
|
|
209
|
+
t("circle", {
|
|
210
|
+
cx: "425",
|
|
211
|
+
cy: "1000",
|
|
212
|
+
r: "60",
|
|
213
|
+
class: e
|
|
214
|
+
}),
|
|
215
|
+
t("line", {
|
|
216
|
+
x1: "0",
|
|
217
|
+
y1: "650",
|
|
218
|
+
x2: "850",
|
|
219
|
+
y2: "650",
|
|
220
|
+
class: e
|
|
221
|
+
}),
|
|
222
|
+
t("line", {
|
|
223
|
+
x1: "0",
|
|
224
|
+
y1: "1350",
|
|
225
|
+
x2: "850",
|
|
226
|
+
y2: "1350",
|
|
227
|
+
class: e
|
|
228
|
+
}),
|
|
229
|
+
t("line", {
|
|
230
|
+
x1: "140",
|
|
231
|
+
y1: "300",
|
|
232
|
+
x2: "710",
|
|
233
|
+
y2: "300",
|
|
234
|
+
class: e
|
|
235
|
+
}),
|
|
236
|
+
t("line", {
|
|
237
|
+
x1: "140",
|
|
238
|
+
y1: "1700",
|
|
239
|
+
x2: "710",
|
|
240
|
+
y2: "1700",
|
|
241
|
+
class: e
|
|
242
|
+
}),
|
|
243
|
+
t("path", {
|
|
244
|
+
d: "M 395 300 A 40 40 0 0 1 455 300",
|
|
245
|
+
class: e
|
|
246
|
+
}),
|
|
247
|
+
t("path", {
|
|
248
|
+
d: "M 395 1700 A 40 40 0 0 0 455 1700",
|
|
249
|
+
class: e
|
|
250
|
+
}),
|
|
251
|
+
t("circle", {
|
|
252
|
+
cx: "270",
|
|
253
|
+
cy: "650",
|
|
254
|
+
r: "50",
|
|
255
|
+
class: e
|
|
256
|
+
}),
|
|
257
|
+
t("circle", {
|
|
258
|
+
cx: "580",
|
|
259
|
+
cy: "650",
|
|
260
|
+
r: "50",
|
|
261
|
+
class: e
|
|
262
|
+
}),
|
|
263
|
+
t("circle", {
|
|
264
|
+
cx: "270",
|
|
265
|
+
cy: "1350",
|
|
266
|
+
r: "50",
|
|
267
|
+
class: e
|
|
268
|
+
}),
|
|
269
|
+
t("circle", {
|
|
270
|
+
cx: "580",
|
|
271
|
+
cy: "1350",
|
|
272
|
+
r: "50",
|
|
273
|
+
class: e
|
|
274
|
+
})
|
|
275
|
+
];
|
|
276
|
+
for (let e of a) i.appendChild(e);
|
|
277
|
+
return i;
|
|
278
|
+
}
|
|
279
|
+
function s(r) {
|
|
280
|
+
let i = n("0 0 200 440", r);
|
|
281
|
+
for (let n of [
|
|
282
|
+
"M 0 0 L 200 0 L 200 440 L 0 440 Z",
|
|
283
|
+
"M 0 220 L 200 220",
|
|
284
|
+
"M 0 150 L 200 150",
|
|
285
|
+
"M 0 290 L 200 290",
|
|
286
|
+
"M 100 0 L 100 150",
|
|
287
|
+
"M 100 290 L 100 440"
|
|
288
|
+
]) i.appendChild(t("path", {
|
|
289
|
+
d: n,
|
|
290
|
+
class: e
|
|
291
|
+
}));
|
|
292
|
+
return i;
|
|
293
|
+
}
|
|
294
|
+
function c(r) {
|
|
295
|
+
let i = n("0 0 200 440", r);
|
|
296
|
+
for (let n of [
|
|
297
|
+
"M 0 0 L 200 0 L 200 440 L 0 440 Z",
|
|
298
|
+
"M 18 0 L 18 440",
|
|
299
|
+
"M 182 0 L 182 440",
|
|
300
|
+
"M 0 220 L 200 220",
|
|
301
|
+
"M 0 146 L 200 146",
|
|
302
|
+
"M 0 294 L 200 294",
|
|
303
|
+
"M 0 30 L 200 30",
|
|
304
|
+
"M 0 410 L 200 410",
|
|
305
|
+
"M 100 146 L 100 220",
|
|
306
|
+
"M 100 220 L 100 294"
|
|
307
|
+
]) i.appendChild(t("path", {
|
|
308
|
+
d: n,
|
|
309
|
+
class: e
|
|
310
|
+
}));
|
|
311
|
+
return i;
|
|
312
|
+
}
|
|
313
|
+
function l(r) {
|
|
314
|
+
let i = n("0 0 100 200", r);
|
|
315
|
+
for (let n of [
|
|
316
|
+
"M 0 0 L 100 0 L 100 200 L 0 200 Z",
|
|
317
|
+
"M 0 100 L 100 100",
|
|
318
|
+
"M 0 69.5 L 100 69.5",
|
|
319
|
+
"M 0 130.5 L 100 130.5",
|
|
320
|
+
"M 50 69.5 L 50 67.5",
|
|
321
|
+
"M 50 130.5 L 50 132.5"
|
|
322
|
+
]) i.appendChild(t("path", {
|
|
323
|
+
d: n,
|
|
324
|
+
class: e
|
|
325
|
+
}));
|
|
326
|
+
return i;
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/components/courts/courtSvgUtil.ts
|
|
330
|
+
var u = "COURT_SVG", d = {
|
|
331
|
+
tennis: r,
|
|
332
|
+
basketball: i,
|
|
333
|
+
baseball: a,
|
|
334
|
+
hockey: o,
|
|
335
|
+
pickleball: s,
|
|
336
|
+
badminton: c,
|
|
337
|
+
padel: l
|
|
338
|
+
}, f = {
|
|
339
|
+
TENNIS: "tennis",
|
|
340
|
+
PADEL: "padel",
|
|
341
|
+
PICKLEBALL: "pickleball",
|
|
342
|
+
BADMINTON: "badminton"
|
|
343
|
+
}, p = {
|
|
344
|
+
HAL: "basketball",
|
|
345
|
+
INN: "baseball",
|
|
346
|
+
PER: "hockey"
|
|
347
|
+
};
|
|
348
|
+
function m(e) {
|
|
349
|
+
if (e) {
|
|
350
|
+
for (let [t, n] of Object.entries(p)) if (e.startsWith(t)) return n;
|
|
351
|
+
if (e.startsWith("SET") || e.startsWith("T")) return e.includes("@RALLY") ? "pickleball" : "tennis";
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function h(e) {
|
|
355
|
+
let t = e?.competitionFormat?.sport;
|
|
356
|
+
return t && f[t] ? f[t] : m(e?.matchUpFormat);
|
|
357
|
+
}
|
|
358
|
+
function g(e) {
|
|
359
|
+
let t = e.getAttribute("viewBox");
|
|
360
|
+
if (!t) return e;
|
|
361
|
+
let n = t.split(/\s+/).map(Number);
|
|
362
|
+
if (n.length !== 4) return e;
|
|
363
|
+
let [r, i, a, o] = n;
|
|
364
|
+
if (o <= a) return e;
|
|
365
|
+
e.setAttribute("viewBox", `${r} ${i} ${o} ${a}`);
|
|
366
|
+
let s = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
367
|
+
for (s.setAttribute("transform", `translate(${o}, 0) rotate(90)`); e.firstChild;) s.appendChild(e.firstChild);
|
|
368
|
+
return e.appendChild(s), e;
|
|
369
|
+
}
|
|
370
|
+
function _(e, t = "") {
|
|
371
|
+
let n = e ? d[e] : void 0;
|
|
372
|
+
if (n) return g(n(t ? `court--${e} ${t}` : `court--${e}`));
|
|
373
|
+
}
|
|
374
|
+
//#endregion
|
|
375
|
+
export { u as COURT_SVG_RESOURCE_SUB_TYPE, c as badmintonCourt, a as baseballDiamond, i as basketballCourt, _ as createCourtSvg, o as hockeyRink, l as padelCourt, s as pickleballCourt, h as resolveCourtSport, m as sportFromMatchUpFormat, r as tennisCourt };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps sport identifiers to court SVG factories and resolves a sport from
|
|
3
|
+
* factory event / matchUpFormat shapes. Shared by TMX, courthive-public, and
|
|
4
|
+
* any other consumer that wants to render a court SVG image.
|
|
5
|
+
*/
|
|
6
|
+
export type CourtSport = 'tennis' | 'basketball' | 'baseball' | 'hockey' | 'pickleball' | 'badminton' | 'padel';
|
|
7
|
+
export declare const COURT_SVG_RESOURCE_SUB_TYPE = "COURT_SVG";
|
|
8
|
+
export declare function sportFromMatchUpFormat(matchUpFormat?: string): CourtSport | undefined;
|
|
9
|
+
export declare function resolveCourtSport(event?: any): CourtSport | undefined;
|
|
10
|
+
export declare function createCourtSvg(sport: string | undefined, className?: string): SVGSVGElement | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function tennisCourt(className: string): SVGSVGElement;
|
|
2
|
+
export declare function basketballCourt(className: string): SVGSVGElement;
|
|
3
|
+
export declare function baseballDiamond(className: string): SVGSVGElement;
|
|
4
|
+
export declare function hockeyRink(className: string): SVGSVGElement;
|
|
5
|
+
export declare function pickleballCourt(className: string): SVGSVGElement;
|
|
6
|
+
export declare function badmintonCourt(className: string): SVGSVGElement;
|
|
7
|
+
export declare function padelCourt(className: string): SVGSVGElement;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { tennisCourt, basketballCourt, baseballDiamond, hockeyRink, pickleballCourt, badmintonCourt, padelCourt } from './courts';
|
|
2
|
+
export { createCourtSvg, resolveCourtSport, sportFromMatchUpFormat, COURT_SVG_RESOURCE_SUB_TYPE } from './courtSvgUtil';
|
|
3
|
+
export type { CourtSport } from './courtSvgUtil';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segmented Bar — generic DOM factory.
|
|
3
|
+
*
|
|
4
|
+
* A configurable sibling of the competitiveness bar: given a list of segment
|
|
5
|
+
* definitions (key + label + color), it returns an element plus an
|
|
6
|
+
* `update(counts)` callback. Each non-zero segment renders as a flex-grow
|
|
7
|
+
* band whose count appears centered. When `onSegmentClick` is supplied the
|
|
8
|
+
* segments become clickable filter drivers and `setActive(key)` highlights
|
|
9
|
+
* the selected segment (dimming the rest).
|
|
10
|
+
*
|
|
11
|
+
* The element is hidden (display:none) until the first update with total > 0.
|
|
12
|
+
*/
|
|
13
|
+
export interface SegmentDef {
|
|
14
|
+
key: string;
|
|
15
|
+
label: string;
|
|
16
|
+
color: string;
|
|
17
|
+
}
|
|
18
|
+
export interface BuildSegmentedBarOptions {
|
|
19
|
+
segments: SegmentDef[];
|
|
20
|
+
onSegmentClick?: (key: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface BuildSegmentedBarResult {
|
|
23
|
+
element: HTMLElement;
|
|
24
|
+
update: (counts: Record<string, number>) => void;
|
|
25
|
+
setActive: (key: string | null) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare function buildSegmentedBar(options: BuildSegmentedBarOptions): BuildSegmentedBarResult;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.court-line{stroke:#505ab4b3;stroke-width:1.5px;fill:none;vector-effect:non-scaling-stroke}.court--tennis .court-line{stroke:#3c50c8cc}.court--basketball .court-line{stroke:#b450c8b3}.court--baseball .court-line{stroke:#c83246b3}.court--hockey .court-line{stroke:#1e78d2bf}.court--pickleball .court-line{stroke:#14a046b3}.court--badminton .court-line{stroke:#00b4a0b3}.court--padel .court-line{stroke:#c88214bf}@media (prefers-color-scheme:dark){:root:not([data-theme]) .court-line{stroke:#7882ff80}:root:not([data-theme]) .court--tennis .court-line{stroke:#667eea99}:root:not([data-theme]) .court--basketball .court-line{stroke:#f093fb80}:root:not([data-theme]) .court--baseball .court-line{stroke:#f5576c80}:root:not([data-theme]) .court--hockey .court-line{stroke:#4facfe8c}:root:not([data-theme]) .court--pickleball .court-line{stroke:#43e97b80}:root:not([data-theme]) .court--badminton .court-line{stroke:#38f9d780}:root:not([data-theme]) .court--padel .court-line{stroke:#ffb74d8c}}[data-theme=dark] .court-line{stroke:#7882ff80}[data-theme=dark] .court--tennis .court-line{stroke:#667eea99}[data-theme=dark] .court--basketball .court-line{stroke:#f093fb80}[data-theme=dark] .court--baseball .court-line{stroke:#f5576c80}[data-theme=dark] .court--hockey .court-line{stroke:#4facfe8c}[data-theme=dark] .court--pickleball .court-line{stroke:#43e97b80}[data-theme=dark] .court--badminton .court-line{stroke:#38f9d780}[data-theme=dark] .court--padel .court-line{stroke:#ffb74d8c}.chc-sb{flex-direction:row;align-items:stretch;gap:2px;min-width:0;height:1.5em;display:none;overflow:hidden}.chc-sb__seg{background:var(--seg-bg,var(--chc-text-muted,#6b7280));color:#fff;border-radius:2px;flex:0 0 0;justify-content:center;align-items:center;min-width:0;padding:0;font-size:.85em;font-weight:600;line-height:1;transition:opacity .15s;display:flex;overflow:hidden}.chc-sb__seg.is-clickable{cursor:pointer}.chc-sb__seg.is-clickable:hover{filter:brightness(1.1)}.chc-sb.has-active .chc-sb__seg:not(.is-active){opacity:.35}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -35,6 +35,14 @@ type CreateTypeAheadParams = {
|
|
|
35
35
|
* Exported for unit testing; the wiring below is the only production caller.
|
|
36
36
|
*/
|
|
37
37
|
export declare function resolveCurrentLabel(list: any[], code?: string): string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Awesomplete's default item renderer builds each suggestion with innerHTML (to wrap matches in
|
|
40
|
+
* <mark>), so a suggestion label holding markup — a participant name, say — would run as script.
|
|
41
|
+
* This renders the same structure from text nodes. Awesomplete calls it with itself as `this`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function typeAheadItem(this: {
|
|
44
|
+
count?: number;
|
|
45
|
+
} | undefined, text: unknown, input: string, itemId: number): HTMLLIElement;
|
|
38
46
|
export declare function createTypeAhead({ list, element, callback, currentCode, currentValue, warnUnresolved, withCatchTab, onChange, onSelectComplete, listProvider }: CreateTypeAheadParams): {
|
|
39
47
|
typeAhead: any;
|
|
40
48
|
};
|
|
@@ -1,89 +1,64 @@
|
|
|
1
|
+
import { Tournament } from 'tods-competition-factory';
|
|
1
2
|
import { Participant } from '../types';
|
|
2
3
|
export type RenderCallback = () => void;
|
|
4
|
+
export type DrawAssignmentMethod = 'assignDrawPosition' | 'assignDrawPositionBye' | 'removeDrawPositionAssignment';
|
|
5
|
+
export interface DrawAssignmentParams {
|
|
6
|
+
drawId: string;
|
|
7
|
+
structureId: string;
|
|
8
|
+
drawPosition: number;
|
|
9
|
+
participantId?: string;
|
|
10
|
+
qualifier?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface DrawAssignmentResult {
|
|
13
|
+
success?: boolean;
|
|
14
|
+
error?: unknown;
|
|
15
|
+
/** The host accepted an asynchronous request; no assignment has been acknowledged yet. */
|
|
16
|
+
pending?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface DrawStateAdapter {
|
|
19
|
+
/** Query current state on every use; never reinstall an opening snapshot. */
|
|
20
|
+
getTournamentRecord: () => Tournament | undefined;
|
|
21
|
+
/** Apply once, then acknowledge. Only a successful acknowledgement changes focus/renders. */
|
|
22
|
+
mutate: (method: DrawAssignmentMethod, params: DrawAssignmentParams, callback: (result: DrawAssignmentResult) => void) => void;
|
|
23
|
+
}
|
|
3
24
|
export declare class DrawStateManager {
|
|
4
|
-
private
|
|
25
|
+
private readonly adapter;
|
|
5
26
|
private readonly drawId;
|
|
6
27
|
private readonly structureId;
|
|
7
|
-
private readonly eventId
|
|
28
|
+
private readonly eventId?;
|
|
8
29
|
private renderCallback?;
|
|
9
30
|
private focusDrawPosition?;
|
|
10
|
-
constructor({ tournamentRecord, drawId, structureId, eventId }: {
|
|
11
|
-
tournamentRecord
|
|
31
|
+
constructor({ tournamentRecord, adapter, drawId, structureId, eventId }: {
|
|
32
|
+
tournamentRecord?: Tournament;
|
|
33
|
+
adapter?: DrawStateAdapter;
|
|
12
34
|
drawId: string;
|
|
13
35
|
structureId: string;
|
|
14
36
|
eventId?: string;
|
|
15
37
|
});
|
|
16
|
-
/**
|
|
17
|
-
* Set callback to trigger re-render when state changes
|
|
18
|
-
*/
|
|
19
38
|
setRenderCallback(callback: RenderCallback): void;
|
|
20
|
-
|
|
21
|
-
* Get participant IDs from draw entries (via flight profile or drawDefinition.entries)
|
|
22
|
-
*/
|
|
23
|
-
private getDrawEntryParticipantIds;
|
|
24
|
-
/**
|
|
25
|
-
* Get participants entered in the draw (including qualifiers)
|
|
26
|
-
*/
|
|
39
|
+
private context;
|
|
27
40
|
getAllParticipants(): Participant[];
|
|
28
|
-
/**
|
|
29
|
-
* Get participants that haven't been assigned to draw positions yet
|
|
30
|
-
*/
|
|
31
41
|
getAvailableParticipants(): Participant[];
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
drawPosition: number;
|
|
37
|
-
}): {
|
|
38
|
-
success: boolean;
|
|
39
|
-
error?: any;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Assign a participant to a specific draw position
|
|
43
|
-
* Note: Direct assignment replaces existing assignment (even with scores)
|
|
44
|
-
*/
|
|
45
|
-
assignParticipant({ drawPosition, participantId }: {
|
|
42
|
+
/** A request is pending until the host acknowledges it. Refusals do not advance focus or render. */
|
|
43
|
+
private request;
|
|
44
|
+
/** Factory validation controls replacement, including assignments with recorded scores. */
|
|
45
|
+
assignParticipant(params: {
|
|
46
46
|
drawPosition: number;
|
|
47
47
|
participantId: string;
|
|
48
|
-
}):
|
|
49
|
-
|
|
50
|
-
error?: any;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Get and clear the drawPosition that should receive focus
|
|
54
|
-
*/
|
|
55
|
-
getAndClearFocusDrawPosition(): number | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Assign a BYE to a specific draw position
|
|
58
|
-
* Note: Direct assignment replaces existing assignment (even with scores)
|
|
59
|
-
*/
|
|
60
|
-
assignBye({ drawPosition }: {
|
|
48
|
+
}): DrawAssignmentResult;
|
|
49
|
+
assignBye(params: {
|
|
61
50
|
drawPosition: number;
|
|
62
|
-
}):
|
|
63
|
-
|
|
64
|
-
error?: any;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Assign a QUALIFIER placeholder to a specific draw position
|
|
68
|
-
* Note: Used when structure has qualifying stage feeding into it
|
|
69
|
-
*/
|
|
70
|
-
assignQualifier({ drawPosition }: {
|
|
51
|
+
}): DrawAssignmentResult;
|
|
52
|
+
assignQualifier(params: {
|
|
71
53
|
drawPosition: number;
|
|
72
|
-
}):
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
* Get all matchUps for the draw with properly populated drawPosition data
|
|
78
|
-
*/
|
|
54
|
+
}): DrawAssignmentResult;
|
|
55
|
+
removeAssignment(params: {
|
|
56
|
+
drawPosition: number;
|
|
57
|
+
}): DrawAssignmentResult;
|
|
58
|
+
getAndClearFocusDrawPosition(): number | undefined;
|
|
79
59
|
getMatchUps(): any[];
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
*/
|
|
83
|
-
getState(): any;
|
|
84
|
-
/**
|
|
85
|
-
* Get draw context information
|
|
86
|
-
*/
|
|
60
|
+
/** A copy of the current record. Asynchronous hosts are queried at call time. */
|
|
61
|
+
getState(): Tournament | undefined;
|
|
87
62
|
getContext(): {
|
|
88
63
|
drawId: string;
|
|
89
64
|
structureId: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes a value for interpolation into HTML text or a quoted attribute. Record data (names,
|
|
3
|
+
* notes, addresses) comes from servers, integrators and imported files, so it must never be
|
|
4
|
+
* parsed as markup. Prefer `textContent` where an element holds only the value; use this where
|
|
5
|
+
* the value sits inside a larger HTML template.
|
|
6
|
+
*/
|
|
7
|
+
export declare function escapeHtml(value: unknown): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -83,6 +83,8 @@ export { renderMenu } from './components/forms/renderMenu';
|
|
|
83
83
|
export { validator } from './components/forms/renderValidator';
|
|
84
84
|
export * as validators from './validators';
|
|
85
85
|
export { DrawStateManager } from './helpers/drawStateManager';
|
|
86
|
+
export { escapeHtml } from './helpers/escapeHtml';
|
|
87
|
+
export type { DrawStateAdapter, DrawAssignmentMethod, DrawAssignmentParams, DrawAssignmentResult } from './helpers/drawStateManager';
|
|
86
88
|
export type { RenderCallback } from './helpers/drawStateManager';
|
|
87
89
|
export { wrapSearchWithClear, syncClearVisibility } from './helpers/searchClearButton';
|
|
88
90
|
export { burstChart } from './components/burstChart/burstChart';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/components/segmentedBar/buildSegmentedBar.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let { segments: t, onSegmentClick: n } = e, r = document.createElement("div");
|
|
4
|
+
r.className = "chc-sb";
|
|
5
|
+
let i = {}, a = {};
|
|
6
|
+
for (let { key: e, label: o, color: s } of t) {
|
|
7
|
+
i[e] = o;
|
|
8
|
+
let t = document.createElement("div");
|
|
9
|
+
t.className = "chc-sb__seg", t.dataset.key = e, t.style.setProperty("--seg-bg", s), n && (t.classList.add("is-clickable"), t.setAttribute("role", "button"), t.addEventListener("click", () => n(e))), a[e] = t, r.appendChild(t);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
element: r,
|
|
13
|
+
update: (e) => {
|
|
14
|
+
let n = t.reduce((t, n) => t + (e[n.key] || 0), 0);
|
|
15
|
+
if (r.style.display = n > 0 ? "flex" : "none", n) for (let { key: n } of t) {
|
|
16
|
+
let t = a[n], r = e[n] || 0;
|
|
17
|
+
r === 0 ? (t.style.flex = "0 0 0", t.style.padding = "0", t.textContent = "", t.removeAttribute("title")) : (t.style.flex = `${r} 1 0`, t.style.padding = "0 4px", t.textContent = String(r), t.title = `${i[n]}: ${r}`);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
setActive: (e) => {
|
|
21
|
+
r.classList.toggle("has-active", !!e);
|
|
22
|
+
for (let { key: n } of t) a[n].classList.toggle("is-active", n === e);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { e as buildSegmentedBar };
|