@behavioral-agentic-design-system/core 0.24.0 → 0.27.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 (137) hide show
  1. package/package.json +5 -2
  2. package/scripts/build-tokens.cjs +87 -5
  3. package/src/app/preview/components/page.tsx +4745 -244
  4. package/src/app/shell.tsx +18 -6
  5. package/src/components/customize/brand-mark-section.tsx +1 -1
  6. package/src/components/customize-tab.tsx +2 -2
  7. package/src/components/home-tab.tsx +2 -2
  8. package/src/components/ui/action-bar.tsx +142 -0
  9. package/src/components/ui/affix.tsx +109 -0
  10. package/src/components/ui/alert.tsx +37 -3
  11. package/src/components/ui/anchor.tsx +136 -0
  12. package/src/components/ui/angle-slider.tsx +265 -0
  13. package/src/components/ui/autocomplete.tsx +223 -0
  14. package/src/components/ui/avatar.tsx +8 -2
  15. package/src/components/ui/blockquote.tsx +112 -0
  16. package/src/components/ui/bottom-navigation.tsx +144 -0
  17. package/src/components/ui/burger.tsx +117 -0
  18. package/src/components/ui/button.tsx +101 -3
  19. package/src/components/ui/calendar.tsx +1 -1
  20. package/src/components/ui/card.tsx +43 -5
  21. package/src/components/ui/carousel.tsx +10 -5
  22. package/src/components/ui/cascader.tsx +253 -0
  23. package/src/components/ui/checkbox-card.tsx +176 -0
  24. package/src/components/ui/checkbox-group.tsx +231 -0
  25. package/src/components/ui/checkbox.tsx +14 -3
  26. package/src/components/ui/chip.tsx +143 -0
  27. package/src/components/ui/circular-progress.tsx +2 -2
  28. package/src/components/ui/color-swatch.tsx +73 -0
  29. package/src/components/ui/copy-button.tsx +21 -4
  30. package/src/components/ui/date-picker.tsx +6 -3
  31. package/src/components/ui/date-range-picker.tsx +6 -3
  32. package/src/components/ui/float-label.tsx +114 -0
  33. package/src/components/ui/floating-action-button.tsx +179 -0
  34. package/src/components/ui/floating-panel.tsx +129 -0
  35. package/src/components/ui/format-number.tsx +122 -0
  36. package/src/components/ui/highlight.tsx +85 -0
  37. package/src/components/ui/image.tsx +195 -0
  38. package/src/components/ui/index.ts +51 -0
  39. package/src/components/ui/indicator.tsx +2 -2
  40. package/src/components/ui/input.tsx +48 -4
  41. package/src/components/ui/kbd.tsx +1 -1
  42. package/src/components/ui/link.tsx +158 -0
  43. package/src/components/ui/listbox.tsx +426 -0
  44. package/src/components/ui/loading-overlay.tsx +80 -0
  45. package/src/components/ui/marquee.tsx +193 -0
  46. package/src/components/ui/masonry.tsx +164 -0
  47. package/src/components/ui/meter.tsx +186 -0
  48. package/src/components/ui/motion-toggle.tsx +170 -0
  49. package/src/components/ui/notification.tsx +175 -0
  50. package/src/components/ui/overlay.tsx +63 -0
  51. package/src/components/ui/progress.tsx +95 -4
  52. package/src/components/ui/rating-group.tsx +1 -0
  53. package/src/components/ui/separator.tsx +57 -1
  54. package/src/components/ui/sidebar.tsx +1 -1
  55. package/src/components/ui/signature-pad.tsx +381 -0
  56. package/src/components/ui/skeleton.tsx +59 -2
  57. package/src/components/ui/skip-link.tsx +117 -0
  58. package/src/components/ui/slider.tsx +86 -1
  59. package/src/components/ui/spoiler.tsx +131 -0
  60. package/src/components/ui/tabs.tsx +1 -1
  61. package/src/components/ui/text.tsx +135 -0
  62. package/src/components/ui/textarea.tsx +66 -2
  63. package/src/components/ui/timeline.tsx +71 -14
  64. package/src/components/ui/timer.tsx +183 -0
  65. package/src/components/ui/tour.tsx +332 -0
  66. package/src/components/ui/transfer-list.tsx +343 -0
  67. package/src/components/ui/typing-indicator.tsx +96 -0
  68. package/src/components/ui/visually-hidden.tsx +42 -0
  69. package/src/components/ui/watermark.tsx +0 -0
  70. package/src/components/ui/word-rotate.tsx +82 -0
  71. package/src/data/docs-index.ts +10 -2
  72. package/src/stories/ActionBar.stories.tsx +201 -0
  73. package/src/stories/Affix.stories.tsx +165 -0
  74. package/src/stories/Alert.stories.tsx +58 -0
  75. package/src/stories/Anchor.stories.tsx +236 -0
  76. package/src/stories/AngleSlider.stories.tsx +128 -0
  77. package/src/stories/Autocomplete.stories.tsx +216 -0
  78. package/src/stories/Avatar.stories.tsx +73 -1
  79. package/src/stories/Blockquote.stories.tsx +148 -0
  80. package/src/stories/BottomNavigation.stories.tsx +195 -0
  81. package/src/stories/Burger.stories.tsx +79 -0
  82. package/src/stories/Button.stories.tsx +103 -2
  83. package/src/stories/Calendar.stories.tsx +4 -0
  84. package/src/stories/Card.stories.tsx +30 -0
  85. package/src/stories/Carousel.stories.tsx +2 -1
  86. package/src/stories/Cascader.stories.tsx +285 -0
  87. package/src/stories/Checkbox.stories.tsx +13 -0
  88. package/src/stories/CheckboxCard.stories.tsx +210 -0
  89. package/src/stories/CheckboxGroup.stories.tsx +186 -0
  90. package/src/stories/Chip.stories.tsx +173 -0
  91. package/src/stories/CircularProgress.stories.tsx +3 -0
  92. package/src/stories/ColorSwatch.stories.tsx +81 -0
  93. package/src/stories/CopyButton.stories.tsx +3 -3
  94. package/src/stories/DatePicker.stories.tsx +3 -0
  95. package/src/stories/DateRangePicker.stories.tsx +3 -0
  96. package/src/stories/Editable.stories.tsx +14 -0
  97. package/src/stories/FloatLabel.stories.tsx +148 -0
  98. package/src/stories/FloatingActionButton.stories.tsx +215 -0
  99. package/src/stories/FloatingPanel.stories.tsx +176 -0
  100. package/src/stories/FormatNumber.stories.tsx +308 -0
  101. package/src/stories/Highlight.stories.tsx +140 -0
  102. package/src/stories/Image.stories.tsx +141 -0
  103. package/src/stories/Indicator.stories.tsx +3 -0
  104. package/src/stories/Input.stories.tsx +33 -0
  105. package/src/stories/Kbd.stories.tsx +3 -0
  106. package/src/stories/Link.stories.tsx +198 -0
  107. package/src/stories/Listbox.stories.tsx +240 -0
  108. package/src/stories/LoadingOverlay.stories.tsx +148 -0
  109. package/src/stories/Marquee.stories.tsx +170 -0
  110. package/src/stories/Masonry.stories.tsx +227 -0
  111. package/src/stories/Meter.stories.tsx +150 -0
  112. package/src/stories/MotionToggle.stories.tsx +85 -0
  113. package/src/stories/Notification.stories.tsx +264 -0
  114. package/src/stories/Overlay.stories.tsx +169 -0
  115. package/src/stories/PasswordInput.stories.tsx +4 -0
  116. package/src/stories/Progress.stories.tsx +70 -27
  117. package/src/stories/RatingGroup.stories.tsx +5 -0
  118. package/src/stories/Separator.stories.tsx +41 -5
  119. package/src/stories/Sidebar.stories.tsx +2 -1
  120. package/src/stories/SignaturePad.stories.tsx +112 -0
  121. package/src/stories/Skeleton.stories.tsx +23 -4
  122. package/src/stories/SkipLink.stories.tsx +137 -0
  123. package/src/stories/Slider.stories.tsx +28 -0
  124. package/src/stories/Spoiler.stories.tsx +122 -0
  125. package/src/stories/Tabs.stories.tsx +2 -1
  126. package/src/stories/Text.stories.tsx +191 -0
  127. package/src/stories/Textarea.stories.tsx +58 -6
  128. package/src/stories/Timeline.stories.tsx +82 -0
  129. package/src/stories/Timer.stories.tsx +160 -0
  130. package/src/stories/Tour.stories.tsx +191 -0
  131. package/src/stories/TransferList.stories.tsx +190 -0
  132. package/src/stories/TypingIndicator.stories.tsx +139 -0
  133. package/src/stories/VisuallyHidden.stories.tsx +105 -0
  134. package/src/stories/Watermark.stories.tsx +212 -0
  135. package/src/stories/WordRotate.stories.tsx +101 -0
  136. package/src/styles.css +88 -6
  137. package/src/tokens.json +3 -3
@@ -0,0 +1,170 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { Monitor, Pause, Play } from "lucide-react";
5
+
6
+ import { cn } from "../../lib/utils";
7
+ import { storageKey, readMigrated } from "../../lib/storage";
8
+ import {
9
+ SegmentedControl,
10
+ SegmentedControlItem,
11
+ } from "./segmented-control";
12
+
13
+ /**
14
+ * Motion preference, mirrored onto the `data-motion` attribute the base layer
15
+ * reads (see `packages/core/scripts/build-tokens.cjs` → the reduced-motion
16
+ * block). Three states, not a boolean, because "off" is ambiguous when the OS
17
+ * is already reducing motion:
18
+ * • `system` — no attribute; the OS `prefers-reduced-motion` query governs.
19
+ * • `reduce` — force motion OFF on this site regardless of the OS.
20
+ * • `full` — force motion ON even if the OS prefers reduce (some users set
21
+ * OS reduce globally but trust a given site with motion).
22
+ */
23
+ export type MotionPreference = "system" | "reduce" | "full";
24
+
25
+ const OPTIONS: {
26
+ value: MotionPreference;
27
+ label: string;
28
+ icon: React.ReactNode;
29
+ hint: string;
30
+ }[] = [
31
+ {
32
+ value: "system",
33
+ label: "System",
34
+ icon: <Monitor />,
35
+ hint: "Follow your device's reduce-motion setting.",
36
+ },
37
+ {
38
+ value: "reduce",
39
+ label: "Reduced",
40
+ icon: <Pause />,
41
+ hint: "Turn off animations on this site.",
42
+ },
43
+ {
44
+ value: "full",
45
+ label: "Full",
46
+ icon: <Play />,
47
+ hint: "Keep animations even if your device reduces motion.",
48
+ },
49
+ ];
50
+
51
+ /**
52
+ * Reflect a preference onto <html>. `system` REMOVES the attribute so the OS
53
+ * media query is the sole authority again — setting `data-motion="system"`
54
+ * would be inert but leaves a stale attribute around, so we clear it.
55
+ */
56
+ function applyMotionPreference(pref: MotionPreference) {
57
+ if (typeof document === "undefined") return;
58
+ const root = document.documentElement;
59
+ if (pref === "system") root.removeAttribute("data-motion");
60
+ else root.setAttribute("data-motion", pref);
61
+ }
62
+
63
+ export interface MotionToggleProps {
64
+ /**
65
+ * localStorage suffix, prefixed per-fork via `storageKey()` (e.g.
66
+ * `BADS.motion` / `CLAP.motion`). Default `"motion"`.
67
+ */
68
+ storageSuffix?: string;
69
+ /** Size passthrough to the underlying SegmentedControl. */
70
+ size?: "sm" | "default" | "lg";
71
+ /** Fires after a new preference is applied + persisted. */
72
+ onPreferenceChange?: (pref: MotionPreference) => void;
73
+ /**
74
+ * Render the active option's one-line hint as muted helper text beneath the
75
+ * control. Off by default so the bare control stays compact; the showcase
76
+ * and settings surfaces turn it on.
77
+ */
78
+ showHint?: boolean;
79
+ /** Accessible label for the radiogroup. Default `"Motion"`. */
80
+ label?: string;
81
+ className?: string;
82
+ }
83
+
84
+ /**
85
+ * In-app motion preference control — an **opt-in** companion to the OS
86
+ * reduce-motion setting. NOT mounted in the default BADS shell; a fork drops
87
+ * it into its own settings/appearance surface when it wants to give users an
88
+ * in-product motion switch (some users can't change their OS setting, or want
89
+ * to override it for one site).
90
+ *
91
+ * Composes {@link SegmentedControl} (radiogroup semantics, roving tabindex,
92
+ * token-driven sliding indicator) and persists to localStorage via the
93
+ * shared `storageKey`/`readMigrated` helpers, so a renamed fork keeps its
94
+ * per-slug prefix. The base layer does the actual motion suppression off the
95
+ * `data-motion` attribute this writes — the component only owns state, not the
96
+ * `!important` kill rules.
97
+ *
98
+ * Flash caveat: the preference is read in an effect, so a user who chose
99
+ * `reduce` while their OS does NOT prefer reduce may see one frame of motion on
100
+ * first load before the attribute lands. Users who set OS reduce see no flash
101
+ * (pure-CSS suppression, no JS needed). A fork wanting zero-flash for the
102
+ * in-app override can mirror this read in its existing theme-init inline
103
+ * `<head>` script, after `window.__BADS_SLUG__` is set.
104
+ */
105
+ export function MotionToggle({
106
+ storageSuffix = "motion",
107
+ size = "default",
108
+ onPreferenceChange,
109
+ showHint = false,
110
+ label = "Motion",
111
+ className,
112
+ }: MotionToggleProps) {
113
+ const [pref, setPref] = React.useState<MotionPreference>("system");
114
+
115
+ // Hydrate from storage on mount and reflect it onto <html>. Client-only;
116
+ // SSR renders the `system` default (no attribute), matching the pre-toggle
117
+ // behavior so there's no hydration mismatch for forks that don't persist a
118
+ // value yet.
119
+ React.useEffect(() => {
120
+ const stored = readMigrated(storageSuffix);
121
+ if (stored === "reduce" || stored === "full" || stored === "system") {
122
+ setPref(stored);
123
+ applyMotionPreference(stored);
124
+ }
125
+ }, [storageSuffix]);
126
+
127
+ const handleChange = (value: string) => {
128
+ const next = value as MotionPreference;
129
+ setPref(next);
130
+ applyMotionPreference(next);
131
+ try {
132
+ window.localStorage.setItem(storageKey(storageSuffix), next);
133
+ } catch {
134
+ // Quota exceeded / privacy mode — the in-memory + attribute state still
135
+ // applies for this session; only cross-reload persistence is lost.
136
+ }
137
+ onPreferenceChange?.(next);
138
+ };
139
+
140
+ const activeHint = OPTIONS.find((o) => o.value === pref)?.hint;
141
+
142
+ return (
143
+ <div className={cn("inline-flex flex-col gap-1.5", className)}>
144
+ <SegmentedControl
145
+ value={pref}
146
+ onValueChange={handleChange}
147
+ size={size}
148
+ label={label}
149
+ >
150
+ {OPTIONS.map((o) => (
151
+ <SegmentedControlItem
152
+ key={o.value}
153
+ value={o.value}
154
+ icon={o.icon}
155
+ title={o.hint}
156
+ >
157
+ {o.label}
158
+ </SegmentedControlItem>
159
+ ))}
160
+ </SegmentedControl>
161
+ {showHint && activeHint ? (
162
+ // aria-live so the reason for the current mode is announced when the
163
+ // selection changes (the title tooltip isn't keyboard-reachable).
164
+ <p className="text-xs text-muted-foreground" aria-live="polite">
165
+ {activeHint}
166
+ </p>
167
+ ) : null}
168
+ </div>
169
+ );
170
+ }
@@ -0,0 +1,175 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+ import { X } from "lucide-react"
4
+
5
+ import { cn } from "../../lib/utils"
6
+ import { Spinner } from "./spinner"
7
+
8
+ // Notification is the persisted feed/inbox item between Alert (static inline
9
+ // callout, role="alert", no dismiss) and Sonner (ephemeral auto-dismissing
10
+ // toast overlay). It shares their 4px left-accent-bar visual language so the
11
+ // three status surfaces read as one family.
12
+ //
13
+ // NOTE: the accent colors use arbitrary `border-l-[var(--token)]` with `!`,
14
+ // NOT the named `border-l-primary` utilities — in this Tailwind v4 setup the
15
+ // named border-color utilities don't emit a rule (see alert.tsx for the full
16
+ // story), so the accent would silently fall through to the `:root *`
17
+ // border-border reset. Also load-bearing: `--success` / `--warning` are oklch
18
+ // tokens, so they're consumed as `[var(--success)]` — wrapping them in
19
+ // `hsl(var(--success))` produces invalid CSS that fails silently.
20
+ const notificationVariants = cva(
21
+ // The variant hue lives ONLY in the non-text accent bar + icon (both
22
+ // audited ≥3:1 non-text). Title/description/timestamp stay foreground /
23
+ // muted-foreground in every variant so text holds the AAA 7:1 floor.
24
+ "relative flex w-full gap-3 overflow-hidden rounded-lg border border-border border-l-4 bg-card px-4 py-3 text-sm transition-[background-color,opacity]",
25
+ {
26
+ variants: {
27
+ variant: {
28
+ default:
29
+ "border-l-[var(--primary)]! bg-primary/5 dark:bg-primary/10 [&_[data-slot=notification-icon]]:text-primary",
30
+ destructive:
31
+ "border-l-[var(--destructive)]! bg-destructive/5 dark:bg-destructive/10 [&_[data-slot=notification-icon]]:text-destructive",
32
+ success:
33
+ "border-l-[var(--success)]! bg-[var(--success)]/5 dark:bg-[var(--success)]/10 [&_[data-slot=notification-icon]]:text-[var(--success)]",
34
+ warning:
35
+ "border-l-[var(--warning)]! bg-[var(--warning)]/5 dark:bg-[var(--warning)]/10 [&_[data-slot=notification-icon]]:text-[var(--warning)]",
36
+ },
37
+ },
38
+ defaultVariants: {
39
+ variant: "default",
40
+ },
41
+ }
42
+ )
43
+
44
+ // Omit the native div `title` (a tooltip string) — Notification's `title` is
45
+ // the ReactNode heading of the card.
46
+ type NotificationProps = Omit<React.ComponentProps<"div">, "title"> &
47
+ VariantProps<typeof notificationVariants> & {
48
+ /** Optional heading. Rendered single-line with truncation. */
49
+ title?: React.ReactNode
50
+ /** Body text below the title. */
51
+ description?: React.ReactNode
52
+ /** Leading icon or avatar. Replaced by a Spinner while `loading`. */
53
+ icon?: React.ReactNode
54
+ /** Meta line, e.g. "2 min ago" / "Just now". */
55
+ timestamp?: React.ReactNode
56
+ /** Marks the item unread: renders the dot indicator + `data-unread`. */
57
+ unread?: boolean
58
+ /** Shows a Spinner in the icon slot and sets `aria-busy` on the root. */
59
+ loading?: boolean
60
+ /** When provided, renders the built-in dismiss (X) button. */
61
+ onDismiss?: () => void
62
+ }
63
+
64
+ function Notification({
65
+ className,
66
+ variant,
67
+ title,
68
+ description,
69
+ icon,
70
+ timestamp,
71
+ unread,
72
+ loading,
73
+ onDismiss,
74
+ ...props
75
+ }: NotificationProps) {
76
+ // The close button needs a real string name — `title` may be a ReactNode,
77
+ // so only fold it into the aria-label when it's actually a string.
78
+ const dismissLabel =
79
+ typeof title === "string" ? `Dismiss: ${title}` : "Dismiss notification"
80
+
81
+ return (
82
+ <div
83
+ data-slot="notification"
84
+ data-unread={unread || undefined}
85
+ aria-busy={loading || undefined}
86
+ className={cn(notificationVariants({ variant }), className)}
87
+ // Pattern (c) motion: token-driven duration/easing resolved at runtime
88
+ // against :root. Never `duration-fast` (compiles to nothing in v4) or
89
+ // duration-[var(--x)] form (unreliable scanner pickup in v4).
90
+ style={{
91
+ transitionDuration: "var(--duration-fast)",
92
+ transitionTimingFunction: "var(--ease-out)",
93
+ }}
94
+ {...props}
95
+ >
96
+ {/* Unread dot — decorative; machine-readable state is `data-unread`
97
+ on the root. Positioned clear of the dismiss button. */}
98
+ {unread && (
99
+ <span
100
+ aria-hidden="true"
101
+ data-slot="notification-unread-dot"
102
+ className={cn(
103
+ "absolute top-3 size-2 shrink-0 rounded-full bg-primary",
104
+ onDismiss ? "right-10" : "right-3"
105
+ )}
106
+ />
107
+ )}
108
+
109
+ {/* Icon / avatar slot. Spinner takes over while loading. */}
110
+ {(icon || loading) && (
111
+ <div
112
+ data-slot="notification-icon"
113
+ className="mt-0.5 shrink-0 [&>svg]:size-5 [&_svg]:shrink-0"
114
+ >
115
+ {loading ? <Spinner size="sm" variant="muted" /> : icon}
116
+ </div>
117
+ )}
118
+
119
+ {/* Content column — min-w-0 so truncate can fire inside flex. */}
120
+ <div className="min-w-0 flex-1 space-y-1">
121
+ {title && (
122
+ <div
123
+ data-slot="notification-title"
124
+ className="min-w-0 truncate pr-6 text-sm font-medium leading-tight text-foreground"
125
+ >
126
+ {title}
127
+ </div>
128
+ )}
129
+ {description && (
130
+ <div
131
+ data-slot="notification-description"
132
+ className="min-w-0 text-sm leading-relaxed text-muted-foreground [overflow-wrap:anywhere]"
133
+ >
134
+ {description}
135
+ </div>
136
+ )}
137
+ {timestamp && (
138
+ <div
139
+ data-slot="notification-timestamp"
140
+ className="text-xs tabular-nums text-muted-foreground"
141
+ >
142
+ {timestamp}
143
+ </div>
144
+ )}
145
+ </div>
146
+
147
+ {/* Built-in dismiss. A small utility action (Tag/Sonner-close class),
148
+ not a flow-changing CTA — so no min-h-11 (SC 2.5.5 Enhanced applies
149
+ only to flow-changing controls per BADS policy).
150
+ SC 2.5.8 AA: size-6 = 24×24px. The offset-exception applies — the
151
+ dismiss button is separated from the notification body text (its nearest
152
+ interactive neighbour) by ≥24 px of padding on all sides via ml-auto +
153
+ self-start layout. Mirror of the InputClearable precedent in PR #209.
154
+ The focus ring is instant (box-shadow deliberately excluded from the
155
+ transition list). */}
156
+ {onDismiss && (
157
+ <button
158
+ type="button"
159
+ data-slot="notification-dismiss"
160
+ aria-label={dismissLabel}
161
+ onClick={onDismiss}
162
+ className="ml-auto flex size-6 shrink-0 items-center justify-center self-start rounded-sm text-muted-foreground opacity-70 transition-[opacity,transform,color] hover:opacity-100 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 active:scale-95"
163
+ style={{
164
+ transitionDuration: "var(--duration-fast)",
165
+ transitionTimingFunction: "var(--ease-out)",
166
+ }}
167
+ >
168
+ <X strokeWidth={1.5} className="size-4" aria-hidden="true" />
169
+ </button>
170
+ )}
171
+ </div>
172
+ )
173
+ }
174
+
175
+ export { Notification, notificationVariants, type NotificationProps }
@@ -0,0 +1,63 @@
1
+ import * as React from "react"
2
+ import { cn } from "../../lib/utils"
3
+
4
+ type OverlayProps = React.ComponentProps<"div"> & {
5
+ /** Utility class painting the overlay surface. Default "bg-background/80". */
6
+ color?: string
7
+ /** Adds a backdrop blur to the surface. */
8
+ blur?: boolean
9
+ /** Radius utility class — match the container being covered. */
10
+ radius?: string
11
+ /** Stacking level, applied as inline style.zIndex. */
12
+ zIndex?: number
13
+ /** Cover the viewport (fixed) instead of the nearest positioned ancestor. */
14
+ fixed?: boolean
15
+ }
16
+
17
+ /**
18
+ * Thin translucent layer that covers its nearest `position: relative`
19
+ * ancestor (or the viewport with `fixed`) to visually freeze the content
20
+ * underneath — the raw backdrop primitive LoadingOverlay builds on.
21
+ *
22
+ * Purely decorative: `aria-hidden`, no role, never focusable. It blocks
23
+ * pointer input by sitting on top, so the REASON the region is frozen must
24
+ * ship in a visible, announced element beside it (disabled inputs, a
25
+ * `role="status"` message, or LoadingOverlay for loading states).
26
+ * Mount/unmount is the consumer's responsibility; the fade rides
27
+ * `transition-opacity` on the motion tokens and collapses under the base
28
+ * layer's reduced-motion rule.
29
+ */
30
+ function Overlay({
31
+ color = "bg-background/80",
32
+ blur = false,
33
+ radius = "rounded-none",
34
+ zIndex = 10,
35
+ fixed = false,
36
+ className,
37
+ style,
38
+ ...props
39
+ }: OverlayProps) {
40
+ return (
41
+ <div
42
+ data-slot="overlay"
43
+ aria-hidden="true"
44
+ className={cn(
45
+ "inset-0 opacity-100 transition-opacity",
46
+ fixed ? "fixed" : "absolute",
47
+ color,
48
+ radius,
49
+ blur && "backdrop-blur-sm",
50
+ className
51
+ )}
52
+ style={{
53
+ transitionDuration: "var(--duration-fast)",
54
+ transitionTimingFunction: "var(--ease-out)",
55
+ zIndex,
56
+ ...style,
57
+ }}
58
+ {...props}
59
+ />
60
+ )
61
+ }
62
+
63
+ export { Overlay, type OverlayProps }
@@ -5,12 +5,54 @@ import * as ProgressPrimitive from "@radix-ui/react-progress"
5
5
 
6
6
  import { cn } from "../../lib/utils"
7
7
 
8
+ type ProgressProps = React.ComponentProps<typeof ProgressPrimitive.Root> & {
9
+ /**
10
+ * Optional label rendered left-aligned above the track. Becomes the
11
+ * progressbar's accessible name via a generated-id aria-labelledby —
12
+ * unless the consumer already passed aria-label / aria-labelledby,
13
+ * which always win.
14
+ */
15
+ label?: React.ReactNode
16
+ /**
17
+ * Renders the value text right-aligned above the track. The visible string
18
+ * is getValueLabel(value, max) — the same function Radix announces through
19
+ * aria-valuetext — so the visible and announced values cannot diverge.
20
+ * Customize both at once via the (passthrough) getValueLabel prop, e.g.
21
+ * getValueLabel={(v, m) => `${v} of ${m} components`}. Ignored while the
22
+ * progress is indeterminate (no numeric value).
23
+ */
24
+ showValue?: boolean
25
+ }
26
+
27
+ // Mirrors Radix Progress's built-in getValueLabel default so the visible
28
+ // value text matches the announced aria-valuetext exactly.
29
+ function defaultGetValueLabel(value: number, max: number) {
30
+ return `${Math.round((value / max) * 100)}%`
31
+ }
32
+
8
33
  function Progress({
9
34
  className,
10
35
  value,
36
+ max,
37
+ getValueLabel,
38
+ label,
39
+ showValue,
11
40
  ...props
12
- }: React.ComponentProps<typeof ProgressPrimitive.Root>) {
13
- return (
41
+ }: ProgressProps) {
42
+ const labelId = React.useId()
43
+ const showLabel = label != null && label !== false
44
+ const showValueText = Boolean(showValue) && typeof value === "number"
45
+ const hasHeader = showLabel || showValueText
46
+ const resolvedMax = typeof max === "number" && max > 0 ? max : 100
47
+ // Labeled path: fill is max-aware (value 14 of max 36 fills ~39%) so the
48
+ // bar can never contradict the visible/announced value text. Bare path:
49
+ // keeps the historical value-as-percent math untouched (byte-identical).
50
+ const fillPercent =
51
+ hasHeader && typeof value === "number"
52
+ ? Math.min(100, Math.max(0, (value / resolvedMax) * 100))
53
+ : value || 0
54
+
55
+ const track = (
14
56
  <ProgressPrimitive.Root
15
57
  data-slot="progress"
16
58
  className={cn(
@@ -22,15 +64,64 @@ function Progress({
22
64
  "relative h-2 w-full overflow-hidden rounded-full bg-primary/30 dark:bg-primary/60",
23
65
  className
24
66
  )}
67
+ // max / getValueLabel always reach Radix (they rode {...props} before
68
+ // this prop existed — keeps the bare path byte-identical). The bare
69
+ // path also keeps its historical quirk of NOT forwarding value; on the
70
+ // labeled path value is forwarded so Radix emits aria-valuenow +
71
+ // aria-valuetext, and the label becomes the accessible name unless the
72
+ // consumer set one explicitly.
73
+ max={max}
74
+ getValueLabel={getValueLabel}
75
+ {...(hasHeader
76
+ ? {
77
+ value,
78
+ ...(showLabel &&
79
+ !("aria-label" in props) &&
80
+ !("aria-labelledby" in props)
81
+ ? { "aria-labelledby": labelId }
82
+ : null),
83
+ }
84
+ : null)}
25
85
  {...props}
26
86
  >
27
87
  <ProgressPrimitive.Indicator
28
88
  data-slot="progress-indicator"
29
- className="h-full w-full flex-1 bg-primary transition-all"
30
- style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
89
+ className="h-full w-full flex-1 bg-primary transition-transform"
90
+ style={{ transform: `translateX(-${100 - fillPercent}%)` }}
31
91
  />
32
92
  </ProgressPrimitive.Root>
33
93
  )
94
+
95
+ if (!hasHeader) return track
96
+
97
+ return (
98
+ <div data-slot="progress-wrapper" className="flex w-full flex-col gap-2">
99
+ <div className="flex items-center justify-between gap-3">
100
+ {showLabel ? (
101
+ <span
102
+ id={labelId}
103
+ data-slot="progress-label"
104
+ className="min-w-0 truncate text-sm font-medium text-foreground"
105
+ >
106
+ {label}
107
+ </span>
108
+ ) : null}
109
+ {showValueText ? (
110
+ // aria-hidden: the identical string is already announced through
111
+ // the progressbar's aria-valuetext — visible-only here avoids the
112
+ // double announcement.
113
+ <span
114
+ aria-hidden="true"
115
+ data-slot="progress-value"
116
+ className="ml-auto shrink-0 text-sm text-muted-foreground tabular-nums"
117
+ >
118
+ {(getValueLabel ?? defaultGetValueLabel)(value as number, resolvedMax)}
119
+ </span>
120
+ ) : null}
121
+ </div>
122
+ {track}
123
+ </div>
124
+ )
34
125
  }
35
126
 
36
127
  export { Progress }
@@ -103,6 +103,7 @@ function RatingGroup({
103
103
  ? "cursor-not-allowed opacity-40"
104
104
  : readOnly
105
105
  ? "cursor-default"
106
+ // allow-slop:BADS-SLOP-3 the star you're about to pick grows to preview the selection — the scale IS the affordance here, not a decorative card pop
106
107
  : "cursor-pointer hover:scale-110",
107
108
  isFilled ? "text-primary" : "text-muted-foreground/40"
108
109
  )}
@@ -5,12 +5,68 @@ import * as SeparatorPrimitive from "@radix-ui/react-separator"
5
5
 
6
6
  import { cn } from "../../lib/utils"
7
7
 
8
+ type SeparatorProps = React.ComponentProps<typeof SeparatorPrimitive.Root> & {
9
+ /**
10
+ * Optional label rendered inline, splitting the rule into two segments (an
11
+ * "OR" divider, a section title). Horizontal only — ignored when
12
+ * orientation is vertical. When set, the rule segments are aria-hidden and
13
+ * the label carries the separator's accessible name.
14
+ */
15
+ label?: React.ReactNode
16
+ /** Where the label sits along the rule. Defaults to center. */
17
+ labelPosition?: "start" | "center" | "end"
18
+ }
19
+
8
20
  function Separator({
9
21
  className,
10
22
  orientation = "horizontal",
11
23
  decorative = true,
24
+ label,
25
+ labelPosition = "center",
12
26
  ...props
13
- }: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
27
+ }: SeparatorProps) {
28
+ if (label != null && label !== false && orientation === "horizontal") {
29
+ return (
30
+ <div
31
+ data-slot="separator"
32
+ data-label-position={labelPosition}
33
+ role="separator"
34
+ aria-orientation="horizontal"
35
+ className={cn(
36
+ "flex items-center gap-3 overflow-hidden text-sm text-muted-foreground",
37
+ className
38
+ )}
39
+ {...(props as React.ComponentProps<"div">)}
40
+ >
41
+ <span
42
+ aria-hidden="true"
43
+ className={cn(
44
+ "h-px shrink-0 bg-border",
45
+ labelPosition === "start" ? "w-6" : "flex-1"
46
+ )}
47
+ />
48
+ {/* min-w-0 + truncate so a long / non-Latin label clips with an
49
+ ellipsis instead of overflowing the rule (corrections #001). CSS
50
+ truncation is visual only — the full string stays in the DOM, so
51
+ the separator's accessible name is still the complete label; title
52
+ recovers it on hover. */}
53
+ <span
54
+ className="min-w-0 truncate"
55
+ title={typeof label === "string" ? label : undefined}
56
+ >
57
+ {label}
58
+ </span>
59
+ <span
60
+ aria-hidden="true"
61
+ className={cn(
62
+ "h-px shrink-0 bg-border",
63
+ labelPosition === "end" ? "w-6" : "flex-1"
64
+ )}
65
+ />
66
+ </div>
67
+ )
68
+ }
69
+
14
70
  return (
15
71
  <SeparatorPrimitive.Root
16
72
  data-slot="separator"
@@ -282,7 +282,7 @@ const SidebarRail = React.forwardRef<HTMLButtonElement, React.ComponentProps<"bu
282
282
  onClick={toggleSidebar}
283
283
  title="Toggle Sidebar"
284
284
  className={cn(
285
- "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
285
+ "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-colors ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
286
286
  "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
287
287
  "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
288
288
  "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",