courthive-components 3.2.0 → 3.3.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.
@@ -1,50 +1,84 @@
1
- //#region node_modules/.pnpm/timepicker-ui@4.3.0/node_modules/timepicker-ui/dist/plugins/range.js
2
- function e(e) {
3
- if (!e || e === "--:--") return null;
4
- let t = e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);
5
- if (t) return {
6
- hour: t[1],
7
- minutes: t[2],
8
- type: t[3].toUpperCase()
9
- };
10
- let n = e.match(/^(\d{1,2}):(\d{2})$/);
1
+ //#region node_modules/.pnpm/timepicker-ui@4.4.0/node_modules/timepicker-ui/dist/plugins/range.js
2
+ var e = /^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i, t = /^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/;
3
+ function n(t) {
4
+ let n = t.match(e);
5
+ return n ? {
6
+ hour: n[1],
7
+ minutes: n[2],
8
+ type: n[3].toUpperCase()
9
+ } : null;
10
+ }
11
+ function r(e) {
12
+ let n = e.match(t);
11
13
  return n ? {
12
14
  hour: n[1],
13
15
  minutes: n[2]
14
16
  } : null;
15
17
  }
16
- function t(e) {
18
+ function i(e, t) {
19
+ let n = parseInt(e.hour, 10), r = parseInt(e.minutes, 10);
20
+ if (Number.isNaN(n) || Number.isNaN(r)) return 0;
21
+ if (t === "12h" && e.type) {
22
+ let t = e.type.toUpperCase();
23
+ t === "PM" && n !== 12 && (n += 12), t === "AM" && n === 12 && (n = 0);
24
+ }
25
+ return n * 60 + r;
26
+ }
27
+ function a(e) {
28
+ if (!e || e === "--:--") return null;
29
+ let t = n(e);
30
+ if (t) return {
31
+ hour: t.hour,
32
+ minutes: t.minutes,
33
+ type: t.type
34
+ };
35
+ let i = e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);
36
+ if (i) return {
37
+ hour: i[1],
38
+ minutes: i[2],
39
+ type: i[3].toUpperCase()
40
+ };
41
+ let a = r(e);
42
+ if (a) return {
43
+ hour: a.hour,
44
+ minutes: a.minutes
45
+ };
46
+ let o = e.match(/^(\d{1,2}):(\d{2})$/);
47
+ return o ? {
48
+ hour: o[1],
49
+ minutes: o[2]
50
+ } : null;
51
+ }
52
+ function o(e) {
17
53
  let t = e.minutes === "--" ? "--" : e.minutes.padStart(2, "0"), n = `${e.hour}:${t}`;
18
54
  return e.type ? `${n} ${e.type}` : n;
19
55
  }
20
- function n(e, t) {
21
- if (!e) return 0;
22
- let n = parseInt(e.hour, 10), r = parseInt(e.minutes, 10);
23
- return t === "12h" && e.type && (e.type === "PM" && n !== 12 && (n += 12), e.type === "AM" && n === 12 && (n = 0)), n * 60 + r;
56
+ function s(e, t) {
57
+ return e ? i(e, t) : 0;
24
58
  }
25
- function r(e, t, r) {
59
+ function c(e, t, n) {
26
60
  if (!e || !t) return 0;
27
- let i = n(e, r);
28
- return n(t, r) - i;
61
+ let r = s(e, n);
62
+ return s(t, n) - r;
29
63
  }
30
- function i(e, t) {
64
+ function l(e, t) {
31
65
  return e ? t === "12h" ? !!(e.hour && e.minutes && e.type) : !!(e.hour && e.minutes) : !1;
32
66
  }
33
- function a(t) {
34
- if (!t || !t.includes(" - ")) return {
67
+ function u(e) {
68
+ if (!e || !e.includes(" - ")) return {
35
69
  from: null,
36
70
  to: null
37
71
  };
38
- let n = t.split(" - ").map((e) => e.trim());
39
- return n.length !== 2 || n[0] === "--:--" || n[1] === "--:--" ? {
72
+ let t = e.split(" - ").map((e) => e.trim());
73
+ return t.length !== 2 || t[0] === "--:--" || t[1] === "--:--" ? {
40
74
  from: null,
41
75
  to: null
42
76
  } : {
43
- from: e(n[0]),
44
- to: e(n[1])
77
+ from: a(t[0]),
78
+ to: a(t[1])
45
79
  };
46
80
  }
47
- var o = class {
81
+ var d = class {
48
82
  activePart = "from";
49
83
  fromValue = null;
50
84
  toValue = null;
@@ -78,10 +112,10 @@ var o = class {
78
112
  this.previewValue = e;
79
113
  }
80
114
  isFromComplete() {
81
- return i(this.fromValue, this.clockType);
115
+ return l(this.fromValue, this.clockType);
82
116
  }
83
117
  isToComplete() {
84
- return i(this.toValue, this.clockType);
118
+ return l(this.toValue, this.clockType);
85
119
  }
86
120
  canSwitchToEnd() {
87
121
  return this.isFromComplete();
@@ -107,7 +141,7 @@ var o = class {
107
141
  this.previewValue &&= (this.activePart === "from" ? this.fromValue = this.previewValue : this.toValue = this.previewValue, null);
108
142
  }
109
143
  getDuration() {
110
- return r(this.fromValue, this.toValue, this.clockType);
144
+ return c(this.fromValue, this.toValue, this.clockType);
111
145
  }
112
146
  validate() {
113
147
  if (!this.fromValue || !this.toValue) return {
@@ -148,7 +182,7 @@ var o = class {
148
182
  reset() {
149
183
  this.activePart = "from", this.fromValue = null, this.toValue = null, this.previewValue = null;
150
184
  }
151
- }, s = class {
185
+ }, f = class {
152
186
  core;
153
187
  state;
154
188
  constructor(e, t) {
@@ -163,10 +197,10 @@ var o = class {
163
197
  updateTimeDisplay() {
164
198
  let e = this.core.getModalElement();
165
199
  if (!e) return;
166
- let n = e.querySelector(".tp-ui-range-from-time"), r = e.querySelector(".tp-ui-range-to-time"), i = this.state.getActivePart(), a = this.state.getPreviewValue(), o = this.state.getFromValue(), s = this.state.getToValue(), c = "--:--";
167
- i === "from" && a ? c = t(a) : o && (c = t(o));
200
+ let t = e.querySelector(".tp-ui-range-from-time"), n = e.querySelector(".tp-ui-range-to-time"), r = this.state.getActivePart(), i = this.state.getPreviewValue(), a = this.state.getFromValue(), s = this.state.getToValue(), c = "--:--";
201
+ r === "from" && i ? c = o(i) : a && (c = o(a));
168
202
  let l = "--:--";
169
- i === "to" && a ? l = t(a) : s && (l = t(s)), n && (n.textContent = c), r && (r.textContent = l);
203
+ r === "to" && i ? l = o(i) : s && (l = o(s)), t && (t.textContent = c), n && (n.textContent = l);
170
204
  }
171
205
  updateOkButton() {
172
206
  let e = this.core.getOkButton();
@@ -177,8 +211,8 @@ var o = class {
177
211
  updateInputValue() {
178
212
  let e = this.core.getInput();
179
213
  if (!e) return;
180
- let n = this.state.getFromValue(), r = this.state.getToValue();
181
- e.value = `${n ? t(n) : "--:--"} - ${r ? t(r) : "--:--"}`;
214
+ let t = this.state.getFromValue(), n = this.state.getToValue();
215
+ e.value = `${t ? o(t) : "--:--"} - ${n ? o(n) : "--:--"}`;
182
216
  }
183
217
  syncClockToActivePart() {
184
218
  let e = this.state.getSavedValue(), t = this.core.getHour(), n = this.core.getMinutes();
@@ -191,29 +225,28 @@ var o = class {
191
225
  updateAll() {
192
226
  this.updateTabs(), this.updateTimeDisplay(), this.updateOkButton();
193
227
  }
194
- }, c = class {
228
+ };
229
+ function p(e, t, n, r) {
230
+ e.on(n, r), t.push(() => e.off(n, r));
231
+ }
232
+ var m = class {
195
233
  core;
196
234
  emitter;
197
235
  state;
198
236
  ui;
199
237
  cleanupHandlers = [];
200
238
  isSyncingAmPm = !1;
201
- boundHandleMinuteCommit;
202
- boundHandleConfirm;
203
- boundHandleUpdate;
204
- boundHandleAmPm;
205
- boundHandleClear;
206
239
  constructor(e, t) {
207
240
  this.core = e, this.emitter = t;
208
241
  let { range: n, clock: r } = e.options;
209
- this.state = new o(r.type, n?.minDuration, n?.maxDuration, t), this.ui = new s(e, this.state), this.boundHandleMinuteCommit = this.handleMinuteCommit.bind(this), this.boundHandleConfirm = this.handleConfirm.bind(this), this.boundHandleUpdate = this.handleUpdate.bind(this), this.boundHandleAmPm = this.handleAmPm.bind(this), this.boundHandleClear = this.handleClear.bind(this);
242
+ this.state = new d(r.type, n?.minDuration, n?.maxDuration, t), this.ui = new f(e, this.state);
210
243
  }
211
244
  get isEnabled() {
212
245
  return this.core.options.range?.enabled === !0;
213
246
  }
214
247
  init() {
215
248
  if (!this.isEnabled) return;
216
- let { from: e, to: t } = a(this.core.getInput()?.value || "");
249
+ let { from: e, to: t } = u(this.core.getInput()?.value || "");
217
250
  this.state.setFromValue(e), this.state.setToValue(t), this.state.setActivePart("from"), this.state.setPreviewValue(null), this.bindEvents(), this.ui.syncClockToActivePart(), this.emitAmPmSyncEvent(), this.ui.updateAll();
218
251
  }
219
252
  getActivePart() {
@@ -247,10 +280,10 @@ var o = class {
247
280
  return this.isEnabled ? this.state.canConfirm() : !0;
248
281
  }
249
282
  getFormattedRange() {
250
- let e = this.state.getFromValue(), n = this.state.getToValue();
251
- return !e || !n ? null : {
252
- from: t(e),
253
- to: t(n)
283
+ let e = this.state.getFromValue(), t = this.state.getToValue();
284
+ return !e || !t ? null : {
285
+ from: o(e),
286
+ to: o(t)
254
287
  };
255
288
  }
256
289
  bindEvents() {
@@ -258,14 +291,48 @@ var o = class {
258
291
  if (!e) return;
259
292
  let t = e.querySelector(".tp-ui-range-tab.tp-ui-range-from"), n = e.querySelector(".tp-ui-range-tab.tp-ui-range-to");
260
293
  if (t) {
261
- let e = () => this.setActivePart("from");
294
+ let e = () => this.activatePart("from", t);
262
295
  t.addEventListener("click", e), this.cleanupHandlers.push(() => t.removeEventListener("click", e));
263
296
  }
264
297
  if (n) {
265
- let e = () => this.setActivePart("to");
298
+ let e = () => this.activatePart("to", n);
266
299
  n.addEventListener("click", e), this.cleanupHandlers.push(() => n.removeEventListener("click", e));
267
300
  }
268
- this.emitter.on("update", this.boundHandleUpdate), this.cleanupHandlers.push(() => this.emitter.off("update", this.boundHandleUpdate)), this.emitter.on("range:minute:commit", this.boundHandleMinuteCommit), this.cleanupHandlers.push(() => this.emitter.off("range:minute:commit", this.boundHandleMinuteCommit)), this.emitter.on("confirm", this.boundHandleConfirm), this.cleanupHandlers.push(() => this.emitter.off("confirm", this.boundHandleConfirm)), this.emitter.on("select:am", this.boundHandleAmPm), this.cleanupHandlers.push(() => this.emitter.off("select:am", this.boundHandleAmPm)), this.emitter.on("select:pm", this.boundHandleAmPm), this.cleanupHandlers.push(() => this.emitter.off("select:pm", this.boundHandleAmPm)), this.emitter.on("clear", this.boundHandleClear), this.cleanupHandlers.push(() => this.emitter.off("clear", this.boundHandleClear));
301
+ this.bindTabKeyboard(t, n), p(this.emitter, this.cleanupHandlers, "update", () => this.handleUpdate()), p(this.emitter, this.cleanupHandlers, "range:minute:commit", (e) => this.handleMinuteCommit(e)), p(this.emitter, this.cleanupHandlers, "confirm", () => this.handleConfirm()), p(this.emitter, this.cleanupHandlers, "select:am", () => this.handleAmPm()), p(this.emitter, this.cleanupHandlers, "select:pm", () => this.handleAmPm()), p(this.emitter, this.cleanupHandlers, "clear", () => this.handleClear());
302
+ }
303
+ isTabDisabled(e) {
304
+ return !e || e.getAttribute("aria-disabled") === "true" || e.classList.contains("disabled");
305
+ }
306
+ activatePart(e, t) {
307
+ this.isTabDisabled(t) || this.setActivePart(e);
308
+ }
309
+ bindTabKeyboard(e, t) {
310
+ let n = [e, t].filter((e) => e !== null);
311
+ n.length !== 0 && n.forEach((e, t) => {
312
+ let r = t === 0 ? "from" : "to", i = (i) => {
313
+ switch (i.key) {
314
+ case "ArrowRight":
315
+ case "ArrowLeft": {
316
+ i.preventDefault();
317
+ let e = n[((i.key === "ArrowRight" ? t + 1 : t - 1) + n.length) % n.length];
318
+ this.isTabDisabled(e) || e.focus();
319
+ break;
320
+ }
321
+ case "Home":
322
+ i.preventDefault(), n[0].focus();
323
+ break;
324
+ case "End":
325
+ i.preventDefault(), n[n.length - 1].focus();
326
+ break;
327
+ case "Enter":
328
+ case " ":
329
+ case "Spacebar":
330
+ i.preventDefault(), this.activatePart(r, e);
331
+ break;
332
+ }
333
+ };
334
+ e.addEventListener("keydown", i), this.cleanupHandlers.push(() => e.removeEventListener("keydown", i));
335
+ });
269
336
  }
270
337
  handleClear() {
271
338
  this.isEnabled && (this.state.setFromValue(null), this.state.setToValue(null), this.state.setPreviewValue(null), this.state.resetActivePart());
@@ -329,14 +396,14 @@ var o = class {
329
396
  }
330
397
  }
331
398
  }
332
- handleConfirm(e) {
399
+ handleConfirm() {
333
400
  if (!this.isEnabled) return;
334
401
  this.state.commitPreview();
335
- let n = this.state.getFromValue(), r = this.state.getToValue(), i = n ? t(n) : "--:--", a = r ? t(r) : "--:--", o = this.state.getDuration();
402
+ let e = this.state.getFromValue(), t = this.state.getToValue(), n = e ? o(e) : "--:--", r = t ? o(t) : "--:--", i = this.state.getDuration();
336
403
  this.ui.updateInputValue(), this.emitter.emit("range:confirm", {
337
- from: i,
338
- to: a,
339
- duration: o
404
+ from: n,
405
+ to: r,
406
+ duration: i
340
407
  });
341
408
  }
342
409
  reset() {
@@ -345,9 +412,9 @@ var o = class {
345
412
  destroy() {
346
413
  this.cleanupHandlers.forEach((e) => e()), this.cleanupHandlers = [], this.reset();
347
414
  }
348
- }, l = {
415
+ }, h = {
349
416
  name: "range",
350
- factory: (e, t) => new c(e, t),
417
+ factory: (e, t) => new m(e, t),
351
418
  clearHandler: (e, t) => {
352
419
  if (!e.options.range?.enabled) return;
353
420
  let n = e.getModalElement();
@@ -362,4 +429,4 @@ var o = class {
362
429
  }
363
430
  };
364
431
  //#endregion
365
- export { l as RangePlugin };
432
+ export { h as RangePlugin };
package/dist/types.d.ts CHANGED
@@ -237,9 +237,21 @@ export interface CompositionColors {
237
237
  internalDividers?: string;
238
238
  /** placeholder "[Score]" text color — sets `--chc-color-score`. Falls back to `--chc-status-info`. */
239
239
  score?: string;
240
- /** round header text + underline color — sets `--chc-color-round-header`.
241
- * Underline falls back to `--chc-text-primary`; text falls back to inherit. */
240
+ /** round header text color — sets `--chc-color-round-header`. Falls back to inherit.
241
+ * Also acts as the underline-color fallback when `roundHeaderUnderline` is unset. */
242
242
  roundHeader?: string;
243
+ /** round header background color — sets `--chc-color-round-header-bg`. Falls back to transparent. */
244
+ roundHeaderBackground?: string;
245
+ /** round header underline (divider between header and participants) — sets
246
+ * `--chc-color-round-header-underline`. Falls back to `roundHeader`, then `--chc-text-primary`. */
247
+ roundHeaderUnderline?: string;
248
+ /** matchUp footer background color — sets `--chc-color-matchup-footer-bg`. Falls back to `matchUpBackground`. */
249
+ matchUpFooterBackground?: string;
250
+ /** matchUp footer text color — sets `--chc-color-matchup-footer-text`. Falls back to `--chc-text-muted`. */
251
+ matchUpFooterText?: string;
252
+ /** matchUp footer top divider (border between matchUp body and footer) — sets
253
+ * `--chc-color-matchup-footer-divider`. Falls back to transparent. */
254
+ matchUpFooterDivider?: string;
243
255
  }
244
256
  export interface Composition {
245
257
  theme: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "courthive-components",
3
- "packageManager": "pnpm@11.5.2",
4
- "version": "3.2.0",
3
+ "packageManager": "pnpm@11.6.0",
4
+ "version": "3.3.0",
5
5
  "engines": {
6
6
  "node": ">=22"
7
7
  },
@@ -78,8 +78,8 @@
78
78
  "@storybook/test-runner": "^0.24.0",
79
79
  "@types/d3": "^7.4.3",
80
80
  "@types/vanillajs-datepicker": "^1.3.5",
81
- "@typescript-eslint/eslint-plugin": "8.60.0",
82
- "@typescript-eslint/parser": "8.60.0",
81
+ "@typescript-eslint/eslint-plugin": "8.60.1",
82
+ "@typescript-eslint/parser": "8.60.1",
83
83
  "@vitest/browser-playwright": "^4.0.16",
84
84
  "@vitest/coverage-v8": "^4.0.16",
85
85
  "@vitest/ui": "^4.0.16",
@@ -93,7 +93,7 @@
93
93
  "lint-staged": "17.0.7",
94
94
  "playwright": "^1.57.0",
95
95
  "prettier": "^3.8.1",
96
- "semver": "7.8.1",
96
+ "semver": "7.8.3",
97
97
  "storybook": "^10.2.17",
98
98
  "tabulator-tables": "6.4.0",
99
99
  "typescript": "^6.0.2",
@@ -117,7 +117,7 @@
117
117
  "focus-trap": "^8.0.0",
118
118
  "timepicker-ui": "^4.1.2",
119
119
  "tippy.js": "6.3.7",
120
- "tods-competition-factory": "5.4.0",
120
+ "tods-competition-factory": "5.5.0",
121
121
  "vanillajs-datepicker": "1.3.4"
122
122
  }
123
123
  }