courthive-components 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export { buildLadderChart } from './ladderChart';
2
+ export type { LadderChartDatum, LadderChartConfig, LadderChartMargins, LadderChartInstance, } from './types';
@@ -0,0 +1,2 @@
1
+ import { LadderChartConfig, LadderChartInstance } from './types';
2
+ export declare function buildLadderChart(container: HTMLElement, initialConfig: LadderChartConfig): LadderChartInstance;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * LadderChart — public types.
3
+ *
4
+ * Visualizes a player's (or any subject's) ordinal progression across a
5
+ * time series. Each datum places a mark at (date, rung), connected
6
+ * chronologically by an optional line.
7
+ *
8
+ * Originally a D3v3 "Ladder chart" in tennisvisuals. Rewritten for
9
+ * D3v7 + TypeScript + the courthive-components vanilla-component
10
+ * pattern (returns SVG element via factory function; no framework).
11
+ */
12
+ export interface LadderChartDatum {
13
+ /** Mark X position. Pass a Date or an ISO-8601 string. */
14
+ date: Date | string;
15
+ /** Mark Y position: 0-based index into `rungs[]`. 0 is the bottom rung. */
16
+ rung: number;
17
+ /** Optional mark color override (CSS color string). Falls back to `markColor`. */
18
+ color?: string;
19
+ /** Optional mark radius override (px). Falls back to `markRadius`. */
20
+ radius?: number;
21
+ /** Optional label for the mark (used in tooltip/aria). Examples: tournament name. */
22
+ label?: string;
23
+ /** Optional secondary label (used in tooltip body). Examples: result string. */
24
+ detail?: string;
25
+ /** Arbitrary attached data, forwarded to onClick/onHover callbacks. */
26
+ meta?: Record<string, unknown>;
27
+ }
28
+ export interface LadderChartMargins {
29
+ top?: number;
30
+ right?: number;
31
+ bottom?: number;
32
+ left?: number;
33
+ }
34
+ export interface LadderChartConfig {
35
+ /** Ordinal rung labels, ordered bottom → top. Example: ['R128','R64','R32','R16','QF','SF','F','W']. */
36
+ rungs: string[];
37
+ /** Mark data. May be unsorted; the renderer sorts by date for the connector. */
38
+ data: LadderChartDatum[];
39
+ /** Chart width in px. Defaults to container's clientWidth (or 600). */
40
+ width?: number;
41
+ /** Chart height in px. Defaults to 240. */
42
+ height?: number;
43
+ margins?: LadderChartMargins;
44
+ /** Optional chart title rendered above the plot. */
45
+ title?: string;
46
+ /** Optional subtitle / source text rendered below the plot. */
47
+ source?: string;
48
+ /** Draw a connector line between marks in chronological order. Default: true. */
49
+ showConnector?: boolean;
50
+ /** Default mark color when datum has no `color` override. Default: `var(--sp-accent)` → `#3366cc`. */
51
+ markColor?: string;
52
+ /** Default mark radius in px when datum has no `radius`. Default: 6. */
53
+ markRadius?: number;
54
+ /** Connector line color. Default: `var(--sp-muted)` → `#94a3b8`. */
55
+ connectorColor?: string;
56
+ /** X-axis date format token (d3-time-format). Auto-selected if absent. */
57
+ xTickFormat?: string;
58
+ /** Maximum number of X-axis ticks. Default: 8. */
59
+ xMaxTicks?: number;
60
+ /** Click handler for a mark. */
61
+ onMarkClick?: (datum: LadderChartDatum, event: MouseEvent) => void;
62
+ /** Hover handler; receives null when the cursor leaves all marks. */
63
+ onMarkHover?: (datum: LadderChartDatum | null, event: MouseEvent | null) => void;
64
+ }
65
+ export interface LadderChartInstance {
66
+ /** The mounted SVG element (already inside the container). */
67
+ element: SVGSVGElement;
68
+ /** Re-render with new partial config (e.g. swap data on player change). */
69
+ update(next: Partial<LadderChartConfig>): void;
70
+ /** Remove the chart from its parent + detach listeners. */
71
+ destroy(): void;
72
+ }
@@ -18,6 +18,7 @@ export declare const tcFooterStyle: () => string;
18
18
  export declare const tcFeeBadgeStyle: () => string;
19
19
  export declare const tcPlayerCountStyle: () => string;
20
20
  export declare const tcEventCountStyle: () => string;
21
+ export declare const tcTierBadgeStyle: () => string;
21
22
  export declare const tcSkeletonStyle: () => string;
22
23
  export declare const tcSkeletonLineStyle: () => string;
23
24
  export declare const tcSkeletonBlockStyle: () => string;
@@ -4,6 +4,23 @@ export interface TournamentStatusPill {
4
4
  kind: TournamentStatusKind;
5
5
  label: string;
6
6
  }
7
+ /**
8
+ * Federation-specific competitive tier. Mirrors the factory's
9
+ * `TierClassification` shape (kept in lockstep but duplicated here to
10
+ * avoid pulling tods-competition-factory into the component's runtime
11
+ * dependency graph).
12
+ *
13
+ * - `system`: federation namespace, e.g. `'ITF_JUNIOR'`, `'ATP'`, `'PPA'`.
14
+ * - `value`: the tier within that system, e.g. `'J500'`, `'Masters 1000'`, `'Gold'`.
15
+ * - `numericRank`: optional sort key — lower = more prestigious. Used by
16
+ * the card / table column to sort tournaments without round-tripping
17
+ * through a ranking policy.
18
+ */
19
+ export interface TierClassification {
20
+ system: string;
21
+ value: string;
22
+ numericRank?: number;
23
+ }
7
24
  export interface TournamentEntryFee {
8
25
  amount: number;
9
26
  currencyCode?: string;
@@ -39,8 +56,16 @@ export interface TournamentCardData {
39
56
  updatedAt?: string;
40
57
  /** When true, render an offline/local indicator */
41
58
  offline?: boolean;
59
+ /**
60
+ * Competitive tier classification (federation-specific). When present
61
+ * and the `'tier'` field is in `TournamentCardConfig.body` (default), the
62
+ * card renders a small chip displaying `tournamentTier.value`. The
63
+ * Tabulator list view sorts on `numericRank` ascending with `value`
64
+ * lex fallback.
65
+ */
66
+ tournamentTier?: TierClassification;
42
67
  }
43
- export type TournamentCardField = 'title' | 'location' | 'dateRange' | 'feeBadge' | 'playerCount' | 'eventCount' | 'organizerName' | 'updatedAt';
68
+ export type TournamentCardField = 'title' | 'tier' | 'location' | 'dateRange' | 'feeBadge' | 'playerCount' | 'eventCount' | 'organizerName' | 'updatedAt';
44
69
  export type TournamentCardCornerField = 'status' | 'offline';
45
70
  export interface TournamentCardConfig {
46
71
  /** Whether to render the image zone. Defaults to true. */