@behavioral-agentic-design-system/core 0.13.0 → 0.14.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@behavioral-agentic-design-system/core",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
5
5
  "license": "MIT",
6
6
  "author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
@@ -149,9 +149,13 @@ import {
149
149
  HoverCardDescription,
150
150
  HoverCardTrigger,
151
151
  } from "@behavioral-agentic-design-system/core/components/ui/hover-card";
152
- import { Sparkles, Info, CircleAlert, CalendarIcon, BuildingIcon } from "lucide-react";
152
+ import { Sparkles, Info, CircleAlert, CalendarIcon, BuildingIcon, CheckIcon, CreditCardIcon, ClipboardCheckIcon, TrophyIcon, UserCheckIcon } from "lucide-react";
153
153
  import { DatePicker } from "@behavioral-agentic-design-system/core/components/ui/date-picker";
154
154
  import { RatingGroup } from "@behavioral-agentic-design-system/core/components/ui/rating-group";
155
+ import { SegmentedControl, SegmentedControlItem } from "@behavioral-agentic-design-system/core/components/ui/segmented-control";
156
+ import { Timeline, TimelineItem } from "@behavioral-agentic-design-system/core/components/ui/timeline";
157
+ import { TagsInput } from "@behavioral-agentic-design-system/core/components/ui/tags-input";
158
+
155
159
  import { Toaster } from "@behavioral-agentic-design-system/core/components/ui/sonner";
156
160
  import { toast } from "sonner";
157
161
 
@@ -583,6 +587,10 @@ export default function ComponentsPreview() {
583
587
  </ScrollArea>
584
588
  </Section>
585
589
 
590
+ <Section title="SegmentedControl">
591
+ <SegmentedControlShowcase />
592
+ </Section>
593
+
586
594
  <Section title="BottomSheet">
587
595
  <div className="flex flex-wrap gap-3">
588
596
  {/* Default — grab handle + close button */}
@@ -1653,6 +1661,89 @@ export default function ComponentsPreview() {
1653
1661
  </div>
1654
1662
  </div>
1655
1663
  </Section>
1664
+
1665
+ <Section title="TagsInput">
1666
+ <div className="space-y-6">
1667
+ <div className="space-y-3">
1668
+ <p className="text-sm font-medium text-muted-foreground">Default — empty</p>
1669
+ <TagsInputShowcase placeholder="Add a tag…" />
1670
+ </div>
1671
+ <div className="space-y-3">
1672
+ <p className="text-sm font-medium text-muted-foreground">With initial tags</p>
1673
+ <TagsInputShowcase
1674
+ initialTags={["butterfly", "freestyle", "backstroke"]}
1675
+ placeholder="Add stroke…"
1676
+ />
1677
+ </div>
1678
+ <div className="space-y-3">
1679
+ <p className="text-sm font-medium text-muted-foreground">Max tags (4)</p>
1680
+ <TagsInputShowcase
1681
+ initialTags={["warm-up", "main set"]}
1682
+ maxTags={4}
1683
+ placeholder="Add phase (max 4)…"
1684
+ />
1685
+ </div>
1686
+ <div className="space-y-3">
1687
+ <p className="text-sm font-medium text-muted-foreground">Disabled</p>
1688
+ <TagsInputShowcase
1689
+ initialTags={["100m freestyle", "200m backstroke"]}
1690
+ disabled
1691
+ placeholder="Disabled"
1692
+ />
1693
+ </div>
1694
+ <div className="space-y-3">
1695
+ <p className="text-sm font-medium text-muted-foreground">Realistic use — Breezy Hills Aquatic Club session filters</p>
1696
+ <TagsInputFilterDemo />
1697
+ </div>
1698
+ </div>
1699
+ </Section>
1700
+
1701
+ <Section title="Timeline">
1702
+ <div className="space-y-8">
1703
+ <div className="space-y-3">
1704
+ <p className="text-sm font-medium text-muted-foreground">Status variants</p>
1705
+ <Timeline>
1706
+ <TimelineItem status="complete" title="Complete" description="Step is done." time="Yesterday" />
1707
+ <TimelineItem status="active" title="Active" description="Currently in progress." time="Today" />
1708
+ <TimelineItem status="default" title="Default" description="No semantic status." />
1709
+ <TimelineItem status="pending" title="Pending" description="Not yet started." time="Next week" />
1710
+ </Timeline>
1711
+ </div>
1712
+ <div className="space-y-3">
1713
+ <p className="text-sm font-medium text-muted-foreground">With icons</p>
1714
+ <Timeline>
1715
+ <TimelineItem
1716
+ status="complete"
1717
+ icon={<CheckIcon className="size-3" strokeWidth={1.5} aria-hidden />}
1718
+ title="Registration confirmed"
1719
+ time="Jun 20"
1720
+ />
1721
+ <TimelineItem
1722
+ status="complete"
1723
+ icon={<CreditCardIcon className="size-3" strokeWidth={1.5} aria-hidden />}
1724
+ title="Payment received"
1725
+ time="Jun 21"
1726
+ />
1727
+ <TimelineItem
1728
+ status="active"
1729
+ title="Heat assignment"
1730
+ description="Times submitted to meet director"
1731
+ time="Jun 25 (today)"
1732
+ />
1733
+ <TimelineItem
1734
+ status="pending"
1735
+ title="Meet day"
1736
+ description="Breezy Hills Aquatic Center"
1737
+ time="Jun 28"
1738
+ />
1739
+ </Timeline>
1740
+ </div>
1741
+ <div className="space-y-3">
1742
+ <p className="text-sm font-medium text-muted-foreground">Realistic use — athlete registration journey</p>
1743
+ <TimelineRealisticDemo />
1744
+ </div>
1745
+ </div>
1746
+ </Section>
1656
1747
  </div>
1657
1748
  </div>
1658
1749
  );
@@ -1735,6 +1826,111 @@ function RatingGroupShowcase({
1735
1826
  return <RatingGroup size={size} value={value} onValueChange={setValue} label={label} />;
1736
1827
  }
1737
1828
 
1829
+ function SegmentedControlShowcase() {
1830
+ const [view, setView] = React.useState("grid");
1831
+ const [period, setPeriod] = React.useState("month");
1832
+ const [filter, setFilter] = React.useState("active");
1833
+ return (
1834
+ <div className="flex flex-col gap-6">
1835
+ <div className="flex flex-col gap-4">
1836
+ <p className="text-sm font-medium text-muted-foreground">Size sm</p>
1837
+ <SegmentedControl value={period} onValueChange={setPeriod} size="sm" label="Time period">
1838
+ <SegmentedControlItem value="day">Day</SegmentedControlItem>
1839
+ <SegmentedControlItem value="week">Week</SegmentedControlItem>
1840
+ <SegmentedControlItem value="month">Month</SegmentedControlItem>
1841
+ </SegmentedControl>
1842
+
1843
+ <p className="text-sm font-medium text-muted-foreground">Default — view toggle</p>
1844
+ <SegmentedControl value={view} onValueChange={setView} label="View">
1845
+ <SegmentedControlItem value="list">List</SegmentedControlItem>
1846
+ <SegmentedControlItem value="grid">Grid</SegmentedControlItem>
1847
+ <SegmentedControlItem value="map">Map</SegmentedControlItem>
1848
+ </SegmentedControl>
1849
+
1850
+ <p className="text-sm font-medium text-muted-foreground">With disabled item</p>
1851
+ <SegmentedControl value={filter} onValueChange={setFilter} label="Filter">
1852
+ <SegmentedControlItem value="all">All</SegmentedControlItem>
1853
+ <SegmentedControlItem value="active">Active</SegmentedControlItem>
1854
+ <SegmentedControlItem value="archived">Archived</SegmentedControlItem>
1855
+ <SegmentedControlItem value="deleted" disabled>Deleted</SegmentedControlItem>
1856
+ </SegmentedControl>
1857
+
1858
+ <p className="text-sm font-medium text-muted-foreground">Disabled</p>
1859
+ <SegmentedControl value="week" onValueChange={() => {}} disabled label="Disabled">
1860
+ <SegmentedControlItem value="day">Day</SegmentedControlItem>
1861
+ <SegmentedControlItem value="week">Week</SegmentedControlItem>
1862
+ <SegmentedControlItem value="month">Month</SegmentedControlItem>
1863
+ </SegmentedControl>
1864
+ </div>
1865
+
1866
+ <Card className="w-80"><CardContent className="p-4 space-y-3">
1867
+ <p className="text-sm font-semibold">Breezy Hills Aquatic Club</p>
1868
+ <SegmentedControl value={filter} onValueChange={setFilter} label="Session filter">
1869
+ <SegmentedControlItem value="active">Upcoming</SegmentedControlItem>
1870
+ <SegmentedControlItem value="archived">Past</SegmentedControlItem>
1871
+ <SegmentedControlItem value="all">All</SegmentedControlItem>
1872
+ </SegmentedControl>
1873
+ <p className="text-xs text-muted-foreground">
1874
+ Showing{" "}
1875
+ <span className="font-medium text-foreground">
1876
+ {filter === "active" ? "upcoming" : filter === "archived" ? "past" : "all"}
1877
+ </span>{" "}
1878
+ sessions · Avery Castillo coaching
1879
+ </p>
1880
+ </CardContent></Card>
1881
+ </div>
1882
+ );
1883
+ }
1884
+
1885
+ function TimelineRealisticDemo() {
1886
+ return (
1887
+ <Card className="w-96">
1888
+ <CardContent className="p-5 space-y-4">
1889
+ <div className="space-y-0.5">
1890
+ <p className="text-sm font-semibold">Avery Castillo · Summer Invitational</p>
1891
+ <p className="text-xs text-muted-foreground">Breezy Hills Aquatic Club</p>
1892
+ </div>
1893
+ <Timeline>
1894
+ <TimelineItem
1895
+ status="complete"
1896
+ icon={<UserCheckIcon className="size-3" strokeWidth={2} aria-hidden />}
1897
+ title="Registration submitted"
1898
+ description="200m freestyle · 400m IM"
1899
+ time="Jun 20, 9:00 AM"
1900
+ />
1901
+ <TimelineItem
1902
+ status="complete"
1903
+ icon={<CreditCardIcon className="size-3" strokeWidth={2} aria-hidden />}
1904
+ title="Payment confirmed"
1905
+ description="$85 — credit card ending 4821"
1906
+ time="Jun 21, 11:30 AM"
1907
+ />
1908
+ <TimelineItem
1909
+ status="complete"
1910
+ icon={<ClipboardCheckIcon className="size-3" strokeWidth={2} aria-hidden />}
1911
+ title="Waiver signed"
1912
+ description="Guardian: Morgan Castillo"
1913
+ time="Jun 22, 3:15 PM"
1914
+ />
1915
+ <TimelineItem
1916
+ status="active"
1917
+ title="Heat assignment pending"
1918
+ description="Sheet expected Jun 26"
1919
+ time="Jun 25 (today)"
1920
+ />
1921
+ <TimelineItem
1922
+ status="pending"
1923
+ icon={<TrophyIcon className="size-3" strokeWidth={2} aria-hidden />}
1924
+ title="Summer Invitational"
1925
+ description="Check-in 7:30 AM · South entrance"
1926
+ time="Jun 28, 2026"
1927
+ />
1928
+ </Timeline>
1929
+ </CardContent>
1930
+ </Card>
1931
+ );
1932
+ }
1933
+
1738
1934
  function RatingGroupFeedbackDemo() {
1739
1935
  const [value, setValue] = React.useState(0);
1740
1936
  const [submitted, setSubmitted] = React.useState(false);
@@ -1771,3 +1967,51 @@ function RatingGroupFeedbackDemo() {
1771
1967
  </div>
1772
1968
  );
1773
1969
  }
1970
+
1971
+ function TagsInputShowcase({
1972
+ initialTags = [],
1973
+ ...props
1974
+ }: Omit<React.ComponentProps<typeof TagsInput>, "value" | "onValueChange"> & {
1975
+ initialTags?: string[];
1976
+ }) {
1977
+ const [tags, setTags] = React.useState<string[]>(initialTags);
1978
+ return (
1979
+ <div className="w-80">
1980
+ <TagsInput value={tags} onValueChange={setTags} {...props} />
1981
+ </div>
1982
+ );
1983
+ }
1984
+
1985
+ function TagsInputFilterDemo() {
1986
+ const [tags, setTags] = React.useState<string[]>(["Junior A", "Summer Invitational"]);
1987
+ return (
1988
+ <div className="w-96 space-y-3">
1989
+ <Card>
1990
+ <CardContent className="p-4 space-y-3">
1991
+ <div>
1992
+ <p className="text-sm font-semibold">Breezy Hills Aquatic Club</p>
1993
+ <p className="text-xs text-muted-foreground">Filter practice sessions by tag</p>
1994
+ </div>
1995
+ <div className="space-y-1.5">
1996
+ <label className="text-sm font-medium">Active filters</label>
1997
+ <TagsInput
1998
+ value={tags}
1999
+ onValueChange={setTags}
2000
+ placeholder="Add filter tag…"
2001
+ maxTags={6}
2002
+ />
2003
+ <p className="text-xs text-muted-foreground">
2004
+ Press Enter or comma to add · Backspace to remove last
2005
+ </p>
2006
+ </div>
2007
+ </CardContent>
2008
+ </Card>
2009
+ {tags.length > 0 && (
2010
+ <p className="text-sm text-muted-foreground">
2011
+ Filtering by:{" "}
2012
+ <span className="font-medium text-foreground">{tags.join(", ")}</span>
2013
+ </p>
2014
+ )}
2015
+ </div>
2016
+ );
2017
+ }
@@ -101,9 +101,18 @@ function BottomSheetFooter({
101
101
  }
102
102
 
103
103
  function BottomSheetTitle({
104
+ className,
105
+ children,
104
106
  ...props
105
107
  }: React.ComponentProps<typeof SheetTitle>) {
106
- return <SheetTitle data-slot="bottom-sheet-title" {...props} />
108
+ // Render as a real h3 (Sheet/Dialog Title defaults to h2 and ships no size).
109
+ // asChild keeps the Radix Title wiring so the sheet stays aria-labelledby it,
110
+ // while the h3 carries an explicit heading size for clear hierarchy.
111
+ return (
112
+ <SheetTitle asChild data-slot="bottom-sheet-title" {...props}>
113
+ <h3 className={cn("text-lg", className)}>{children}</h3>
114
+ </SheetTitle>
115
+ )
107
116
  }
108
117
 
109
118
  function BottomSheetDescription({
@@ -176,7 +176,7 @@ function CarouselContent({
176
176
  ? "overflow-x-auto snap-x snap-mandatory scroll-smooth"
177
177
  : "flex-col overflow-y-auto snap-y snap-mandatory scroll-smooth",
178
178
  // Hide scrollbar visually while keeping scroll functionality
179
- "[scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
179
+ "scrollbar-none",
180
180
  // BADS focus ring on the keyboard-navigable scroll container
181
181
  "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
182
182
  className
@@ -49,6 +49,9 @@ export * from "./switch";
49
49
  export * from "./table";
50
50
  export * from "./tabs";
51
51
  export * from "./tag";
52
+ export * from "./segmented-control";
53
+ export * from "./tags-input";
54
+ export * from "./timeline";
52
55
  export * from "./textarea";
53
56
  export * from "./toggle";
54
57
  export * from "./toggle-group";
@@ -0,0 +1,213 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+ import { cn } from "../../lib/utils";
6
+
7
+ // ─── Context ──────────────────────────────────────────────────────────────────
8
+
9
+ interface SegmentedControlContextValue {
10
+ value: string;
11
+ onValueChange: (value: string) => void;
12
+ disabled: boolean;
13
+ size: "sm" | "default" | "lg";
14
+ }
15
+
16
+ const SegmentedControlContext = React.createContext<SegmentedControlContextValue>({
17
+ value: "",
18
+ onValueChange: () => {},
19
+ disabled: false,
20
+ size: "default",
21
+ });
22
+
23
+ // ─── Variants ─────────────────────────────────────────────────────────────────
24
+
25
+ const rootVariants = cva(
26
+ [
27
+ "relative inline-grid rounded-lg bg-muted p-1",
28
+ ],
29
+ {
30
+ variants: {
31
+ size: {
32
+ sm: "gap-0.5",
33
+ default: "gap-0.5",
34
+ lg: "gap-0.5",
35
+ },
36
+ },
37
+ defaultVariants: { size: "default" },
38
+ }
39
+ );
40
+
41
+ const itemVariants = cva(
42
+ [
43
+ "relative z-10 inline-flex cursor-pointer select-none items-center justify-center whitespace-nowrap rounded-md",
44
+ "font-medium text-muted-foreground",
45
+ "transition-colors",
46
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
47
+ "disabled:pointer-events-none disabled:opacity-50",
48
+ "aria-checked:text-foreground",
49
+ "hover:text-foreground",
50
+ ],
51
+ {
52
+ variants: {
53
+ size: {
54
+ sm: "px-2.5 min-h-8 text-xs",
55
+ default: "px-3 min-h-11 text-sm",
56
+ lg: "px-4 min-h-12 text-sm",
57
+ },
58
+ },
59
+ defaultVariants: { size: "default" },
60
+ }
61
+ );
62
+
63
+ // ─── Root ─────────────────────────────────────────────────────────────────────
64
+
65
+ export interface SegmentedControlProps
66
+ extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
67
+ /** The currently selected value. */
68
+ value: string;
69
+ /** Callback fired when the selected value changes. */
70
+ onValueChange: (value: string) => void;
71
+ /** Visual + size variant. */
72
+ size?: "sm" | "default" | "lg";
73
+ /** Disables all items. */
74
+ disabled?: boolean;
75
+ /** Accessible label for the radio group. */
76
+ label?: string;
77
+ }
78
+
79
+ export function SegmentedControl({
80
+ value,
81
+ onValueChange,
82
+ size = "default",
83
+ disabled = false,
84
+ label,
85
+ className,
86
+ children,
87
+ ...props
88
+ }: SegmentedControlProps) {
89
+ // Count valid SegmentedControlItem children to calculate indicator geometry
90
+ const items = React.Children.toArray(children).filter(
91
+ (child): child is React.ReactElement<SegmentedControlItemProps> =>
92
+ React.isValidElement(child)
93
+ );
94
+ const count = items.length;
95
+ const selectedIndex = items.findIndex((item) => item.props.value === value);
96
+
97
+ // Roving tabindex: track focused item index so ArrowLeft/Right works across items
98
+ const rootRef = React.useRef<HTMLDivElement>(null);
99
+
100
+ const handleKeyDown = React.useCallback(
101
+ (e: React.KeyboardEvent<HTMLDivElement>) => {
102
+ if (!rootRef.current) return;
103
+ const buttons = Array.from(
104
+ rootRef.current.querySelectorAll<HTMLButtonElement>("[role=radio]:not([disabled])")
105
+ );
106
+ const focusedIdx = buttons.findIndex((b) => b === document.activeElement);
107
+ if (focusedIdx === -1) return;
108
+
109
+ let next = focusedIdx;
110
+ if (e.key === "ArrowRight" || e.key === "ArrowDown") {
111
+ next = (focusedIdx + 1) % buttons.length;
112
+ } else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
113
+ next = (focusedIdx - 1 + buttons.length) % buttons.length;
114
+ } else if (e.key === "Home") {
115
+ next = 0;
116
+ } else if (e.key === "End") {
117
+ next = buttons.length - 1;
118
+ } else {
119
+ return;
120
+ }
121
+ e.preventDefault();
122
+ buttons[next]?.focus();
123
+ const nextValue = items.find((_, i) => {
124
+ const enabledItems = items.filter((item) => !item.props.disabled);
125
+ return enabledItems[next] === items[i];
126
+ });
127
+ const targetItem = items.filter((item) => !item.props.disabled)[next];
128
+ if (targetItem) onValueChange(targetItem.props.value);
129
+ },
130
+ [items, onValueChange]
131
+ );
132
+
133
+ return (
134
+ <SegmentedControlContext.Provider value={{ value, onValueChange, disabled, size }}>
135
+ <div
136
+ ref={rootRef}
137
+ role="radiogroup"
138
+ aria-label={label}
139
+ data-slot="segmented-control"
140
+ data-disabled={disabled || undefined}
141
+ onKeyDown={handleKeyDown}
142
+ className={cn(rootVariants({ size }), className)}
143
+ style={{ gridTemplateColumns: `repeat(${count}, 1fr)` }}
144
+ {...props}
145
+ >
146
+ {/* Sliding indicator — absolutely positioned, moves via left transition */}
147
+ {selectedIndex >= 0 && count > 0 && (
148
+ <div
149
+ aria-hidden
150
+ data-slot="segmented-control-indicator"
151
+ className="absolute inset-y-1 rounded-md bg-background shadow-sm pointer-events-none"
152
+ style={{
153
+ // width = (containerWidth - 2*p-1 gap) / count
154
+ width: `calc((100% - 8px) / ${count})`,
155
+ // left = p-1(4px) + selectedIndex * (itemWidth + gap)
156
+ left: `calc(${selectedIndex} * (100% - 8px) / ${count} + 4px)`,
157
+ transitionProperty: "left",
158
+ transitionDuration: "var(--duration-fast)",
159
+ transitionTimingFunction: "var(--ease-out)",
160
+ }}
161
+ />
162
+ )}
163
+ {children}
164
+ </div>
165
+ </SegmentedControlContext.Provider>
166
+ );
167
+ }
168
+
169
+ // ─── Item ─────────────────────────────────────────────────────────────────────
170
+
171
+ export interface SegmentedControlItemProps
172
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
173
+ /** The value this item represents. */
174
+ value: string;
175
+ /** Icon to render before the label. Must be a Lucide icon with strokeWidth={1.5}. */
176
+ icon?: React.ReactNode;
177
+ }
178
+
179
+ export function SegmentedControlItem({
180
+ value,
181
+ icon,
182
+ className,
183
+ disabled,
184
+ children,
185
+ ...props
186
+ }: SegmentedControlItemProps) {
187
+ const { value: selectedValue, onValueChange, disabled: groupDisabled, size } =
188
+ React.useContext(SegmentedControlContext);
189
+ const isSelected = selectedValue === value;
190
+ const isDisabled = groupDisabled || disabled;
191
+
192
+ return (
193
+ <button
194
+ type="button"
195
+ role="radio"
196
+ aria-checked={isSelected}
197
+ data-slot="segmented-control-item"
198
+ data-state={isSelected ? "on" : "off"}
199
+ disabled={isDisabled}
200
+ tabIndex={isSelected ? 0 : -1}
201
+ onClick={() => {
202
+ if (!isDisabled) onValueChange(value);
203
+ }}
204
+ className={cn(itemVariants({ size }), className)}
205
+ {...props}
206
+ >
207
+ {icon && (
208
+ <span className="mr-1.5 shrink-0 [&>svg]:size-4 [&>svg]:stroke-[1.5]">{icon}</span>
209
+ )}
210
+ {children}
211
+ </button>
212
+ );
213
+ }
@@ -165,6 +165,12 @@ function StepperIndicator({
165
165
  ...(state === "active" && {
166
166
  borderColor: "var(--primary)",
167
167
  }),
168
+ // Error matches the active/completed pattern: inline so the
169
+ // destructive color resolves regardless of the @theme cascade
170
+ // (the `border-destructive` class alone falls back to gray).
171
+ ...(state === "error" && {
172
+ borderColor: "var(--destructive)",
173
+ }),
168
174
  }}
169
175
  {...props}
170
176
  >
@@ -193,9 +199,11 @@ function StepperTitle({
193
199
  data-state={state}
194
200
  className={cn(
195
201
  "text-sm font-medium leading-tight",
196
- state === "active" || state === "completed"
197
- ? "text-foreground"
198
- : "text-muted-foreground",
202
+ state === "error"
203
+ ? "text-destructive"
204
+ : state === "active" || state === "completed"
205
+ ? "text-foreground"
206
+ : "text-muted-foreground",
199
207
  className
200
208
  )}
201
209
  {...props}
@@ -106,7 +106,7 @@ function TabsList({
106
106
  className={cn(
107
107
  tabsListVariants({ variant }),
108
108
  scrollable &&
109
- "overflow-x-auto [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden data-[overflowing]:[mask-image:linear-gradient(to_right,#000_calc(100%-2rem),transparent)]",
109
+ "overflow-x-auto scrollbar-none data-[overflowing]:[mask-image:linear-gradient(to_right,#000_calc(100%-2rem),transparent)]",
110
110
  className
111
111
  )}
112
112
  {...props}
@@ -0,0 +1,199 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { XIcon } from "lucide-react";
5
+ import { cn } from "../../lib/utils";
6
+
7
+ // ─── Types ────────────────────────────────────────────────────────────────────
8
+
9
+ export interface TagsInputProps
10
+ extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
11
+ /** The current list of tag values. */
12
+ value: string[];
13
+ /** Callback fired when the tag list changes. */
14
+ onValueChange: (value: string[]) => void;
15
+ /** Placeholder shown when no tags are present. */
16
+ placeholder?: string;
17
+ /** Disables the entire input. */
18
+ disabled?: boolean;
19
+ /** Maximum number of tags allowed. Input is blocked once reached. */
20
+ maxTags?: number;
21
+ /** Allow duplicate tag values. Defaults to false. */
22
+ allowDuplicates?: boolean;
23
+ /** Characters that trigger tag creation in addition to Enter. Default: [","]. */
24
+ delimiters?: string[];
25
+ }
26
+
27
+ // ─── Component ────────────────────────────────────────────────────────────────
28
+
29
+ export function TagsInput({
30
+ value,
31
+ onValueChange,
32
+ placeholder,
33
+ disabled = false,
34
+ maxTags,
35
+ allowDuplicates = false,
36
+ delimiters = [","],
37
+ className,
38
+ ...props
39
+ }: TagsInputProps) {
40
+ const [inputValue, setInputValue] = React.useState("");
41
+ const [focusedTagIndex, setFocusedTagIndex] = React.useState<number | null>(null);
42
+ const inputRef = React.useRef<HTMLInputElement>(null);
43
+
44
+ const atMax = maxTags !== undefined && value.length >= maxTags;
45
+
46
+ const addTag = React.useCallback(
47
+ (raw: string) => {
48
+ const trimmed = raw.trim();
49
+ if (!trimmed) return;
50
+ if (atMax) return;
51
+ if (!allowDuplicates && value.includes(trimmed)) return;
52
+ onValueChange([...value, trimmed]);
53
+ setInputValue("");
54
+ },
55
+ [atMax, allowDuplicates, value, onValueChange]
56
+ );
57
+
58
+ const removeTag = React.useCallback(
59
+ (index: number) => {
60
+ onValueChange(value.filter((_, i) => i !== index));
61
+ setFocusedTagIndex(null);
62
+ inputRef.current?.focus();
63
+ },
64
+ [value, onValueChange]
65
+ );
66
+
67
+ const handleKeyDown = React.useCallback(
68
+ (e: React.KeyboardEvent<HTMLInputElement>) => {
69
+ if (e.key === "Enter") {
70
+ e.preventDefault();
71
+ addTag(inputValue);
72
+ } else if (e.key === "Backspace" && inputValue === "") {
73
+ e.preventDefault();
74
+ if (focusedTagIndex !== null) {
75
+ removeTag(focusedTagIndex);
76
+ } else if (value.length > 0) {
77
+ setFocusedTagIndex(value.length - 1);
78
+ }
79
+ } else if (e.key === "Delete" && inputValue === "" && focusedTagIndex !== null) {
80
+ e.preventDefault();
81
+ removeTag(focusedTagIndex);
82
+ } else if (e.key === "ArrowLeft" && inputValue === "") {
83
+ if (focusedTagIndex === null && value.length > 0) {
84
+ setFocusedTagIndex(value.length - 1);
85
+ } else if (focusedTagIndex !== null && focusedTagIndex > 0) {
86
+ setFocusedTagIndex(focusedTagIndex - 1);
87
+ }
88
+ } else if (e.key === "ArrowRight" && inputValue === "") {
89
+ if (focusedTagIndex !== null) {
90
+ if (focusedTagIndex < value.length - 1) {
91
+ setFocusedTagIndex(focusedTagIndex + 1);
92
+ } else {
93
+ setFocusedTagIndex(null);
94
+ }
95
+ }
96
+ } else if (e.key === "Escape") {
97
+ setFocusedTagIndex(null);
98
+ } else {
99
+ setFocusedTagIndex(null);
100
+ }
101
+ },
102
+ [inputValue, focusedTagIndex, value, addTag, removeTag]
103
+ );
104
+
105
+ const handleInputChange = React.useCallback(
106
+ (e: React.ChangeEvent<HTMLInputElement>) => {
107
+ const val = e.target.value;
108
+ const lastChar = val[val.length - 1];
109
+ if (lastChar !== undefined && delimiters.includes(lastChar)) {
110
+ addTag(val.slice(0, -1));
111
+ } else {
112
+ setInputValue(val);
113
+ }
114
+ setFocusedTagIndex(null);
115
+ },
116
+ [delimiters, addTag]
117
+ );
118
+
119
+ const inputPlaceholder =
120
+ value.length === 0
121
+ ? placeholder
122
+ : atMax
123
+ ? `Max ${maxTags} tags reached`
124
+ : undefined;
125
+
126
+ return (
127
+ <div
128
+ data-slot="tags-input"
129
+ data-disabled={disabled || undefined}
130
+ aria-disabled={disabled || undefined}
131
+ onClick={() => !disabled && inputRef.current?.focus()}
132
+ className={cn(
133
+ "flex min-h-11 flex-wrap items-center gap-1.5 rounded-md border border-input bg-background px-3 py-2",
134
+ "cursor-text",
135
+ "focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
136
+ disabled && "cursor-not-allowed border-border/50 bg-muted/30 pointer-events-none",
137
+ className
138
+ )}
139
+ {...props}
140
+ >
141
+ {value.map((tag, index) => (
142
+ <span
143
+ key={`${tag}-${index}`}
144
+ data-slot="tags-input-item"
145
+ data-focused={focusedTagIndex === index || undefined}
146
+ className={cn(
147
+ "inline-flex max-w-[160px] items-center gap-1 rounded-md px-2 py-0.5",
148
+ "text-sm font-medium transition-colors",
149
+ disabled
150
+ ? "bg-muted text-muted-foreground"
151
+ : "bg-secondary text-secondary-foreground",
152
+ !disabled && focusedTagIndex === index && "ring-2 ring-ring ring-offset-1 ring-offset-background"
153
+ )}
154
+ >
155
+ <span className="truncate">{tag}</span>
156
+ {!disabled && (
157
+ <button
158
+ type="button"
159
+ data-slot="tags-input-item-delete"
160
+ aria-label={`Remove ${tag}`}
161
+ tabIndex={-1}
162
+ onClick={(e) => {
163
+ e.stopPropagation();
164
+ removeTag(index);
165
+ }}
166
+ className={cn(
167
+ "shrink-0 rounded-sm p-0.5",
168
+ "text-secondary-foreground/70 hover:text-secondary-foreground",
169
+ "transition-colors",
170
+ "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
171
+ )}
172
+ style={{
173
+ transitionDuration: "var(--duration-fast)",
174
+ transitionTimingFunction: "var(--ease-out)",
175
+ }}
176
+ >
177
+ <XIcon className="size-3" strokeWidth={1.5} aria-hidden />
178
+ </button>
179
+ )}
180
+ </span>
181
+ ))}
182
+ <input
183
+ ref={inputRef}
184
+ type="text"
185
+ value={inputValue}
186
+ onChange={handleInputChange}
187
+ onKeyDown={handleKeyDown}
188
+ disabled={disabled || atMax}
189
+ placeholder={inputPlaceholder}
190
+ aria-label={placeholder ?? "Add tags, press Enter or comma to confirm"}
191
+ className={cn(
192
+ "min-w-[80px] flex-1 bg-transparent text-sm outline-none",
193
+ "placeholder:text-muted-foreground",
194
+ "disabled:cursor-not-allowed disabled:opacity-0"
195
+ )}
196
+ />
197
+ </div>
198
+ );
199
+ }
@@ -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
+ }
@@ -10,8 +10,12 @@
10
10
  * - A mark that uses `currentColor` is **adaptive** — the monotone path in
11
11
  * svg-sanitize already rewrote it, so it follows the text color on its own.
12
12
  * Never filter those (inverting would fight the currentColor adaptation).
13
- * - A mark whose every resolvable color is dark is **dark** → invert it in
14
- * dark mode. Every color light → **light** → invert it in light mode.
13
+ * - A mark with any **saturated** color is a brand hue → **mixed** (left as
14
+ * authored). Inverting a saturated color rotates its hue — a blue logo
15
+ * becomes orange — so only neutrals are ever inverted. This check runs
16
+ * before the dark/light luminance test.
17
+ * - A mark whose every resolvable color is dark (and neutral) is **dark** →
18
+ * invert it in dark mode. Every color light → **light** → invert in light.
15
19
  * - Anything with a mix of light and dark fixed colors is **mixed** → left
16
20
  * exactly as authored, because inverting a multi-color logo wrecks the brand
17
21
  * colors. Same for marks whose colors we can't resolve (oklch/hsl/exotic
@@ -80,6 +84,41 @@ function luminanceOf(raw: string): number | null {
80
84
  return null;
81
85
  }
82
86
 
87
+ /**
88
+ * HSV saturation (0–1) of a color, or null if it can't be resolved. Near 0 =
89
+ * a neutral (black / gray / white) that inverts cleanly; high = a saturated
90
+ * brand hue (blue, orange, …) whose hue an `invert` filter would wreck.
91
+ */
92
+ function saturationOf(raw: string): number | null {
93
+ let v = raw.trim().toLowerCase();
94
+ if (!v || v === "none" || v === "transparent" || v === "inherit" || v === "currentcolor") {
95
+ return null;
96
+ }
97
+ if (NAMED_HEX[v]) v = NAMED_HEX[v];
98
+ if (/^#[0-9a-f]{3}$/.test(v)) {
99
+ v = `#${v[1]}${v[1]}${v[2]}${v[2]}${v[3]}${v[3]}`;
100
+ }
101
+ let r: number, g: number, b: number;
102
+ if (/^#[0-9a-f]{6}$/.test(v)) {
103
+ r = parseInt(v.slice(1, 3), 16);
104
+ g = parseInt(v.slice(3, 5), 16);
105
+ b = parseInt(v.slice(5, 7), 16);
106
+ } else {
107
+ const rgb = v.match(/^rgba?\(([^)]+)\)$/);
108
+ if (!rgb) return null;
109
+ const parts = rgb[1]
110
+ .split(/[,\s/]+/)
111
+ .filter(Boolean)
112
+ .slice(0, 3)
113
+ .map(Number);
114
+ if (parts.length !== 3 || parts.some((n) => Number.isNaN(n))) return null;
115
+ [r, g, b] = parts;
116
+ }
117
+ const max = Math.max(r, g, b);
118
+ const min = Math.min(r, g, b);
119
+ return max === 0 ? 0 : (max - min) / max;
120
+ }
121
+
83
122
  function colorTokens(svg: string): string[] {
84
123
  const tokens: string[] = [];
85
124
  let m: RegExpExecArray | null;
@@ -104,6 +143,11 @@ function colorTokens(svg: string): string[] {
104
143
  // and are left alone rather than aggressively inverted.
105
144
  const DARK_MAX = 0.22;
106
145
  const LIGHT_MIN = 0.6;
146
+ // At/above this HSV saturation a color is a brand hue, not a neutral. Only
147
+ // neutrals (black/gray/white) invert cleanly — inverting a saturated color
148
+ // rotates its hue (a blue mark becomes orange), which wrecks the brand. So a
149
+ // saturated mark is treated like a multi-color one: left exactly as authored.
150
+ const SAT_MAX = 0.4;
107
151
 
108
152
  export function classifyMarkTone(svg: string | null): MarkTone {
109
153
  if (!svg) return "adaptive";
@@ -111,6 +155,16 @@ export function classifyMarkTone(svg: string | null): MarkTone {
111
155
  // Any currentColor usage means the mark already adapts to the theme.
112
156
  if (tokens.some((t) => t.trim().toLowerCase() === "currentcolor")) return "adaptive";
113
157
 
158
+ // A saturated mark is a brand color — never invert it (the hue would flip).
159
+ if (
160
+ tokens.some((t) => {
161
+ const s = saturationOf(t);
162
+ return s !== null && s >= SAT_MAX;
163
+ })
164
+ ) {
165
+ return "mixed";
166
+ }
167
+
114
168
  const lums: number[] = [];
115
169
  for (const t of tokens) {
116
170
  const l = luminanceOf(t);