@vllnt/ui 0.2.1-canary.ab2c69a → 0.2.1-canary.bb791f1
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/components/alert-pulse/alert-pulse.js +93 -0
- package/dist/components/alert-pulse/index.js +6 -0
- package/dist/components/bottom-activity-strip/bottom-activity-strip.js +91 -0
- package/dist/components/bottom-activity-strip/index.js +6 -0
- package/dist/components/comment-pin/comment-pin.js +104 -0
- package/dist/components/comment-pin/index.js +6 -0
- package/dist/components/context-lens/context-lens.js +98 -0
- package/dist/components/context-lens/index.js +6 -0
- package/dist/components/floating-toolbar/floating-toolbar.js +66 -0
- package/dist/components/floating-toolbar/index.js +6 -0
- package/dist/components/follow-mode/follow-mode.js +89 -0
- package/dist/components/follow-mode/index.js +6 -0
- package/dist/components/handoff-beacon/handoff-beacon.js +78 -0
- package/dist/components/handoff-beacon/index.js +6 -0
- package/dist/components/heat-overlay/heat-overlay.js +92 -0
- package/dist/components/heat-overlay/index.js +6 -0
- package/dist/components/index.js +108 -0
- package/dist/components/jarvis-dock/index.js +6 -0
- package/dist/components/jarvis-dock/jarvis-dock.js +98 -0
- package/dist/components/live-cursor/index.js +6 -0
- package/dist/components/live-cursor/live-cursor.js +62 -0
- package/dist/components/metric-cluster/index.js +6 -0
- package/dist/components/metric-cluster/metric-cluster.js +96 -0
- package/dist/components/multi-select-lasso/index.js +6 -0
- package/dist/components/multi-select-lasso/multi-select-lasso.js +76 -0
- package/dist/components/object-inspector/index.js +6 -0
- package/dist/components/object-inspector/object-inspector.js +136 -0
- package/dist/components/playback-ghost/index.js +6 -0
- package/dist/components/playback-ghost/playback-ghost.js +83 -0
- package/dist/components/policy-delivery-panel/index.js +6 -0
- package/dist/components/policy-delivery-panel/policy-delivery-panel.js +99 -0
- package/dist/components/presence-sync-indicator/index.js +6 -0
- package/dist/components/presence-sync-indicator/presence-sync-indicator.js +73 -0
- package/dist/components/property-section/index.js +6 -0
- package/dist/components/property-section/property-section.js +101 -0
- package/dist/components/relationship-inspector/index.js +6 -0
- package/dist/components/relationship-inspector/relationship-inspector.js +102 -0
- package/dist/components/routing-assignment-panel/index.js +6 -0
- package/dist/components/routing-assignment-panel/routing-assignment-panel.js +122 -0
- package/dist/components/run-timeline/index.js +6 -0
- package/dist/components/run-timeline/run-timeline.js +221 -0
- package/dist/components/runtime-overview-panel/index.js +6 -0
- package/dist/components/runtime-overview-panel/runtime-overview-panel.js +89 -0
- package/dist/components/selection-halo/index.js +6 -0
- package/dist/components/selection-halo/selection-halo.js +72 -0
- package/dist/components/snap-guides/index.js +6 -0
- package/dist/components/snap-guides/snap-guides.js +45 -0
- package/dist/components/state-badge-overlay/index.js +6 -0
- package/dist/components/state-badge-overlay/state-badge-overlay.js +90 -0
- package/dist/components/sticky-metric/index.js +6 -0
- package/dist/components/sticky-metric/sticky-metric.js +83 -0
- package/dist/components/threshold-ring/index.js +6 -0
- package/dist/components/threshold-ring/threshold-ring.js +160 -0
- package/dist/components/timeline-scrubber/index.js +6 -0
- package/dist/components/timeline-scrubber/timeline-scrubber.js +179 -0
- package/dist/index.d.ts +2168 -107
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef
|
|
5
|
+
} from "react";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
const STATE_LABEL = {
|
|
8
|
+
complete: "Complete",
|
|
9
|
+
failed: "Failed",
|
|
10
|
+
idle: "Idle",
|
|
11
|
+
queued: "Queued",
|
|
12
|
+
running: "Running",
|
|
13
|
+
stopped: "Stopped"
|
|
14
|
+
};
|
|
15
|
+
const STATE_TONE = {
|
|
16
|
+
complete: "border-emerald-500/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300",
|
|
17
|
+
failed: "border-red-500/40 bg-red-500/15 text-red-700 dark:text-red-300",
|
|
18
|
+
idle: "border-border bg-muted/40 text-muted-foreground",
|
|
19
|
+
queued: "border-amber-500/40 bg-amber-500/15 text-amber-700 dark:text-amber-300",
|
|
20
|
+
running: "border-blue-500/40 bg-blue-500/15 text-blue-700 dark:text-blue-300",
|
|
21
|
+
stopped: "border-border bg-background text-foreground"
|
|
22
|
+
};
|
|
23
|
+
const STATE_DOT = {
|
|
24
|
+
complete: "bg-emerald-500",
|
|
25
|
+
failed: "bg-red-500",
|
|
26
|
+
idle: "bg-muted-foreground",
|
|
27
|
+
queued: "bg-amber-500",
|
|
28
|
+
running: "bg-blue-500 animate-pulse",
|
|
29
|
+
stopped: "bg-muted-foreground"
|
|
30
|
+
};
|
|
31
|
+
const ANCHOR_TRANSFORM = {
|
|
32
|
+
"bottom-left": "translate(-100%, 100%)",
|
|
33
|
+
"bottom-right": "translate(0%, 100%)",
|
|
34
|
+
"top-left": "translate(-100%, -100%)",
|
|
35
|
+
"top-right": "translate(0%, -100%)"
|
|
36
|
+
};
|
|
37
|
+
const DEFAULT_LABELS = {
|
|
38
|
+
region: "State"
|
|
39
|
+
};
|
|
40
|
+
const StateBadgeOverlay = forwardRef((props, ref) => {
|
|
41
|
+
const {
|
|
42
|
+
anchor = "top-right",
|
|
43
|
+
className,
|
|
44
|
+
label,
|
|
45
|
+
labels,
|
|
46
|
+
state,
|
|
47
|
+
x,
|
|
48
|
+
y,
|
|
49
|
+
...rest
|
|
50
|
+
} = props;
|
|
51
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
52
|
+
const text = label ?? STATE_LABEL[state];
|
|
53
|
+
return /* @__PURE__ */ jsxs(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
"aria-label": `${resolvedLabels.region}: ${STATE_LABEL[state]}`,
|
|
57
|
+
className: cn(
|
|
58
|
+
"pointer-events-none absolute z-20 inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide shadow-sm backdrop-blur",
|
|
59
|
+
STATE_TONE[state],
|
|
60
|
+
className
|
|
61
|
+
),
|
|
62
|
+
"data-state-anchor": anchor,
|
|
63
|
+
"data-state-badge-overlay": true,
|
|
64
|
+
"data-state-name": state,
|
|
65
|
+
ref,
|
|
66
|
+
role: "status",
|
|
67
|
+
style: {
|
|
68
|
+
left: x,
|
|
69
|
+
top: y,
|
|
70
|
+
transform: ANCHOR_TRANSFORM[anchor]
|
|
71
|
+
},
|
|
72
|
+
...rest,
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ jsx(
|
|
75
|
+
"span",
|
|
76
|
+
{
|
|
77
|
+
"aria-hidden": "true",
|
|
78
|
+
className: cn("h-1.5 w-1.5 rounded-full", STATE_DOT[state]),
|
|
79
|
+
"data-state-badge-dot": true
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
text
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
StateBadgeOverlay.displayName = "StateBadgeOverlay";
|
|
88
|
+
export {
|
|
89
|
+
StateBadgeOverlay
|
|
90
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef
|
|
5
|
+
} from "react";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
const TONE_DOT = {
|
|
8
|
+
danger: "bg-red-500",
|
|
9
|
+
neutral: "bg-muted-foreground",
|
|
10
|
+
success: "bg-emerald-500",
|
|
11
|
+
warn: "bg-amber-500"
|
|
12
|
+
};
|
|
13
|
+
const ANCHOR_OFFSET = {
|
|
14
|
+
"bottom-left": { transform: "translate(-100%, 100%)" },
|
|
15
|
+
"bottom-right": { transform: "translate(0%, 100%)" },
|
|
16
|
+
"top-left": { transform: "translate(-100%, -100%)" },
|
|
17
|
+
"top-right": { transform: "translate(0%, -100%)" }
|
|
18
|
+
};
|
|
19
|
+
const DEFAULT_LABELS = {
|
|
20
|
+
region: "Sticky metric"
|
|
21
|
+
};
|
|
22
|
+
const StickyMetric = forwardRef(
|
|
23
|
+
(props, ref) => {
|
|
24
|
+
const {
|
|
25
|
+
anchor = "top-right",
|
|
26
|
+
className,
|
|
27
|
+
detail,
|
|
28
|
+
label,
|
|
29
|
+
labels,
|
|
30
|
+
tone = "neutral",
|
|
31
|
+
value,
|
|
32
|
+
x,
|
|
33
|
+
y,
|
|
34
|
+
...rest
|
|
35
|
+
} = props;
|
|
36
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
37
|
+
return /* @__PURE__ */ jsxs(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
"aria-label": resolvedLabels.region,
|
|
41
|
+
className: cn(
|
|
42
|
+
"pointer-events-none absolute z-20 inline-flex items-center gap-1.5 rounded-full border border-border bg-background/90 px-2 py-1 text-[11px] shadow-sm backdrop-blur",
|
|
43
|
+
className
|
|
44
|
+
),
|
|
45
|
+
"data-sticky-anchor": anchor,
|
|
46
|
+
"data-sticky-metric": true,
|
|
47
|
+
"data-sticky-tone": tone,
|
|
48
|
+
ref,
|
|
49
|
+
role: "status",
|
|
50
|
+
style: {
|
|
51
|
+
left: x,
|
|
52
|
+
top: y,
|
|
53
|
+
transform: ANCHOR_OFFSET[anchor].transform
|
|
54
|
+
},
|
|
55
|
+
...rest,
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsx(
|
|
58
|
+
"span",
|
|
59
|
+
{
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
className: cn("h-1.5 w-1.5 rounded-full", TONE_DOT[tone]),
|
|
62
|
+
"data-sticky-metric-dot": true
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: label }),
|
|
66
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold text-foreground", children: value }),
|
|
67
|
+
detail ? /* @__PURE__ */ jsx(
|
|
68
|
+
"span",
|
|
69
|
+
{
|
|
70
|
+
className: "text-[10px] text-muted-foreground",
|
|
71
|
+
"data-sticky-metric-detail": true,
|
|
72
|
+
children: detail
|
|
73
|
+
}
|
|
74
|
+
) : null
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
StickyMetric.displayName = "StickyMetric";
|
|
81
|
+
export {
|
|
82
|
+
StickyMetric
|
|
83
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef
|
|
5
|
+
} from "react";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
const TONE_STROKE = {
|
|
8
|
+
danger: "stroke-red-500",
|
|
9
|
+
neutral: "stroke-foreground",
|
|
10
|
+
success: "stroke-emerald-500",
|
|
11
|
+
warn: "stroke-amber-500"
|
|
12
|
+
};
|
|
13
|
+
const DEFAULT_LABELS = {
|
|
14
|
+
region: "Threshold ring"
|
|
15
|
+
};
|
|
16
|
+
const clamp = (v, min, max) => {
|
|
17
|
+
if (v < min) {
|
|
18
|
+
return min;
|
|
19
|
+
}
|
|
20
|
+
if (v > max) {
|
|
21
|
+
return max;
|
|
22
|
+
}
|
|
23
|
+
return v;
|
|
24
|
+
};
|
|
25
|
+
const polar = (input) => {
|
|
26
|
+
const rad = (input.angle - 90) * (Math.PI / 180);
|
|
27
|
+
return {
|
|
28
|
+
x: input.cx + input.r * Math.cos(rad),
|
|
29
|
+
y: input.cy + input.r * Math.sin(rad)
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const computeGeometry = (input) => {
|
|
33
|
+
const safeMax = input.max <= 0 ? 1 : input.max;
|
|
34
|
+
const ratio = clamp(input.value / safeMax, 0, 1);
|
|
35
|
+
const cx = input.size / 2;
|
|
36
|
+
const cy = input.size / 2;
|
|
37
|
+
const r = (input.size - input.stroke) / 2;
|
|
38
|
+
const circumference = 2 * Math.PI * r;
|
|
39
|
+
const tickAngle = input.threshold === void 0 ? null : clamp(input.threshold / safeMax, 0, 1) * 360;
|
|
40
|
+
return {
|
|
41
|
+
circumference,
|
|
42
|
+
cx,
|
|
43
|
+
cy,
|
|
44
|
+
r,
|
|
45
|
+
ratio,
|
|
46
|
+
size: input.size,
|
|
47
|
+
stroke: input.stroke,
|
|
48
|
+
tickAngle
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const Tick = (props) => {
|
|
52
|
+
const { geom } = props;
|
|
53
|
+
if (geom.tickAngle === null) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const inner = polar({
|
|
57
|
+
angle: geom.tickAngle,
|
|
58
|
+
cx: geom.cx,
|
|
59
|
+
cy: geom.cy,
|
|
60
|
+
r: geom.r - geom.stroke / 2
|
|
61
|
+
});
|
|
62
|
+
const outer = polar({
|
|
63
|
+
angle: geom.tickAngle,
|
|
64
|
+
cx: geom.cx,
|
|
65
|
+
cy: geom.cy,
|
|
66
|
+
r: geom.r + geom.stroke / 2
|
|
67
|
+
});
|
|
68
|
+
return /* @__PURE__ */ jsx(
|
|
69
|
+
"line",
|
|
70
|
+
{
|
|
71
|
+
className: "stroke-foreground/80",
|
|
72
|
+
"data-threshold-ring-tick": true,
|
|
73
|
+
strokeLinecap: "round",
|
|
74
|
+
strokeWidth: 2,
|
|
75
|
+
x1: inner.x,
|
|
76
|
+
x2: outer.x,
|
|
77
|
+
y1: inner.y,
|
|
78
|
+
y2: outer.y
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
const ThresholdRing = forwardRef(
|
|
83
|
+
(props, ref) => {
|
|
84
|
+
const {
|
|
85
|
+
centerLabel,
|
|
86
|
+
className,
|
|
87
|
+
labels,
|
|
88
|
+
max = 1,
|
|
89
|
+
size = 64,
|
|
90
|
+
stroke = 6,
|
|
91
|
+
threshold,
|
|
92
|
+
tone = "neutral",
|
|
93
|
+
value,
|
|
94
|
+
...rest
|
|
95
|
+
} = props;
|
|
96
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
97
|
+
const geom = computeGeometry({ max, size, stroke, threshold, value });
|
|
98
|
+
const dash = `${geom.ratio * geom.circumference} ${geom.circumference}`;
|
|
99
|
+
return /* @__PURE__ */ jsxs(
|
|
100
|
+
"svg",
|
|
101
|
+
{
|
|
102
|
+
"aria-label": resolvedLabels.region,
|
|
103
|
+
className: cn("inline-block", className),
|
|
104
|
+
"data-threshold-ring": true,
|
|
105
|
+
"data-threshold-tone": tone,
|
|
106
|
+
height: geom.size,
|
|
107
|
+
ref,
|
|
108
|
+
role: "img",
|
|
109
|
+
viewBox: `0 0 ${geom.size} ${geom.size}`,
|
|
110
|
+
width: geom.size,
|
|
111
|
+
...rest,
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
"circle",
|
|
115
|
+
{
|
|
116
|
+
className: "stroke-muted",
|
|
117
|
+
cx: geom.cx,
|
|
118
|
+
cy: geom.cy,
|
|
119
|
+
fill: "none",
|
|
120
|
+
r: geom.r,
|
|
121
|
+
strokeWidth: geom.stroke
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
"circle",
|
|
126
|
+
{
|
|
127
|
+
className: cn("transition-all duration-300", TONE_STROKE[tone]),
|
|
128
|
+
cx: geom.cx,
|
|
129
|
+
cy: geom.cy,
|
|
130
|
+
"data-threshold-ring-arc": true,
|
|
131
|
+
fill: "none",
|
|
132
|
+
r: geom.r,
|
|
133
|
+
strokeDasharray: dash,
|
|
134
|
+
strokeLinecap: "round",
|
|
135
|
+
strokeWidth: geom.stroke,
|
|
136
|
+
transform: `rotate(-90 ${geom.cx} ${geom.cy})`
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ jsx(Tick, { geom }),
|
|
140
|
+
centerLabel ? /* @__PURE__ */ jsx(
|
|
141
|
+
"text",
|
|
142
|
+
{
|
|
143
|
+
className: "fill-foreground text-[10px] font-semibold",
|
|
144
|
+
"data-threshold-ring-label": true,
|
|
145
|
+
dominantBaseline: "central",
|
|
146
|
+
textAnchor: "middle",
|
|
147
|
+
x: geom.cx,
|
|
148
|
+
y: geom.cy,
|
|
149
|
+
children: centerLabel
|
|
150
|
+
}
|
|
151
|
+
) : null
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
ThresholdRing.displayName = "ThresholdRing";
|
|
158
|
+
export {
|
|
159
|
+
ThresholdRing
|
|
160
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef,
|
|
5
|
+
useId
|
|
6
|
+
} from "react";
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
|
+
const TONE_FILL = {
|
|
9
|
+
danger: "bg-red-500",
|
|
10
|
+
neutral: "bg-foreground",
|
|
11
|
+
primary: "bg-blue-500",
|
|
12
|
+
success: "bg-emerald-500",
|
|
13
|
+
warn: "bg-amber-500"
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_LABELS = {
|
|
16
|
+
region: "Timeline scrubber"
|
|
17
|
+
};
|
|
18
|
+
const clamp = (v, min, max) => {
|
|
19
|
+
if (v < min) {
|
|
20
|
+
return min;
|
|
21
|
+
}
|
|
22
|
+
if (v > max) {
|
|
23
|
+
return max;
|
|
24
|
+
}
|
|
25
|
+
return v;
|
|
26
|
+
};
|
|
27
|
+
const Labels = (props) => {
|
|
28
|
+
const fmt = props.formatValue;
|
|
29
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
30
|
+
/* @__PURE__ */ jsx("span", { "data-timeline-scrubber-start": true, children: fmt ? fmt(props.start) : props.start }),
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
"span",
|
|
33
|
+
{
|
|
34
|
+
className: "font-semibold text-foreground",
|
|
35
|
+
"data-timeline-scrubber-cursor": true,
|
|
36
|
+
children: fmt ? fmt(props.clamped) : props.clamped
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ jsx("span", { "data-timeline-scrubber-end": true, children: fmt ? fmt(props.end) : props.end })
|
|
40
|
+
] });
|
|
41
|
+
};
|
|
42
|
+
const Track = (props) => /* @__PURE__ */ jsxs("div", { className: "relative h-6", children: [
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
"span",
|
|
45
|
+
{
|
|
46
|
+
"aria-hidden": "true",
|
|
47
|
+
className: "absolute left-0 right-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-muted"
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
"span",
|
|
52
|
+
{
|
|
53
|
+
"aria-hidden": "true",
|
|
54
|
+
className: cn(
|
|
55
|
+
"absolute left-0 top-1/2 h-1 -translate-y-1/2 rounded-full",
|
|
56
|
+
TONE_FILL[props.tone]
|
|
57
|
+
),
|
|
58
|
+
"data-timeline-scrubber-fill": true,
|
|
59
|
+
style: { width: `${props.ratio * 100}%` }
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
props.ticks?.map((tick) => /* @__PURE__ */ jsx(
|
|
63
|
+
TickMark,
|
|
64
|
+
{
|
|
65
|
+
scrubberId: props.scrubberId,
|
|
66
|
+
span: props.span,
|
|
67
|
+
start: props.start,
|
|
68
|
+
tick
|
|
69
|
+
},
|
|
70
|
+
tick.id
|
|
71
|
+
)),
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
"input",
|
|
74
|
+
{
|
|
75
|
+
"aria-label": props.ariaLabel,
|
|
76
|
+
className: "absolute inset-0 h-full w-full cursor-pointer appearance-none bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
77
|
+
"data-timeline-scrubber-input": true,
|
|
78
|
+
id: props.inputId,
|
|
79
|
+
max: props.max,
|
|
80
|
+
min: props.min,
|
|
81
|
+
onChange: props.onChange,
|
|
82
|
+
step: props.step,
|
|
83
|
+
type: "range",
|
|
84
|
+
value: props.value
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] });
|
|
88
|
+
const TickMark = (props) => {
|
|
89
|
+
const { scrubberId, span, start, tick } = props;
|
|
90
|
+
const ratio = clamp((tick.value - start) / span, 0, 1);
|
|
91
|
+
const tone = tick.tone ?? "neutral";
|
|
92
|
+
return /* @__PURE__ */ jsx(
|
|
93
|
+
"span",
|
|
94
|
+
{
|
|
95
|
+
"aria-hidden": "true",
|
|
96
|
+
className: cn(
|
|
97
|
+
"absolute top-1/2 h-2.5 w-px -translate-y-1/2 rounded-full",
|
|
98
|
+
TONE_FILL[tone]
|
|
99
|
+
),
|
|
100
|
+
"data-scrubber-tick": tick.id,
|
|
101
|
+
"data-scrubber-tick-of": scrubberId,
|
|
102
|
+
"data-scrubber-tick-tone": tone,
|
|
103
|
+
style: { left: `${ratio * 100}%` },
|
|
104
|
+
title: typeof tick.label === "string" ? tick.label : void 0
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
const TimelineScrubber = forwardRef((props, ref) => {
|
|
109
|
+
const {
|
|
110
|
+
className,
|
|
111
|
+
end,
|
|
112
|
+
formatValue,
|
|
113
|
+
labels,
|
|
114
|
+
onValueChange,
|
|
115
|
+
start,
|
|
116
|
+
step = 1,
|
|
117
|
+
ticks,
|
|
118
|
+
tone = "primary",
|
|
119
|
+
value,
|
|
120
|
+
...rest
|
|
121
|
+
} = props;
|
|
122
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
123
|
+
const inputId = useId();
|
|
124
|
+
const safeEnd = end <= start ? start + 1 : end;
|
|
125
|
+
const span = safeEnd - start;
|
|
126
|
+
const clamped = clamp(value, start, safeEnd);
|
|
127
|
+
const ratio = clamp((clamped - start) / span, 0, 1);
|
|
128
|
+
const handleChange = (event) => {
|
|
129
|
+
onValueChange(clamp(Number(event.target.value), start, safeEnd));
|
|
130
|
+
};
|
|
131
|
+
return /* @__PURE__ */ jsxs(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
"aria-label": resolvedLabels.region,
|
|
135
|
+
className: cn(
|
|
136
|
+
"flex w-full flex-col gap-1 text-[11px] text-muted-foreground",
|
|
137
|
+
className
|
|
138
|
+
),
|
|
139
|
+
"data-timeline-scrubber": true,
|
|
140
|
+
"data-timeline-tone": tone,
|
|
141
|
+
ref,
|
|
142
|
+
role: "group",
|
|
143
|
+
...rest,
|
|
144
|
+
children: [
|
|
145
|
+
/* @__PURE__ */ jsx(
|
|
146
|
+
Labels,
|
|
147
|
+
{
|
|
148
|
+
clamped,
|
|
149
|
+
end: safeEnd,
|
|
150
|
+
formatValue,
|
|
151
|
+
start
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ jsx(
|
|
155
|
+
Track,
|
|
156
|
+
{
|
|
157
|
+
ariaLabel: resolvedLabels.region,
|
|
158
|
+
inputId,
|
|
159
|
+
max: safeEnd,
|
|
160
|
+
min: start,
|
|
161
|
+
onChange: handleChange,
|
|
162
|
+
ratio,
|
|
163
|
+
scrubberId: inputId,
|
|
164
|
+
span,
|
|
165
|
+
start,
|
|
166
|
+
step,
|
|
167
|
+
ticks,
|
|
168
|
+
tone,
|
|
169
|
+
value: clamped
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
TimelineScrubber.displayName = "TimelineScrubber";
|
|
177
|
+
export {
|
|
178
|
+
TimelineScrubber
|
|
179
|
+
};
|