@behavioral-agentic-design-system/core 0.13.0 → 0.15.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.
- package/package.json +1 -1
- package/src/app/preview/components/page.tsx +989 -6
- package/src/components/ui/bottom-sheet.tsx +10 -1
- package/src/components/ui/carousel.tsx +1 -1
- package/src/components/ui/color-picker.tsx +219 -0
- package/src/components/ui/date-range-picker.tsx +174 -0
- package/src/components/ui/index.ts +6 -0
- package/src/components/ui/password-input.tsx +150 -0
- package/src/components/ui/segmented-control.tsx +213 -0
- package/src/components/ui/stepper.tsx +11 -3
- package/src/components/ui/tabs.tsx +1 -1
- package/src/components/ui/tags-input.tsx +199 -0
- package/src/components/ui/time-picker.tsx +363 -0
- package/src/components/ui/timeline.tsx +171 -0
- package/src/components/ui/tree-view.tsx +405 -0
- package/src/data/docs-index.ts +1 -0
- package/src/lib/brand-mark-tone.ts +56 -2
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { XIcon } from "lucide-react"
|
|
5
|
+
import { cn } from "../../lib/utils"
|
|
6
|
+
|
|
7
|
+
export interface TimePickerProps {
|
|
8
|
+
value?: string
|
|
9
|
+
onValueChange?: (value: string | undefined) => void
|
|
10
|
+
placeholder?: string
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
clearable?: boolean
|
|
13
|
+
size?: "sm" | "default" | "lg"
|
|
14
|
+
hours12?: boolean
|
|
15
|
+
showSeconds?: boolean
|
|
16
|
+
className?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const sizeMap = {
|
|
20
|
+
sm: { height: "h-8", px: "px-2.5", text: "text-sm", gap: "gap-1", icon: 14 },
|
|
21
|
+
default: { height: "h-9", px: "px-3", text: "text-sm", gap: "gap-1.5", icon: 16 },
|
|
22
|
+
lg: { height: "h-10", px: "px-4", text: "text-base", gap: "gap-2", icon: 16 },
|
|
23
|
+
} as const
|
|
24
|
+
|
|
25
|
+
function pad2(n: number) {
|
|
26
|
+
return String(n).padStart(2, "0")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function parseTime(value?: string): { h: number; m: number; s: number } | null {
|
|
30
|
+
if (!value) return null
|
|
31
|
+
const parts = value.split(":").map(Number)
|
|
32
|
+
if (parts.length < 2 || parts.some(isNaN)) return null
|
|
33
|
+
return { h: parts[0], m: parts[1], s: parts[2] ?? 0 }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function formatTime(h: number, m: number, s: number, showSeconds: boolean): string {
|
|
37
|
+
return showSeconds ? `${pad2(h)}:${pad2(m)}:${pad2(s)}` : `${pad2(h)}:${pad2(m)}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type Segment = "h" | "m" | "s" | "ampm"
|
|
41
|
+
|
|
42
|
+
function TimePicker({
|
|
43
|
+
value,
|
|
44
|
+
onValueChange,
|
|
45
|
+
placeholder = "--:--",
|
|
46
|
+
disabled = false,
|
|
47
|
+
clearable = false,
|
|
48
|
+
size = "default",
|
|
49
|
+
hours12 = false,
|
|
50
|
+
showSeconds = false,
|
|
51
|
+
className,
|
|
52
|
+
}: TimePickerProps) {
|
|
53
|
+
const isControlled = value !== undefined || onValueChange !== undefined
|
|
54
|
+
const [internalValue, setInternalValue] = React.useState<string | undefined>(undefined)
|
|
55
|
+
const resolvedValue = isControlled ? value : internalValue
|
|
56
|
+
|
|
57
|
+
const parsed = parseTime(resolvedValue)
|
|
58
|
+
const [h, setH] = React.useState(parsed?.h ?? 0)
|
|
59
|
+
const [m, setM] = React.useState(parsed?.m ?? 0)
|
|
60
|
+
const [s, setS] = React.useState(parsed?.s ?? 0)
|
|
61
|
+
const [active, setActive] = React.useState<Segment | null>(null)
|
|
62
|
+
const [digitBuffer, setDigitBuffer] = React.useState("")
|
|
63
|
+
const [hasValue, setHasValue] = React.useState(!!parsed)
|
|
64
|
+
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
const p = parseTime(resolvedValue)
|
|
67
|
+
if (p) {
|
|
68
|
+
setH(p.h)
|
|
69
|
+
setM(p.m)
|
|
70
|
+
setS(p.s)
|
|
71
|
+
setHasValue(true)
|
|
72
|
+
} else if (resolvedValue === undefined || resolvedValue === "") {
|
|
73
|
+
setHasValue(false)
|
|
74
|
+
}
|
|
75
|
+
}, [resolvedValue])
|
|
76
|
+
|
|
77
|
+
function commit(nh: number, nm: number, ns: number) {
|
|
78
|
+
const str = formatTime(nh, nm, ns, showSeconds)
|
|
79
|
+
setHasValue(true)
|
|
80
|
+
if (!isControlled) setInternalValue(str)
|
|
81
|
+
onValueChange?.(str)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function handleClear(e: React.MouseEvent) {
|
|
85
|
+
e.stopPropagation()
|
|
86
|
+
setHasValue(false)
|
|
87
|
+
setH(0)
|
|
88
|
+
setM(0)
|
|
89
|
+
setS(0)
|
|
90
|
+
if (!isControlled) setInternalValue(undefined)
|
|
91
|
+
onValueChange?.(undefined)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const isPM = h >= 12
|
|
95
|
+
const displayH = hours12 ? (h === 0 ? 12 : h > 12 ? h - 12 : h) : h
|
|
96
|
+
|
|
97
|
+
function adjustH(delta: number) {
|
|
98
|
+
const nh = (h + delta + 24) % 24
|
|
99
|
+
setH(nh)
|
|
100
|
+
commit(nh, m, s)
|
|
101
|
+
}
|
|
102
|
+
function adjustM(delta: number) {
|
|
103
|
+
const nm = (m + delta + 60) % 60
|
|
104
|
+
setM(nm)
|
|
105
|
+
commit(h, nm, s)
|
|
106
|
+
}
|
|
107
|
+
function adjustS(delta: number) {
|
|
108
|
+
const ns = (s + delta + 60) % 60
|
|
109
|
+
setS(ns)
|
|
110
|
+
commit(h, m, ns)
|
|
111
|
+
}
|
|
112
|
+
function toggleAMPM() {
|
|
113
|
+
const nh = h >= 12 ? h - 12 : h + 12
|
|
114
|
+
setH(nh)
|
|
115
|
+
commit(nh, m, s)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function handleSegmentKeyDown(seg: Segment, e: React.KeyboardEvent) {
|
|
119
|
+
if (e.key === "ArrowUp") {
|
|
120
|
+
e.preventDefault()
|
|
121
|
+
if (seg === "h") adjustH(1)
|
|
122
|
+
else if (seg === "m") adjustM(1)
|
|
123
|
+
else if (seg === "s") adjustS(1)
|
|
124
|
+
else if (seg === "ampm") toggleAMPM()
|
|
125
|
+
} else if (e.key === "ArrowDown") {
|
|
126
|
+
e.preventDefault()
|
|
127
|
+
if (seg === "h") adjustH(-1)
|
|
128
|
+
else if (seg === "m") adjustM(-1)
|
|
129
|
+
else if (seg === "s") adjustS(-1)
|
|
130
|
+
else if (seg === "ampm") toggleAMPM()
|
|
131
|
+
} else if (e.key >= "0" && e.key <= "9" && seg !== "ampm") {
|
|
132
|
+
e.preventDefault()
|
|
133
|
+
const digit = Number(e.key)
|
|
134
|
+
const newBuf = digitBuffer + String(digit)
|
|
135
|
+
const val = parseInt(newBuf, 10)
|
|
136
|
+
if (seg === "h") {
|
|
137
|
+
if (hours12) {
|
|
138
|
+
if (newBuf.length === 1 && digit > 1) {
|
|
139
|
+
const nh = isPM ? digit + 12 : digit
|
|
140
|
+
setH(nh)
|
|
141
|
+
commit(nh, m, s)
|
|
142
|
+
setDigitBuffer("")
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
const clamped = Math.min(val, 12)
|
|
146
|
+
const nh =
|
|
147
|
+
clamped === 0
|
|
148
|
+
? isPM ? 12 : 0
|
|
149
|
+
: isPM
|
|
150
|
+
? clamped === 12
|
|
151
|
+
? 12
|
|
152
|
+
: clamped + 12
|
|
153
|
+
: clamped === 12
|
|
154
|
+
? 0
|
|
155
|
+
: clamped
|
|
156
|
+
if (newBuf.length >= 2) {
|
|
157
|
+
setH(nh)
|
|
158
|
+
commit(nh, m, s)
|
|
159
|
+
setDigitBuffer("")
|
|
160
|
+
} else {
|
|
161
|
+
setDigitBuffer(newBuf)
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
if (val > 2 || newBuf.length >= 2) {
|
|
165
|
+
const nh = Math.min(val, 23)
|
|
166
|
+
setH(nh)
|
|
167
|
+
commit(nh, m, s)
|
|
168
|
+
setDigitBuffer("")
|
|
169
|
+
} else {
|
|
170
|
+
setDigitBuffer(newBuf)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
} else if (seg === "m" || seg === "s") {
|
|
174
|
+
if (digit > 5 || newBuf.length >= 2) {
|
|
175
|
+
const nv = Math.min(val, 59)
|
|
176
|
+
if (seg === "m") {
|
|
177
|
+
setM(nv)
|
|
178
|
+
commit(h, nv, s)
|
|
179
|
+
} else {
|
|
180
|
+
setS(nv)
|
|
181
|
+
commit(h, m, nv)
|
|
182
|
+
}
|
|
183
|
+
setDigitBuffer("")
|
|
184
|
+
} else {
|
|
185
|
+
setDigitBuffer(newBuf)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
setDigitBuffer("")
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const { height, px, text, gap, icon: iconSize } = sizeMap[size]
|
|
194
|
+
const segClass = cn(
|
|
195
|
+
"inline-flex items-center justify-center rounded px-0.5 outline-none select-none tabular-nums",
|
|
196
|
+
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:bg-accent",
|
|
197
|
+
"transition-colors",
|
|
198
|
+
text
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<div
|
|
203
|
+
data-slot="time-picker"
|
|
204
|
+
data-size={size}
|
|
205
|
+
role="group"
|
|
206
|
+
aria-label="Time input"
|
|
207
|
+
aria-disabled={disabled}
|
|
208
|
+
className={cn(
|
|
209
|
+
"inline-flex w-full min-w-0 items-center rounded-md border border-input bg-transparent shadow-xs",
|
|
210
|
+
"focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50",
|
|
211
|
+
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
212
|
+
height,
|
|
213
|
+
px,
|
|
214
|
+
gap,
|
|
215
|
+
className
|
|
216
|
+
)}
|
|
217
|
+
>
|
|
218
|
+
{!hasValue ? (
|
|
219
|
+
<span
|
|
220
|
+
tabIndex={disabled ? -1 : 0}
|
|
221
|
+
className={cn(
|
|
222
|
+
"flex-1 text-muted-foreground cursor-text outline-none",
|
|
223
|
+
text
|
|
224
|
+
)}
|
|
225
|
+
onFocus={() => {
|
|
226
|
+
setActive("h")
|
|
227
|
+
setHasValue(true)
|
|
228
|
+
}}
|
|
229
|
+
onClick={() => {
|
|
230
|
+
setActive("h")
|
|
231
|
+
setHasValue(true)
|
|
232
|
+
}}
|
|
233
|
+
>
|
|
234
|
+
{placeholder}
|
|
235
|
+
</span>
|
|
236
|
+
) : (
|
|
237
|
+
<span className={cn("inline-flex items-center", gap)}>
|
|
238
|
+
<span
|
|
239
|
+
role="spinbutton"
|
|
240
|
+
aria-label="Hours"
|
|
241
|
+
aria-valuenow={displayH}
|
|
242
|
+
aria-valuemin={hours12 ? 1 : 0}
|
|
243
|
+
aria-valuemax={hours12 ? 12 : 23}
|
|
244
|
+
aria-valuetext={pad2(displayH)}
|
|
245
|
+
tabIndex={disabled ? -1 : 0}
|
|
246
|
+
className={cn(segClass, active === "h" && "bg-accent")}
|
|
247
|
+
onFocus={() => setActive("h")}
|
|
248
|
+
onBlur={() => {
|
|
249
|
+
setActive(null)
|
|
250
|
+
setDigitBuffer("")
|
|
251
|
+
}}
|
|
252
|
+
onKeyDown={(e) => handleSegmentKeyDown("h", e)}
|
|
253
|
+
style={{
|
|
254
|
+
transitionDuration: "var(--duration-fast)",
|
|
255
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
258
|
+
{pad2(displayH)}
|
|
259
|
+
</span>
|
|
260
|
+
<span aria-hidden className={cn("text-muted-foreground", text)}>
|
|
261
|
+
:
|
|
262
|
+
</span>
|
|
263
|
+
<span
|
|
264
|
+
role="spinbutton"
|
|
265
|
+
aria-label="Minutes"
|
|
266
|
+
aria-valuenow={m}
|
|
267
|
+
aria-valuemin={0}
|
|
268
|
+
aria-valuemax={59}
|
|
269
|
+
aria-valuetext={pad2(m)}
|
|
270
|
+
tabIndex={disabled ? -1 : 0}
|
|
271
|
+
className={cn(segClass, active === "m" && "bg-accent")}
|
|
272
|
+
onFocus={() => setActive("m")}
|
|
273
|
+
onBlur={() => {
|
|
274
|
+
setActive(null)
|
|
275
|
+
setDigitBuffer("")
|
|
276
|
+
}}
|
|
277
|
+
onKeyDown={(e) => handleSegmentKeyDown("m", e)}
|
|
278
|
+
style={{
|
|
279
|
+
transitionDuration: "var(--duration-fast)",
|
|
280
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
281
|
+
}}
|
|
282
|
+
>
|
|
283
|
+
{pad2(m)}
|
|
284
|
+
</span>
|
|
285
|
+
{showSeconds && (
|
|
286
|
+
<>
|
|
287
|
+
<span aria-hidden className={cn("text-muted-foreground", text)}>
|
|
288
|
+
:
|
|
289
|
+
</span>
|
|
290
|
+
<span
|
|
291
|
+
role="spinbutton"
|
|
292
|
+
aria-label="Seconds"
|
|
293
|
+
aria-valuenow={s}
|
|
294
|
+
aria-valuemin={0}
|
|
295
|
+
aria-valuemax={59}
|
|
296
|
+
aria-valuetext={pad2(s)}
|
|
297
|
+
tabIndex={disabled ? -1 : 0}
|
|
298
|
+
className={cn(segClass, active === "s" && "bg-accent")}
|
|
299
|
+
onFocus={() => setActive("s")}
|
|
300
|
+
onBlur={() => {
|
|
301
|
+
setActive(null)
|
|
302
|
+
setDigitBuffer("")
|
|
303
|
+
}}
|
|
304
|
+
onKeyDown={(e) => handleSegmentKeyDown("s", e)}
|
|
305
|
+
style={{
|
|
306
|
+
transitionDuration: "var(--duration-fast)",
|
|
307
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
308
|
+
}}
|
|
309
|
+
>
|
|
310
|
+
{pad2(s)}
|
|
311
|
+
</span>
|
|
312
|
+
</>
|
|
313
|
+
)}
|
|
314
|
+
{hours12 && (
|
|
315
|
+
<button
|
|
316
|
+
type="button"
|
|
317
|
+
role="spinbutton"
|
|
318
|
+
aria-label="AM/PM"
|
|
319
|
+
aria-valuenow={isPM ? 1 : 0}
|
|
320
|
+
aria-valuemin={0}
|
|
321
|
+
aria-valuemax={1}
|
|
322
|
+
aria-valuetext={isPM ? "PM" : "AM"}
|
|
323
|
+
tabIndex={disabled ? -1 : 0}
|
|
324
|
+
disabled={disabled}
|
|
325
|
+
onClick={toggleAMPM}
|
|
326
|
+
onFocus={() => setActive("ampm")}
|
|
327
|
+
onBlur={() => setActive(null)}
|
|
328
|
+
onKeyDown={(e) => handleSegmentKeyDown("ampm", e)}
|
|
329
|
+
className={cn(
|
|
330
|
+
segClass,
|
|
331
|
+
"cursor-pointer hover:bg-accent",
|
|
332
|
+
active === "ampm" && "bg-accent"
|
|
333
|
+
)}
|
|
334
|
+
style={{
|
|
335
|
+
transitionDuration: "var(--duration-fast)",
|
|
336
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
337
|
+
}}
|
|
338
|
+
>
|
|
339
|
+
{isPM ? "PM" : "AM"}
|
|
340
|
+
</button>
|
|
341
|
+
)}
|
|
342
|
+
</span>
|
|
343
|
+
)}
|
|
344
|
+
{clearable && hasValue && (
|
|
345
|
+
<button
|
|
346
|
+
type="button"
|
|
347
|
+
aria-label="Clear time"
|
|
348
|
+
onClick={handleClear}
|
|
349
|
+
disabled={disabled}
|
|
350
|
+
className="shrink-0 -mr-1 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
351
|
+
style={{
|
|
352
|
+
transitionDuration: "var(--duration-fast)",
|
|
353
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
354
|
+
}}
|
|
355
|
+
>
|
|
356
|
+
<XIcon size={iconSize - 2} strokeWidth={1.5} />
|
|
357
|
+
</button>
|
|
358
|
+
)}
|
|
359
|
+
</div>
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export { TimePicker }
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { CheckIcon } from "lucide-react";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
|
|
8
|
+
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
export type TimelineStatus = "default" | "complete" | "active" | "pending";
|
|
11
|
+
|
|
12
|
+
// ─── Variants ─────────────────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
const dotVariants = cva(
|
|
15
|
+
[
|
|
16
|
+
"absolute left-0 top-1 flex size-5 items-center justify-center",
|
|
17
|
+
"rounded-full border-2 ring-offset-background",
|
|
18
|
+
],
|
|
19
|
+
{
|
|
20
|
+
variants: {
|
|
21
|
+
status: {
|
|
22
|
+
default: "border-border bg-background",
|
|
23
|
+
complete: "border-primary bg-primary text-primary-foreground",
|
|
24
|
+
active: "border-primary bg-primary text-primary-foreground",
|
|
25
|
+
pending: "border-border/40 bg-muted",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: { status: "default" },
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// ─── Root ─────────────────────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
export interface TimelineProps extends React.HTMLAttributes<HTMLOListElement> {}
|
|
35
|
+
|
|
36
|
+
export function Timeline({ className, children, ...props }: TimelineProps) {
|
|
37
|
+
return (
|
|
38
|
+
<ol
|
|
39
|
+
data-slot="timeline"
|
|
40
|
+
className={cn("relative space-y-0", className)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
{children}
|
|
44
|
+
</ol>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ─── Item ─────────────────────────────────────────────────────────────────────
|
|
49
|
+
|
|
50
|
+
export interface TimelineItemProps extends Omit<React.HTMLAttributes<HTMLLIElement>, "title"> {
|
|
51
|
+
/** Semantic status: affects dot fill and connector visibility. */
|
|
52
|
+
status?: TimelineStatus;
|
|
53
|
+
/**
|
|
54
|
+
* Icon inside the dot. For `status="complete"` defaults to a check mark.
|
|
55
|
+
* Pass `null` to render an empty dot. Pass any ReactNode for a custom icon.
|
|
56
|
+
*/
|
|
57
|
+
icon?: React.ReactNode | null;
|
|
58
|
+
/** Primary label for this event. */
|
|
59
|
+
title?: React.ReactNode;
|
|
60
|
+
/** Secondary detail text. Ignored when `children` is provided. */
|
|
61
|
+
description?: React.ReactNode;
|
|
62
|
+
/** Human-readable timestamp label (e.g. "2 hours ago", "Jun 24"). */
|
|
63
|
+
time?: React.ReactNode;
|
|
64
|
+
/**
|
|
65
|
+
* Machine-readable datetime value (ISO 8601). When provided, the time is
|
|
66
|
+
* rendered as `<time datetime="...">` for screen readers. Without it,
|
|
67
|
+
* a `<span>` is used to avoid axe `time-datetime` violations.
|
|
68
|
+
*/
|
|
69
|
+
dateTime?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function TimelineItem({
|
|
73
|
+
status = "default",
|
|
74
|
+
icon,
|
|
75
|
+
title,
|
|
76
|
+
description,
|
|
77
|
+
time,
|
|
78
|
+
dateTime,
|
|
79
|
+
className,
|
|
80
|
+
children,
|
|
81
|
+
...props
|
|
82
|
+
}: TimelineItemProps) {
|
|
83
|
+
// Default icon: check mark for complete, nothing for others
|
|
84
|
+
const resolvedIcon =
|
|
85
|
+
icon !== undefined
|
|
86
|
+
? icon
|
|
87
|
+
: status === "complete"
|
|
88
|
+
? <CheckIcon className="size-3" strokeWidth={1.5} aria-hidden />
|
|
89
|
+
: null;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<li
|
|
93
|
+
data-slot="timeline-item"
|
|
94
|
+
data-status={status}
|
|
95
|
+
className={cn("group relative pb-6 pl-8 last:pb-0", className)}
|
|
96
|
+
{...props}
|
|
97
|
+
>
|
|
98
|
+
{/* Connector line: runs from below the dot to the bottom of the item.
|
|
99
|
+
group-last:hidden removes it on the final item so there's no dangling line. */}
|
|
100
|
+
<span
|
|
101
|
+
aria-hidden
|
|
102
|
+
data-slot="timeline-connector"
|
|
103
|
+
className={cn(
|
|
104
|
+
"absolute left-[9px] top-5 bottom-0 w-px",
|
|
105
|
+
"group-last:hidden",
|
|
106
|
+
status === "pending" ? "bg-border/30" : "bg-border"
|
|
107
|
+
)}
|
|
108
|
+
style={{
|
|
109
|
+
transitionProperty: "background-color",
|
|
110
|
+
transitionDuration: "var(--duration-fast)",
|
|
111
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
|
|
115
|
+
{/* Dot */}
|
|
116
|
+
<span
|
|
117
|
+
aria-hidden
|
|
118
|
+
data-slot="timeline-dot"
|
|
119
|
+
className={cn(dotVariants({ status }))}
|
|
120
|
+
style={{
|
|
121
|
+
transitionProperty: "background-color, border-color",
|
|
122
|
+
transitionDuration: "var(--duration-fast)",
|
|
123
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
{resolvedIcon}
|
|
127
|
+
</span>
|
|
128
|
+
|
|
129
|
+
{/* Content */}
|
|
130
|
+
<div data-slot="timeline-content" className="min-w-0 pt-0.5">
|
|
131
|
+
{title && (
|
|
132
|
+
<p
|
|
133
|
+
data-slot="timeline-title"
|
|
134
|
+
className={cn(
|
|
135
|
+
"text-sm font-medium leading-5",
|
|
136
|
+
status === "pending" && "text-muted-foreground"
|
|
137
|
+
)}
|
|
138
|
+
>
|
|
139
|
+
{title}
|
|
140
|
+
</p>
|
|
141
|
+
)}
|
|
142
|
+
{(children != null || description != null) && (
|
|
143
|
+
<div
|
|
144
|
+
data-slot="timeline-description"
|
|
145
|
+
className="mt-0.5 text-sm text-muted-foreground"
|
|
146
|
+
>
|
|
147
|
+
{children ?? description}
|
|
148
|
+
</div>
|
|
149
|
+
)}
|
|
150
|
+
{time != null && (
|
|
151
|
+
dateTime != null ? (
|
|
152
|
+
<time
|
|
153
|
+
data-slot="timeline-time"
|
|
154
|
+
dateTime={dateTime}
|
|
155
|
+
className="mt-1 block text-xs text-muted-foreground"
|
|
156
|
+
>
|
|
157
|
+
{time}
|
|
158
|
+
</time>
|
|
159
|
+
) : (
|
|
160
|
+
<span
|
|
161
|
+
data-slot="timeline-time"
|
|
162
|
+
className="mt-1 block text-xs text-muted-foreground"
|
|
163
|
+
>
|
|
164
|
+
{time}
|
|
165
|
+
</span>
|
|
166
|
+
)
|
|
167
|
+
)}
|
|
168
|
+
</div>
|
|
169
|
+
</li>
|
|
170
|
+
);
|
|
171
|
+
}
|