@jorgerdz/timeview 0.1.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +263 -0
  4. package/dist/cli/timeview.js +6710 -0
  5. package/dist/timeview.cjs +1 -0
  6. package/dist/timeview.js +5667 -0
  7. package/dist/tokens.css +67 -0
  8. package/dist/types/timeview/BandedTimeline.d.ts +11 -0
  9. package/dist/types/timeview/BandedTimeline.d.ts.map +1 -0
  10. package/dist/types/timeview/DensityHeatmap.d.ts +11 -0
  11. package/dist/types/timeview/DensityHeatmap.d.ts.map +1 -0
  12. package/dist/types/timeview/LaneCalendar.d.ts +11 -0
  13. package/dist/types/timeview/LaneCalendar.d.ts.map +1 -0
  14. package/dist/types/timeview/MetricTimeline.d.ts +8 -0
  15. package/dist/types/timeview/MetricTimeline.d.ts.map +1 -0
  16. package/dist/types/timeview/SpanMatrix.d.ts +8 -0
  17. package/dist/types/timeview/SpanMatrix.d.ts.map +1 -0
  18. package/dist/types/timeview/config.d.ts +22 -0
  19. package/dist/types/timeview/config.d.ts.map +1 -0
  20. package/dist/types/timeview/core/aggregate.d.ts +113 -0
  21. package/dist/types/timeview/core/aggregate.d.ts.map +1 -0
  22. package/dist/types/timeview/core/calendar.d.ts +27 -0
  23. package/dist/types/timeview/core/calendar.d.ts.map +1 -0
  24. package/dist/types/timeview/core/intervals.d.ts +8 -0
  25. package/dist/types/timeview/core/intervals.d.ts.map +1 -0
  26. package/dist/types/timeview/core/labels.d.ts +5 -0
  27. package/dist/types/timeview/core/labels.d.ts.map +1 -0
  28. package/dist/types/timeview/core/metric.d.ts +58 -0
  29. package/dist/types/timeview/core/metric.d.ts.map +1 -0
  30. package/dist/types/timeview/core/time.d.ts +22 -0
  31. package/dist/types/timeview/core/time.d.ts.map +1 -0
  32. package/dist/types/timeview/dashboard.d.ts +17 -0
  33. package/dist/types/timeview/dashboard.d.ts.map +1 -0
  34. package/dist/types/timeview/data.d.ts +21 -0
  35. package/dist/types/timeview/data.d.ts.map +1 -0
  36. package/dist/types/timeview/export.d.ts +14 -0
  37. package/dist/types/timeview/export.d.ts.map +1 -0
  38. package/dist/types/timeview/index.d.ts +28 -0
  39. package/dist/types/timeview/index.d.ts.map +1 -0
  40. package/dist/types/timeview/registry.d.ts +285 -0
  41. package/dist/types/timeview/registry.d.ts.map +1 -0
  42. package/dist/types/timeview/shared/Caption.d.ts +9 -0
  43. package/dist/types/timeview/shared/Caption.d.ts.map +1 -0
  44. package/dist/types/timeview/shared/EmptyState.d.ts +16 -0
  45. package/dist/types/timeview/shared/EmptyState.d.ts.map +1 -0
  46. package/dist/types/timeview/shared/Legend.d.ts +10 -0
  47. package/dist/types/timeview/shared/Legend.d.ts.map +1 -0
  48. package/dist/types/timeview/shared/Tooltip.d.ts +15 -0
  49. package/dist/types/timeview/shared/Tooltip.d.ts.map +1 -0
  50. package/dist/types/timeview/shared/useMeasuredWidth.d.ts +2 -0
  51. package/dist/types/timeview/shared/useMeasuredWidth.d.ts.map +1 -0
  52. package/dist/types/timeview/types.d.ts +158 -0
  53. package/dist/types/timeview/types.d.ts.map +1 -0
  54. package/docs/AGENT-USAGE.md +93 -0
  55. package/docs/COMPATIBILITY.md +134 -0
  56. package/docs/STUDIO.md +41 -0
  57. package/examples/README.md +21 -0
  58. package/examples/configs/bandedTimeline.json +31 -0
  59. package/examples/configs/densityHeatmap.json +33 -0
  60. package/examples/configs/laneCalendar.json +31 -0
  61. package/examples/configs/metricTimeline.json +51 -0
  62. package/examples/configs/spanMatrix.json +31 -0
  63. package/package.json +94 -0
  64. package/render.html +12 -0
  65. package/src/render.tsx +67 -0
  66. package/src/styles/tokens.css +67 -0
  67. package/src/timeview/BandedTimeline.tsx +620 -0
  68. package/src/timeview/DensityHeatmap.tsx +513 -0
  69. package/src/timeview/LaneCalendar.tsx +496 -0
  70. package/src/timeview/MetricTimeline.tsx +993 -0
  71. package/src/timeview/SpanMatrix.tsx +721 -0
  72. package/src/timeview/config.ts +399 -0
  73. package/src/timeview/core/aggregate.ts +317 -0
  74. package/src/timeview/core/calendar.ts +81 -0
  75. package/src/timeview/core/intervals.ts +52 -0
  76. package/src/timeview/core/labels.ts +19 -0
  77. package/src/timeview/core/metric.ts +263 -0
  78. package/src/timeview/core/time.ts +103 -0
  79. package/src/timeview/dashboard.ts +80 -0
  80. package/src/timeview/data.ts +242 -0
  81. package/src/timeview/export.ts +48 -0
  82. package/src/timeview/index.ts +106 -0
  83. package/src/timeview/registry.ts +207 -0
  84. package/src/timeview/shared/Caption.tsx +40 -0
  85. package/src/timeview/shared/EmptyState.tsx +90 -0
  86. package/src/timeview/shared/Legend.tsx +67 -0
  87. package/src/timeview/shared/Tooltip.tsx +59 -0
  88. package/src/timeview/shared/useMeasuredWidth.ts +21 -0
  89. package/src/timeview/types.ts +159 -0
  90. package/vite.config.ts +11 -0
@@ -0,0 +1,159 @@
1
+ // types.ts — the shared Timeview data contract.
2
+ //
3
+ // Every Timeview visualizer renders the same `TimeDataset` (schema
4
+ // `timeview.dataset.v1`) projected by a view-specific `ViewSpec`. Keeping the
5
+ // dataset renderer-agnostic is what lets a future LaneCalendar / DensityHeatmap
6
+ // / Gantt consume the exact same fixtures as BandedTimeline.
7
+
8
+ /** Anything the helpers will accept as a moment in time. */
9
+ export type TimeInput = number | string | Date;
10
+
11
+ /** A categorical label. `color` is advisory — at render time the active
12
+ * `palette[i]` (mapped by index) wins, so a dataset re-themes by swapping
13
+ * the palette without touching the data. */
14
+ export interface TimeLabel {
15
+ id: string;
16
+ name: string;
17
+ color?: string;
18
+ }
19
+
20
+ /** An instant event (milestone). Rendered as a hollow diamond. */
21
+ export interface TimeEvent {
22
+ id: string;
23
+ at: string;
24
+ title: string;
25
+ labelIds?: string[];
26
+ }
27
+
28
+ /** A date range. Rendered as an interval band in a lane. */
29
+ export interface TimeInterval {
30
+ id: string;
31
+ range: { start: string; end: string };
32
+ title: string;
33
+ labelIds?: string[];
34
+ }
35
+
36
+ /** A dated numeric sample for metric visualizers. */
37
+ export interface MetricSample {
38
+ at: string;
39
+ value: number;
40
+ }
41
+
42
+ /** Optional numeric series carried by metric-oriented visualizers. */
43
+ export interface MetricSeries {
44
+ id: string;
45
+ name: string;
46
+ unit?: string;
47
+ samples: MetricSample[];
48
+ target?: { value: number; label?: string };
49
+ }
50
+
51
+ /** schema `timeview.dataset.v1` */
52
+ export interface TimeDataset {
53
+ schemaVersion: "timeview.dataset.v1";
54
+ timezone: string;
55
+ meta?: { title?: string; description?: string };
56
+ labels: TimeLabel[];
57
+ events: TimeEvent[];
58
+ intervals: TimeInterval[];
59
+ series?: MetricSeries;
60
+ }
61
+
62
+ export type Density = "comfortable" | "compact";
63
+ export type LegendPosition = "top" | "bottom" | "right" | "off";
64
+ export type CaptionPosition = "top" | "bottom" | "off";
65
+ export type OverlapMode = "lanes" | "packed" | "layered" | "hatched";
66
+ export type LaneMode = "packed" | "category";
67
+ export type TodayMode = "auto";
68
+ export type TodayValue = string | TodayMode | null;
69
+ export type TimeBucketMode = "day" | "week";
70
+ export type HeatmapMeasure = "count" | "duration";
71
+ export type HeatmapGroupBy = "category" | "none";
72
+ export type HeatmapScaleMode = "category" | "uniform";
73
+ export type MetricStateMode = "band" | "tint" | "off";
74
+ export type MetricYAxisMode = "auto" | "full";
75
+ export type MetricDefaultDays = 30 | 90 | 180 | 365;
76
+
77
+ /** Options shared by every Timeview visualizer. */
78
+ export interface ViewSpecBase {
79
+ title?: string;
80
+ /** "comfortable" | "compact" */
81
+ density?: Density;
82
+ legend?: { enabled?: boolean; position?: LegendPosition };
83
+ caption?: { enabled?: boolean; position?: CaptionPosition; text?: string };
84
+ events?: { showPoints?: boolean; showLabels?: boolean; showMarkers?: boolean };
85
+ }
86
+
87
+ /** View-specific projection for BandedTimeline. */
88
+ export interface BandedTimelineSpec extends ViewSpecBase {
89
+ kind?: "bandedTimeline";
90
+ /** how simultaneously-active intervals are resolved */
91
+ overlapMode?: OverlapMode;
92
+ }
93
+
94
+ /** View-specific projection for LaneCalendar. */
95
+ export interface LaneCalendarSpec extends ViewSpecBase {
96
+ kind?: "laneCalendar";
97
+ /** how interval rows are preserved across week rows */
98
+ laneMode?: LaneMode;
99
+ /** "auto" uses browser-local today, ISO strings freeze the marker, null/omitted disables it */
100
+ today?: TodayValue;
101
+ }
102
+
103
+ /** View-specific projection for DensityHeatmap. */
104
+ export interface DensityHeatmapSpec extends ViewSpecBase {
105
+ kind?: "densityHeatmap";
106
+ /** time bucket granularity */
107
+ bucket?: TimeBucketMode;
108
+ /** density value encoded by cell intensity */
109
+ measure?: HeatmapMeasure;
110
+ /** row grouping derived from existing dataset dimensions */
111
+ groupBy?: HeatmapGroupBy;
112
+ /** category-colored rows or one neutral comparable ramp */
113
+ scaleMode?: HeatmapScaleMode;
114
+ /** show count/duration text inside cells when space allows */
115
+ showValues?: boolean;
116
+ }
117
+
118
+ /** View-specific projection for SpanMatrix. */
119
+ export interface SpanMatrixSpec extends ViewSpecBase {
120
+ kind?: "spanMatrix";
121
+ /** time bucket granularity */
122
+ bucket?: TimeBucketMode;
123
+ /** row grouping derived from existing dataset dimensions */
124
+ groupBy?: HeatmapGroupBy;
125
+ /** column scale multiplier; 1 is the default bucket width */
126
+ zoom?: number;
127
+ /** show overlap counts inside present cells */
128
+ showCounts?: boolean;
129
+ /** ISO string freezes the marker; null/omitted disables it */
130
+ today?: string | null;
131
+ }
132
+
133
+ /** View-specific projection for MetricTimeline. */
134
+ export interface MetricTimelineSpec extends ViewSpecBase {
135
+ kind?: "metricTimeline";
136
+ /** State intervals as a separate band row, line tinting, or hidden. */
137
+ stateMode?: MetricStateMode;
138
+ /** Fit y-axis to visible window or full series. */
139
+ yAxis?: MetricYAxisMode;
140
+ /** Opening viewport span ending at today or the series end. */
141
+ defaultDays?: MetricDefaultDays;
142
+ /** ISO string freezes the default viewport end; null/omitted uses the series end. */
143
+ today?: string | null;
144
+ showPoints?: boolean;
145
+ showValues?: boolean;
146
+ showTarget?: boolean;
147
+ minimap?: boolean;
148
+ }
149
+
150
+ /** Back-compat alias for the first Timeview visualizer's spec. */
151
+ export type ViewSpec = BandedTimelineSpec | LaneCalendarSpec | DensityHeatmapSpec | SpanMatrixSpec | MetricTimelineSpec;
152
+
153
+ /** A linear time→pixel scale (callable, with d3-style extras). */
154
+ export interface TvScale {
155
+ (t: TimeInput): number;
156
+ invert: (px: number) => Date;
157
+ domain: [number, number];
158
+ width: number;
159
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react";
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ build: {
8
+ emptyOutDir: false,
9
+ outDir: "dist/studio",
10
+ },
11
+ });