@behavioral-agentic-design-system/core 0.38.0 → 0.39.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 (172) hide show
  1. package/package.json +2 -2
  2. package/src/app/preview/components/page.tsx +362 -0
  3. package/src/components/Foundations/Typography.stories.tsx +82 -21
  4. package/src/components/ui/accordion.tsx +67 -5
  5. package/src/components/ui/alert.tsx +20 -7
  6. package/src/components/ui/avatar.tsx +18 -4
  7. package/src/components/ui/breadcrumb.tsx +47 -0
  8. package/src/components/ui/checkbox-card.tsx +48 -8
  9. package/src/components/ui/checkbox.tsx +17 -8
  10. package/src/components/ui/format-date.tsx +107 -0
  11. package/src/components/ui/progress.tsx +6 -5
  12. package/src/components/ui/sparkline.tsx +198 -0
  13. package/src/components/ui/tag.tsx +17 -1
  14. package/src/components/ui/tags-input.tsx +84 -11
  15. package/src/components/ui/toggle-group.tsx +13 -0
  16. package/src/components/ui/week-picker.tsx +463 -0
  17. package/src/data/docs-index.ts +7 -0
  18. package/src/stories/Accordion.stories.tsx +59 -1
  19. package/src/stories/ActionBar.stories.tsx +1 -1
  20. package/src/stories/Affix.stories.tsx +1 -1
  21. package/src/stories/AiBadge.stories.tsx +1 -1
  22. package/src/stories/Alert.stories.tsx +36 -1
  23. package/src/stories/AlertDialog.stories.tsx +1 -1
  24. package/src/stories/Anchor.stories.tsx +1 -1
  25. package/src/stories/AngleSlider.stories.tsx +1 -1
  26. package/src/stories/AspectRatio.stories.tsx +1 -1
  27. package/src/stories/Autocomplete.stories.tsx +1 -1
  28. package/src/stories/Avatar.stories.tsx +41 -1
  29. package/src/stories/Badge.stories.tsx +1 -1
  30. package/src/stories/Blockquote.stories.tsx +1 -1
  31. package/src/stories/BottomNavigation.stories.tsx +1 -1
  32. package/src/stories/Breadcrumb.stories.tsx +38 -5
  33. package/src/stories/Burger.stories.tsx +1 -1
  34. package/src/stories/Button.stories.tsx +9 -1
  35. package/src/stories/ButtonGroup.stories.tsx +1 -1
  36. package/src/stories/Calendar.stories.tsx +1 -1
  37. package/src/stories/Card.stories.tsx +1 -1
  38. package/src/stories/Carousel.stories.tsx +1 -1
  39. package/src/stories/Cascader.stories.tsx +1 -1
  40. package/src/stories/Chart.stories.tsx +1 -1
  41. package/src/stories/ChatBubble.stories.tsx +1 -1
  42. package/src/stories/ChatMarker.stories.tsx +1 -1
  43. package/src/stories/Checkbox.stories.tsx +36 -5
  44. package/src/stories/CheckboxCard.stories.tsx +37 -2
  45. package/src/stories/CheckboxGroup.stories.tsx +1 -1
  46. package/src/stories/Chip.stories.tsx +1 -1
  47. package/src/stories/CircularProgress.stories.tsx +17 -1
  48. package/src/stories/Clipboard.stories.tsx +1 -1
  49. package/src/stories/CloseButton.stories.tsx +1 -1
  50. package/src/stories/Code.stories.tsx +1 -1
  51. package/src/stories/Collapsible.stories.tsx +1 -1
  52. package/src/stories/ColorPicker.stories.tsx +1 -1
  53. package/src/stories/ColorSwatch.stories.tsx +1 -1
  54. package/src/stories/Combobox.stories.tsx +1 -1
  55. package/src/stories/Command.stories.tsx +1 -1
  56. package/src/stories/Container.stories.tsx +1 -1
  57. package/src/stories/ContextMenu.stories.tsx +1 -1
  58. package/src/stories/CopyButton.stories.tsx +9 -1
  59. package/src/stories/DataList.stories.tsx +1 -1
  60. package/src/stories/DataTable.stories.tsx +1 -1
  61. package/src/stories/DateField.stories.tsx +1 -1
  62. package/src/stories/DatePicker.stories.tsx +1 -1
  63. package/src/stories/DateRangePicker.stories.tsx +1 -1
  64. package/src/stories/Dialog.stories.tsx +1 -1
  65. package/src/stories/Drawer.stories.tsx +1 -1
  66. package/src/stories/DropdownMenu.stories.tsx +1 -1
  67. package/src/stories/Editable.stories.tsx +1 -1
  68. package/src/stories/EmptyState.stories.tsx +1 -1
  69. package/src/stories/Field.stories.tsx +1 -1
  70. package/src/stories/Fieldset.stories.tsx +1 -1
  71. package/src/stories/FileButton.stories.tsx +1 -1
  72. package/src/stories/FileUpload.stories.tsx +1 -1
  73. package/src/stories/FloatLabel.stories.tsx +1 -1
  74. package/src/stories/FloatingActionButton.stories.tsx +1 -1
  75. package/src/stories/FloatingIndicator.stories.tsx +1 -1
  76. package/src/stories/FloatingPanel.stories.tsx +9 -1
  77. package/src/stories/FocusTrap.stories.tsx +1 -1
  78. package/src/stories/FormatByte.stories.tsx +1 -1
  79. package/src/stories/FormatDate.stories.tsx +174 -0
  80. package/src/stories/FormatNumber.stories.tsx +1 -1
  81. package/src/stories/Highlight.stories.tsx +1 -1
  82. package/src/stories/HoverCard.stories.tsx +1 -1
  83. package/src/stories/Image.stories.tsx +1 -1
  84. package/src/stories/Indicator.stories.tsx +17 -1
  85. package/src/stories/Input.stories.tsx +1 -1
  86. package/src/stories/InputClearButton.stories.tsx +1 -1
  87. package/src/stories/InputGroup.stories.tsx +1 -1
  88. package/src/stories/Kbd.stories.tsx +1 -1
  89. package/src/stories/KeyboardShortcut.stories.tsx +1 -1
  90. package/src/stories/Label.stories.tsx +1 -1
  91. package/src/stories/Link.stories.tsx +1 -1
  92. package/src/stories/List.stories.tsx +1 -1
  93. package/src/stories/Listbox.stories.tsx +1 -1
  94. package/src/stories/LoadingDots.stories.tsx +1 -1
  95. package/src/stories/LoadingOverlay.stories.tsx +1 -1
  96. package/src/stories/Mark.stories.tsx +1 -1
  97. package/src/stories/Marquee.stories.tsx +1 -1
  98. package/src/stories/Masonry.stories.tsx +1 -1
  99. package/src/stories/Menubar.stories.tsx +1 -1
  100. package/src/stories/Meter.stories.tsx +1 -1
  101. package/src/stories/MonthPicker.stories.tsx +1 -1
  102. package/src/stories/MotionToggle.stories.tsx +1 -1
  103. package/src/stories/MultiSelect.stories.tsx +1 -1
  104. package/src/stories/NativeSelect.stories.tsx +1 -1
  105. package/src/stories/NavLink.stories.tsx +1 -1
  106. package/src/stories/NavigationMenu.stories.tsx +1 -1
  107. package/src/stories/NavigationRail.stories.tsx +9 -1
  108. package/src/stories/Notification.stories.tsx +1 -1
  109. package/src/stories/NumberInput.stories.tsx +1 -1
  110. package/src/stories/Overlay.stories.tsx +1 -1
  111. package/src/stories/Pagination.stories.tsx +1 -1
  112. package/src/stories/PasswordInput.stories.tsx +1 -1
  113. package/src/stories/PinInput.stories.tsx +1 -1
  114. package/src/stories/Popover.stories.tsx +1 -1
  115. package/src/stories/Progress.stories.tsx +11 -1
  116. package/src/stories/Prose.stories.tsx +1 -1
  117. package/src/stories/QrCode.stories.tsx +1 -1
  118. package/src/stories/Questionnaire.stories.tsx +1 -1
  119. package/src/stories/RadioGroup.stories.tsx +1 -1
  120. package/src/stories/RatingGroup.stories.tsx +1 -1
  121. package/src/stories/Resizable.stories.tsx +1 -1
  122. package/src/stories/Result.stories.tsx +1 -1
  123. package/src/stories/Reveal.stories.tsx +1 -1
  124. package/src/stories/RollingNumber.stories.tsx +1 -1
  125. package/src/stories/ScrollArea.stories.tsx +1 -1
  126. package/src/stories/SearchInput.stories.tsx +1 -1
  127. package/src/stories/SegmentedControl.stories.tsx +1 -1
  128. package/src/stories/Select.stories.tsx +1 -1
  129. package/src/stories/Separator.stories.tsx +1 -1
  130. package/src/stories/Sheet.stories.tsx +1 -1
  131. package/src/stories/Sidebar.stories.tsx +1 -1
  132. package/src/stories/SignaturePad.stories.tsx +1 -1
  133. package/src/stories/SimpleGrid.stories.tsx +1 -1
  134. package/src/stories/Skeleton.stories.tsx +1 -1
  135. package/src/stories/SkeletonTable.stories.tsx +1 -1
  136. package/src/stories/SkipLink.stories.tsx +1 -1
  137. package/src/stories/Slider.stories.tsx +1 -1
  138. package/src/stories/Sonner.stories.tsx +1 -1
  139. package/src/stories/Sparkline.stories.tsx +208 -0
  140. package/src/stories/Spinner.stories.tsx +9 -1
  141. package/src/stories/Spoiler.stories.tsx +1 -1
  142. package/src/stories/Squircle.stories.tsx +1 -1
  143. package/src/stories/Stack.stories.tsx +1 -1
  144. package/src/stories/StatusBadge.stories.tsx +1 -1
  145. package/src/stories/Stepper.stories.tsx +1 -1
  146. package/src/stories/Switch.stories.tsx +1 -1
  147. package/src/stories/Table.stories.tsx +1 -1
  148. package/src/stories/Tabs.stories.tsx +1 -1
  149. package/src/stories/Tag.stories.tsx +23 -1
  150. package/src/stories/TagsInput.stories.tsx +46 -1
  151. package/src/stories/Text.stories.tsx +1 -1
  152. package/src/stories/Textarea.stories.tsx +1 -1
  153. package/src/stories/ThemeIcon.stories.tsx +1 -1
  154. package/src/stories/TimePicker.stories.tsx +1 -1
  155. package/src/stories/Timeline.stories.tsx +9 -1
  156. package/src/stories/Timer.stories.tsx +1 -1
  157. package/src/stories/Toggle.stories.tsx +1 -1
  158. package/src/stories/ToggleGroup.stories.tsx +21 -1
  159. package/src/stories/ToggleTip.stories.tsx +1 -1
  160. package/src/stories/Toolbar.stories.tsx +1 -1
  161. package/src/stories/Tooltip.stories.tsx +1 -1
  162. package/src/stories/Tour.stories.tsx +1 -1
  163. package/src/stories/TransferList.stories.tsx +1 -1
  164. package/src/stories/TreeSelect.stories.tsx +1 -1
  165. package/src/stories/TreeView.stories.tsx +1 -1
  166. package/src/stories/TypingIndicator.stories.tsx +1 -1
  167. package/src/stories/VisuallyHidden.stories.tsx +1 -1
  168. package/src/stories/Watermark.stories.tsx +1 -1
  169. package/src/stories/WeekPicker.stories.tsx +90 -0
  170. package/src/stories/WordRotate.stories.tsx +1 -1
  171. package/src/stories/YearPicker.stories.tsx +1 -1
  172. package/src/stories/story-groups.json +199 -0
@@ -0,0 +1,198 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import {
5
+ ResponsiveContainer,
6
+ AreaChart,
7
+ LineChart,
8
+ Area,
9
+ Line,
10
+ Dot,
11
+ } from "recharts"
12
+
13
+ import { cn } from "../../lib/utils"
14
+
15
+ export interface SparklineProps extends React.ComponentProps<"span"> {
16
+ /**
17
+ * Array of numeric data points to render. The chart maps each value to a
18
+ * `{ value }` datum on its internal series — no axes, labels, or tooltip
19
+ * by default.
20
+ */
21
+ data: number[]
22
+ /**
23
+ * Fill / stroke color for the series. Accepts any CSS color string or a
24
+ * CSS variable reference (`var(--color-primary)`). Defaults to the primary
25
+ * brand color.
26
+ */
27
+ color?: string
28
+ /**
29
+ * Chart type. `"area"` (default) renders an `AreaChart` with a gradient
30
+ * fill. `"line"` renders a `LineChart` with no fill.
31
+ */
32
+ type?: "area" | "line"
33
+ /** Height in pixels. Defaults to 40. */
34
+ height?: number
35
+ /**
36
+ * Curve interpolation. Defaults to "monotone" (smooth). "linear" gives
37
+ * sharp corners; "step" gives a staircase shape.
38
+ */
39
+ curveType?: "linear" | "monotone" | "step"
40
+ /**
41
+ * When `true`, renders a dot at the last data point to mark the current
42
+ * value. Defaults to `false`.
43
+ */
44
+ withDot?: boolean
45
+ }
46
+
47
+ // A unique id prefix for gradient definitions (SSR-safe via useId).
48
+ // Each Sparkline instance gets its own gradient so multiple sparklines on
49
+ // the same page don't share gradient ids and create incorrect fill colors.
50
+
51
+ function usePrefersReducedMotion(): boolean {
52
+ const [reduced, setReduced] = React.useState(false)
53
+ React.useEffect(() => {
54
+ if (typeof window === "undefined" || !window.matchMedia) return
55
+ const mql = window.matchMedia("(prefers-reduced-motion: reduce)")
56
+ setReduced(mql.matches)
57
+ const onChange = (e: MediaQueryListEvent) => setReduced(e.matches)
58
+ mql.addEventListener("change", onChange)
59
+ return () => mql.removeEventListener("change", onChange)
60
+ }, [])
61
+ return reduced
62
+ }
63
+
64
+ /**
65
+ * Compact inline sparkline for trend visualization. Renders a mini area or
66
+ * line chart with no axes, no labels, and no tooltip — just the data shape.
67
+ * Use inside stat rows, table cells, and dashboard cards to communicate
68
+ * direction at a glance.
69
+ *
70
+ * The root element is a `<span data-slot="sparkline">` so it can be placed
71
+ * inline next to text. The inner chart is a `block` display at the specified
72
+ * height; set `className` for `w-*` / `min-w-*` to control width.
73
+ *
74
+ * Uses Recharts 3.x via BADS's existing recharts peer-dep. The
75
+ * `ResponsiveContainer` is only mounted after the container has a measured
76
+ * size (ResizeObserver gate) — the same pattern as `ChartContainer` — to
77
+ * prevent the Recharts v3 -1×-1 invisible-chart bug.
78
+ */
79
+ function Sparkline({
80
+ data,
81
+ color = "var(--color-primary)",
82
+ type = "area",
83
+ height = 40,
84
+ curveType = "monotone",
85
+ withDot = false,
86
+ className,
87
+ "aria-label": ariaLabel = "Sparkline chart",
88
+ ...props
89
+ }: SparklineProps) {
90
+ const uniqueId = React.useId()
91
+ const gradientId = `sparkline-grad-${uniqueId.replace(/:/g, "")}`
92
+
93
+ const prefersReducedMotion = usePrefersReducedMotion()
94
+ const animate = !prefersReducedMotion
95
+
96
+ // ResizeObserver gate — same pattern as ChartContainer.
97
+ const containerRef = React.useRef<HTMLSpanElement | null>(null)
98
+ const [hasSize, setHasSize] = React.useState(false)
99
+
100
+ React.useEffect(() => {
101
+ const el = containerRef.current
102
+ if (!el) return
103
+ const observer = new ResizeObserver((entries) => {
104
+ for (const entry of entries) {
105
+ const { width, height: h } = entry.contentRect
106
+ setHasSize(width > 0 && h > 0)
107
+ }
108
+ })
109
+ observer.observe(el)
110
+ return () => observer.disconnect()
111
+ }, [])
112
+
113
+ // Map bare numbers to recharts-compatible datum objects.
114
+ const chartData = React.useMemo(
115
+ () => data.map((v) => ({ value: v })),
116
+ [data]
117
+ )
118
+
119
+ // Compute domain so flat/negative data still renders a visible shape.
120
+ const min = Math.min(...data)
121
+ const max = Math.max(...data)
122
+ const padding = max === min ? 1 : (max - min) * 0.1
123
+ const domain: [number, number] = [min - padding, max + padding]
124
+
125
+ // Last-point dot: rendered via Recharts' customized dot prop.
126
+ const lastIndex = data.length - 1
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
+ const renderDot = withDot
129
+ ? (dotProps: any) => {
130
+ if (dotProps.index !== lastIndex) return <React.Fragment key={dotProps.index} />
131
+ return (
132
+ <Dot
133
+ key={dotProps.index}
134
+ cx={dotProps.cx}
135
+ cy={dotProps.cy}
136
+ r={3}
137
+ fill={color}
138
+ stroke="var(--color-background, #fff)"
139
+ strokeWidth={1.5}
140
+ />
141
+ )
142
+ }
143
+ : false
144
+
145
+ const commonLineProps = {
146
+ type: curveType,
147
+ dataKey: "value",
148
+ stroke: color,
149
+ strokeWidth: 1.5,
150
+ dot: renderDot,
151
+ isAnimationActive: animate,
152
+ } as const
153
+
154
+ return (
155
+ <span
156
+ ref={containerRef}
157
+ data-slot="sparkline"
158
+ role="img"
159
+ aria-label={ariaLabel}
160
+ className={cn("block", className)}
161
+ style={{ height }}
162
+ {...props}
163
+ >
164
+ {hasSize ? (
165
+ <ResponsiveContainer width="100%" height="100%">
166
+ {type === "area" ? (
167
+ <AreaChart
168
+ data={chartData}
169
+ margin={{ top: 2, right: 2, bottom: 2, left: 2 }}
170
+ >
171
+ <defs>
172
+ <linearGradient id={gradientId} x1="0" y1="0" x2="0" y2="1">
173
+ <stop offset="5%" stopColor={color} stopOpacity={0.3} />
174
+ <stop offset="95%" stopColor={color} stopOpacity={0} />
175
+ </linearGradient>
176
+ </defs>
177
+ <Area
178
+ {...commonLineProps}
179
+ fill={`url(#${gradientId})`}
180
+ fillOpacity={1}
181
+ yAxisId={0}
182
+ />
183
+ </AreaChart>
184
+ ) : (
185
+ <LineChart
186
+ data={chartData}
187
+ margin={{ top: 2, right: 2, bottom: 2, left: 2 }}
188
+ >
189
+ <Line {...commonLineProps} yAxisId={0} />
190
+ </LineChart>
191
+ )}
192
+ </ResponsiveContainer>
193
+ ) : null}
194
+ </span>
195
+ )
196
+ }
197
+
198
+ export { Sparkline }
@@ -46,14 +46,25 @@ const closeButtonBySize = {
46
46
  lg: { button: "ml-1", icon: "size-4" },
47
47
  } as const
48
48
 
49
+ // Icon size per tag size — mirrors the close-button icon scale.
50
+ const iconSizeBySize = {
51
+ xs: "size-3",
52
+ sm: "size-3",
53
+ md: "size-4",
54
+ lg: "size-4",
55
+ } as const
56
+
49
57
  interface TagProps extends React.ComponentProps<"div">, VariantProps<typeof tagVariants> {
50
58
  label: string
59
+ /** Optional leading icon. Pass a Lucide or custom SVG element. Sized automatically per `size`. */
60
+ icon?: React.ReactNode
51
61
  onClose?: () => void
52
62
  }
53
63
 
54
- function Tag({ className, variant, size, label, onClose, style, ...props }: TagProps) {
64
+ function Tag({ className, variant, size, label, icon, onClose, style, ...props }: TagProps) {
55
65
  const resolvedSize = size ?? "md"
56
66
  const closeButton = closeButtonBySize[resolvedSize]
67
+ const iconSize = iconSizeBySize[resolvedSize]
57
68
  return (
58
69
  <div
59
70
  data-size={resolvedSize}
@@ -65,6 +76,11 @@ function Tag({ className, variant, size, label, onClose, style, ...props }: TagP
65
76
  }}
66
77
  {...props}
67
78
  >
79
+ {icon && (
80
+ <span className={cn("shrink-0 [&>svg]:size-full", iconSize)} aria-hidden>
81
+ {icon}
82
+ </span>
83
+ )}
68
84
  <span>{label}</span>
69
85
  {onClose && (
70
86
  <button
@@ -2,12 +2,90 @@
2
2
 
3
3
  import * as React from "react";
4
4
  import { XIcon, CheckIcon } from "lucide-react";
5
+ import { cva } from "class-variance-authority";
5
6
  import { cn } from "../../lib/utils";
6
7
 
8
+ // ─── Variants ─────────────────────────────────────────────────────────────────
9
+
10
+ /**
11
+ * Container sizing. The wrapper is a flex-wrap field, so heights are `min-h-*`
12
+ * (tags wrap onto additional lines) rather than the fixed `h-*` Input uses.
13
+ *
14
+ * `default` keeps the pre-size rendering byte-for-byte (min-h-11 / 44px — the
15
+ * SC 2.5.5 Enhanced floor the registry a11yContract documents), so adding the
16
+ * prop is additive for every existing consumer. The ladder steps around it:
17
+ * sm=36px (Input default / dense form chrome), lg=48px, xl=56px (hero-tier
18
+ * filter fields). Chips and the inner input scale with the container via the
19
+ * matching `tagsInputItemVariants` / `tagsInputFieldVariants` below.
20
+ */
21
+ const tagsInputVariants = cva(
22
+ [
23
+ "flex flex-wrap items-center rounded-md border border-input bg-background cursor-text",
24
+ "focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
25
+ ],
26
+ {
27
+ variants: {
28
+ size: {
29
+ sm: "min-h-9 gap-1 px-2.5 py-1",
30
+ default: "min-h-11 gap-1.5 px-3 py-2",
31
+ lg: "min-h-12 gap-2 px-4 py-2.5",
32
+ xl: "min-h-14 gap-2 px-4 py-3",
33
+ },
34
+ },
35
+ defaultVariants: { size: "default" },
36
+ }
37
+ );
38
+
39
+ /** Chip sizing — text never drops below text-xs (14px, the BADS floor). */
40
+ const tagsInputItemVariants = cva(
41
+ "inline-flex max-w-[160px] items-center rounded-md font-medium transition-colors",
42
+ {
43
+ variants: {
44
+ size: {
45
+ sm: "gap-0.5 px-1.5 py-0 text-xs",
46
+ default: "gap-1 px-2 py-0.5 text-sm",
47
+ lg: "gap-1 px-2.5 py-1 text-sm",
48
+ xl: "gap-1.5 px-3 py-1.5 text-base",
49
+ },
50
+ },
51
+ defaultVariants: { size: "default" },
52
+ }
53
+ );
54
+
55
+ /** Inner text field sizing — mirrors Input's text scale per size. */
56
+ const tagsInputFieldVariants = cva(
57
+ "min-w-[80px] flex-1 bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-0",
58
+ {
59
+ variants: {
60
+ size: {
61
+ sm: "text-sm",
62
+ default: "text-sm",
63
+ lg: "text-base",
64
+ xl: "text-base",
65
+ },
66
+ },
67
+ defaultVariants: { size: "default" },
68
+ }
69
+ );
70
+
71
+ const DELETE_ICON_SIZE: Record<NonNullable<TagsInputProps["size"]>, string> = {
72
+ sm: "size-3",
73
+ default: "size-3",
74
+ lg: "size-3.5",
75
+ xl: "size-4",
76
+ };
77
+
7
78
  // ─── Types ────────────────────────────────────────────────────────────────────
8
79
 
9
80
  export interface TagsInputProps
10
81
  extends Omit<React.HTMLAttributes<HTMLDivElement>, "onChange"> {
82
+ /**
83
+ * Container size. `default` (min-h-11, 44px) is the SC 2.5.5 Enhanced floor
84
+ * and the pre-existing rendering; `sm` (min-h-9, 36px) matches Input's
85
+ * default for dense form chrome; `lg` (48px) and `xl` (56px) suit hero-tier
86
+ * filter fields. Chips and the inner text field scale with the container.
87
+ */
88
+ size?: "sm" | "default" | "lg" | "xl";
11
89
  /** The current list of tag values. */
12
90
  value: string[];
13
91
  /** Callback fired when the tag list changes. */
@@ -40,6 +118,7 @@ export function TagsInput({
40
118
  allowDuplicates = false,
41
119
  delimiters = [","],
42
120
  suggestions,
121
+ size = "default",
43
122
  className,
44
123
  ...props
45
124
  }: TagsInputProps) {
@@ -210,13 +289,12 @@ export function TagsInput({
210
289
  <div className="relative">
211
290
  <div
212
291
  data-slot="tags-input"
292
+ data-size={size}
213
293
  data-disabled={disabled || undefined}
214
294
  aria-disabled={disabled || undefined}
215
295
  onClick={() => !disabled && inputRef.current?.focus()}
216
296
  className={cn(
217
- "flex min-h-11 flex-wrap items-center gap-1.5 rounded-md border border-input bg-background px-3 py-2",
218
- "cursor-text",
219
- "focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
297
+ tagsInputVariants({ size }),
220
298
  disabled && "cursor-not-allowed border-border/50 bg-muted/30 pointer-events-none",
221
299
  className
222
300
  )}
@@ -228,8 +306,7 @@ export function TagsInput({
228
306
  data-slot="tags-input-item"
229
307
  data-focused={focusedTagIndex === index || undefined}
230
308
  className={cn(
231
- "inline-flex max-w-[160px] items-center gap-1 rounded-md px-2 py-0.5",
232
- "text-sm font-medium transition-colors",
309
+ tagsInputItemVariants({ size }),
233
310
  disabled
234
311
  ? "bg-muted text-muted-foreground"
235
312
  : "bg-secondary text-secondary-foreground",
@@ -258,7 +335,7 @@ export function TagsInput({
258
335
  transitionTimingFunction: "var(--ease-out)",
259
336
  }}
260
337
  >
261
- <XIcon className="size-3" strokeWidth={1.5} aria-hidden />
338
+ <XIcon className={DELETE_ICON_SIZE[size]} strokeWidth={1.5} aria-hidden />
262
339
  </button>
263
340
  )}
264
341
  </span>
@@ -283,11 +360,7 @@ export function TagsInput({
283
360
  disabled={disabled || atMax}
284
361
  placeholder={inputPlaceholder}
285
362
  aria-label={placeholder ?? "Add tags, press Enter or comma to confirm"}
286
- className={cn(
287
- "min-w-[80px] flex-1 bg-transparent text-sm outline-none",
288
- "placeholder:text-muted-foreground",
289
- "disabled:cursor-not-allowed disabled:opacity-0"
290
- )}
363
+ className={tagsInputFieldVariants({ size })}
291
364
  />
292
365
  </div>
293
366
 
@@ -23,10 +23,12 @@ function ToggleGroup({
23
23
  size,
24
24
  spacing = 0,
25
25
  children,
26
+ orientation = "horizontal",
26
27
  ...props
27
28
  }: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
28
29
  VariantProps<typeof toggleVariants> & {
29
30
  spacing?: number
31
+ orientation?: "horizontal" | "vertical"
30
32
  }) {
31
33
  return (
32
34
  <ToggleGroupPrimitive.Root
@@ -34,9 +36,17 @@ function ToggleGroup({
34
36
  data-variant={variant}
35
37
  data-size={size}
36
38
  data-spacing={spacing}
39
+ data-orientation={orientation}
40
+ orientation={orientation}
37
41
  style={{ "--gap": spacing } as React.CSSProperties}
38
42
  className={cn(
39
43
  "group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs",
44
+ // vertical orientation: stack items in a column, collapse to intrinsic width
45
+ "data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch",
46
+ // vertical + no-spacing: round top and bottom caps instead of left/right
47
+ "data-[orientation=vertical]:data-[spacing=0]:[&>[data-slot=toggle-group-item]]:rounded-none",
48
+ "data-[orientation=vertical]:data-[spacing=0]:[&>[data-slot=toggle-group-item]:first-child]:rounded-t-md",
49
+ "data-[orientation=vertical]:data-[spacing=0]:[&>[data-slot=toggle-group-item]:last-child]:rounded-b-md",
40
50
  className
41
51
  )}
42
52
  {...props}
@@ -70,7 +80,10 @@ function ToggleGroupItem({
70
80
  size: context.size || size,
71
81
  }),
72
82
  "w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10",
83
+ // horizontal (default): left/right rounded caps, suppress left border between items
73
84
  "data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",
85
+ // vertical: suppress top border between items; the group-level classes handle the corner radii
86
+ "group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:rounded-none group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
74
87
  className
75
88
  )}
76
89
  {...props}