@behavioral-agentic-design-system/core 0.29.0 → 0.32.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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +2 -1
  3. package/scripts/build-tokens.cjs +59 -10
  4. package/scripts/wcag-audit.cjs +30 -4
  5. package/src/app/preview/components/page.tsx +305 -1
  6. package/src/app/preview/health/page.tsx +201 -0
  7. package/src/app/shell.tsx +40 -4
  8. package/src/components/docs-tab.tsx +26 -9
  9. package/src/components/home-tab.tsx +12 -3
  10. package/src/components/ui/badge.tsx +16 -2
  11. package/src/components/ui/button.tsx +10 -0
  12. package/src/components/ui/checkbox.tsx +21 -6
  13. package/src/components/ui/index.ts +1 -0
  14. package/src/components/ui/input-clear-button.tsx +52 -0
  15. package/src/components/ui/input.tsx +5 -21
  16. package/src/components/ui/multi-select.tsx +20 -6
  17. package/src/components/ui/progress.tsx +23 -1
  18. package/src/components/ui/questionnaire.tsx +352 -0
  19. package/src/components/ui/sidebar.tsx +5 -0
  20. package/src/components/ui/skeleton.tsx +83 -1
  21. package/src/components/ui/tabs.tsx +34 -0
  22. package/src/components/ui/textarea.tsx +5 -0
  23. package/src/components/ui/toggle-tip.tsx +125 -0
  24. package/src/data/docs-index.ts +51 -3
  25. package/src/fonts-cdn.css +25 -0
  26. package/src/lib/fork.ts +21 -0
  27. package/src/lib/get-icon-color.ts +66 -0
  28. package/src/stories/Badge.stories.tsx +66 -0
  29. package/src/stories/Button.stories.tsx +3 -0
  30. package/src/stories/Checkbox.stories.tsx +58 -4
  31. package/src/stories/Input.stories.tsx +3 -0
  32. package/src/stories/InputClearButton.stories.tsx +53 -0
  33. package/src/stories/MultiSelect.stories.tsx +6 -2
  34. package/src/stories/Progress.stories.tsx +56 -4
  35. package/src/stories/Questionnaire.stories.tsx +287 -0
  36. package/src/stories/Sidebar.stories.tsx +2 -0
  37. package/src/stories/SkeletonTable.stories.tsx +97 -0
  38. package/src/stories/Stack.stories.tsx +2 -1
  39. package/src/stories/Tabs.stories.tsx +56 -8
  40. package/src/stories/Textarea.stories.tsx +2 -0
  41. package/src/stories/ToggleTip.stories.tsx +106 -0
  42. package/src/styles.css +22 -10
@@ -16,6 +16,19 @@ export type DocGroup = {
16
16
  label: string;
17
17
  description: string;
18
18
  entries: DocEntry[];
19
+ /**
20
+ * Set on groups that only make sense while a repo is still the unbranded
21
+ * upstream template. `visibleDocGroups()` drops them once the repo is a
22
+ * renamed client fork, so a fork's Docs tab stops telling its own staff to
23
+ * onboard a design system that was onboarded months ago.
24
+ *
25
+ * The files stay on disk either way — this only controls what the tab
26
+ * SURFACES, so links to them from other docs keep resolving. If an entry in
27
+ * a retiring group is genuinely load-bearing for every fork (Chromatic's two
28
+ * docs are the example: Chromatic gates every fork's PRs), it belongs in a
29
+ * permanent group instead, not here.
30
+ */
31
+ retireAfterRename?: boolean;
19
32
  };
20
33
 
21
34
  export const DOCS_INDEX: DocGroup[] = [
@@ -112,6 +125,8 @@ export const DOCS_INDEX: DocGroup[] = [
112
125
  entries: [
113
126
  { title: "Design rules", path: "DESIGN.md", summary: "Visual system + accessibility baseline." },
114
127
  { title: "Release-please evaluation", path: "docs/release-please-evaluation.md", summary: "Decision record: release-please vs changesets. Recommendation — stay on changesets (BADS ships one package; human-authored changelogs fit the intentional-output ethos), revisit release-please when BADS goes multi-package or Night Shift's auto-merge cadence outpaces manual changeset authoring. Item 12 from the web-common spec." },
128
+ { title: "Oxlint + anti-slop evaluation", path: "docs/oxlint-anti-slop-evaluation.md", summary: "Spike (paused): dmmulroy/anti-slop TS rules + oxlint adoption (web-common Item 3). Finding — BADS's TypeScript is already clean of the low-signal patterns; the cheap win is oxlint's baseline (72 mostly-autofixable warnings), not the anti-slop pack. Recommended split: baseline + web-common React/cn rules + a few zero-cost ratchet rules; skip the high-backlog ones." },
129
+ { title: "StyleX evaluation", path: "docs/stylex-evaluation.md", summary: "Scouting note (not adopted): Meta's compile-time atomic CSS-in-JS. Verdict — a replacement for BADS's Tailwind-v4 foundation, not an addition; rewriting it would invalidate the className-scanning lint suite that is BADS's value. Worth remembering only for a green-field v2 'creative OS' layer, for its deterministic cross-boundary token merge." },
115
130
  { title: "Token migration", path: "docs/token-migration.md", summary: "The pattern for renaming/restructuring tokens in a fork without a heroic all-at-once PR: a token-migration.json old→new mapping enforced diff-aware (changed files held to new names, legacy tolerated in untouched files) via pnpm check:token-migration, plus a copy-pasteable mapping table. Adapted from web-common." },
116
131
  { title: "Chart color palette", path: "docs/chart-color-palette.md", summary: "Accessible 5-color categorical palette for data viz — Okabe-Ito-derived, reviewed against WCAG 1.4.11 non-text contrast." },
117
132
  { title: "Chart design", path: "docs/chart-design.md", summary: "Chart composition rules — grid, axes, labels, legend, tooltip, number formatting, states, motion. The 'data is the only saturated thing' register; companion to the color palette." },
@@ -122,10 +137,17 @@ export const DOCS_INDEX: DocGroup[] = [
122
137
  { title: "Anti-defaults refresh", path: "prompts/anti-defaults-refresh.md", summary: "Quarterly pressure-test of the current anti-defaults." },
123
138
  { title: "Promote corrections", path: "prompts/promote-corrections.md", summary: "Monthly: corrections → lint promotion candidates." },
124
139
  { title: "Recipe miner", path: "prompts/recipe-miner.md", summary: "Monthly: ship-first vs bounce-recipe ranking." },
140
+ { title: "Chromatic setup", path: "docs/chromatic-setup.md", summary: "Wiring the visual-regression gate that runs on every story-relevant PR. Lives here rather than under onboarding because Chromatic gates every fork's PRs for the life of the fork, not just its first week." },
141
+ { title: "Chromatic prompt", path: "prompts/chromatic.md", summary: "AI-guided version of the Chromatic setup walkthrough." },
125
142
  ],
126
143
  },
127
144
  {
128
145
  id: "onboarding",
146
+ // Retires itself once the repo is a renamed fork — see `retireAfterRename`
147
+ // on DocGroup. Every entry below is a one-time, pre-branding step; a fork
148
+ // that has already been branded has no use for any of them, and surfacing
149
+ // them tells its staff to re-run onboarding on their own live system.
150
+ retireAfterRename: true,
129
151
  label: "Client onboarding",
130
152
  description: "The flow that takes BADS from upstream template to a named client engagement.",
131
153
  entries: [
@@ -139,7 +161,6 @@ export const DOCS_INDEX: DocGroup[] = [
139
161
  { title: "4 · Tokens", path: "prompts/4-tokens.md" },
140
162
  { title: "5 · Component needs", path: "prompts/5-component-needs.md" },
141
163
  { title: "6 · Patterns", path: "prompts/6-patterns.md" },
142
- { title: "Chromatic setup", path: "docs/chromatic-setup.md" },
143
164
  {
144
165
  title: "Handoff runbook",
145
166
  path: "docs/handoff-runbook.md",
@@ -152,7 +173,6 @@ export const DOCS_INDEX: DocGroup[] = [
152
173
  summary:
153
174
  "workspace:* to npm-consume — the migration every client fork runs so daily component releases actually arrive.",
154
175
  },
155
- { title: "Chromatic prompt", path: "prompts/chromatic.md" },
156
176
  ],
157
177
  },
158
178
  {
@@ -187,11 +207,39 @@ export const DOCS_INDEX: DocGroup[] = [
187
207
  { title: "Roadmap", path: "docs/roadmap.md", summary: "Layer 2/6/8/9/10 deferred work with the signal that should activate each one." },
188
208
  { title: "Plan — skill package", path: "docs/plans/2026-08-21-skill-package.md", summary: "Approved plan: generate a per-fork, npx-installable agent skill — SKILL.md + drift-proof component recipes + token CSS — so the design system's rules travel into the client product repos where components are consumed. Phase A shipped; see the spec." },
189
209
  { title: "Spec — skill package", path: "docs/specs/2026-08-21-skill-package.md", summary: "The durable contract for packages/skill: generated-only output, usage-focused recipes, ≤2k-word SKILL.md, deterministic builds, the check:skill staleness gate, and the eval --context=skill acceptance instrument." },
210
+ { title: "Plan — self-healing layer", path: "docs/plans/2026-08-21-self-healing-layer.md", summary: "Approved plan: the watch-half of the system — drift ledger, token intent validator, component health score, and a Health surface, assembled from signals BADS already owns; runtime telemetry deliberately deferred behind consent + futures-check." },
211
+ { title: "Spec — self-healing layer", path: "docs/specs/2026-08-21-self-healing-layer.md", summary: "Phase A contract: informational-only health score (Goodhart guard), no runtime telemetry, deterministic visible-copy intent rules, drift-ledger status convention, and the calibration record (6→0 false positives; two scoring bugs caught by face-checking)." },
190
212
  ],
191
213
  },
192
214
  ];
193
215
 
216
+ /**
217
+ * Every entry in every group, retiring groups included. Kept as-is so any fork
218
+ * or consumer already importing it still compiles. For "how many docs does this
219
+ * repo actually show", use `docsTotal(visibleDocGroups(IS_CLIENT_FORK))`.
220
+ */
194
221
  export const DOCS_TOTAL = DOCS_INDEX.reduce((sum, g) => sum + g.entries.length, 0);
195
222
 
223
+ /**
224
+ * The groups a given repo should surface.
225
+ *
226
+ * Upstream BADS shows everything — it IS the template, and the onboarding flow
227
+ * is one of the things it ships. A renamed client fork drops the groups marked
228
+ * `retireAfterRename`, because those describe work that already happened.
229
+ *
230
+ * Pass `IS_CLIENT_FORK` from `@…/core/lib/fork`, which is resolved at BUILD
231
+ * time (not from `window`), so the server render and the client hydration agree
232
+ * and the sidebar doesn't flash a group it is about to remove.
233
+ */
234
+ export function visibleDocGroups(isClientFork: boolean): DocGroup[] {
235
+ if (!isClientFork) return DOCS_INDEX;
236
+ return DOCS_INDEX.filter((g) => !g.retireAfterRename);
237
+ }
238
+
239
+ /** Entry count for whichever set of groups you're rendering. */
240
+ export function docsTotal(groups: DocGroup[]): number {
241
+ return groups.reduce((sum, g) => sum + g.entries.length, 0);
242
+ }
243
+
196
244
  // linters, checks, audits, reports, and CI workflows — automation scripts in pnpm + .github
197
- export const AUTOMATION_COUNT = 48;
245
+ export const AUTOMATION_COUNT = 49;
@@ -0,0 +1,25 @@
1
+ /* GENERATED FROM tokens.json — DO NOT EDIT BY HAND.
2
+ * Run `pnpm build:tokens` after changing tokens.json. */
3
+
4
+ /* @behavioral-agentic-design-system/core — Google Fonts CDN faces (opt-in).
5
+ *
6
+ * Import this FIRST in your global stylesheet, ahead of Tailwind:
7
+ * @import "@behavioral-agentic-design-system/core/fonts-cdn.css";
8
+ * @import "tailwindcss";
9
+ * @import "tw-animate-css";
10
+ * @import "@behavioral-agentic-design-system/core/styles.css";
11
+ *
12
+ * Remote @import statements are legal only before any rule, and Tailwind
13
+ * expands into rules — so these cannot live in styles.css, which is imported
14
+ * after it. Skip this file entirely if the app already loads Inter and
15
+ * Atkinson Hyperlegible itself (next/font, or self-hosted woff2 copied out of
16
+ * this package's fonts/ directory); the CDN is the zero-setup fallback, and
17
+ * the local @font-face rules in fonts.css win over it either way.
18
+ *
19
+ * Inter Variable leads as the default sans; Atkinson Hyperlegible stays as
20
+ * the accessibility-preserving secondary.
21
+ *
22
+ * This file must contain NO rules of its own — a single rule here would make
23
+ * the @import statements below invalid for anyone importing it. */
24
+ @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
25
+ @import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Is this repo a renamed client fork, or is it still the upstream template?
3
+ *
4
+ * `scripts/rename.mjs` writes `.client-identity.json` at the repo root when it
5
+ * brands a fork, and that file's existence is the canonical answer. But the
6
+ * question gets asked from client components (the Docs and Home tabs), which
7
+ * cannot read the filesystem — and reading it from `window` would answer
8
+ * `false` during the server render and `true` after hydration, so React would
9
+ * render the template shape first and then rip a group out of the sidebar.
10
+ *
11
+ * So it is resolved at BUILD time instead: `next.config.js` checks for the file
12
+ * and inlines the result as `NEXT_PUBLIC_BADS_IS_FORK`. Next substitutes
13
+ * `NEXT_PUBLIC_*` into the server and client bundles identically, so both
14
+ * renders agree and there is no flash.
15
+ *
16
+ * Deliberately NOT derived from `brand.config.ts` (`isUpstreamTemplate`, or
17
+ * `name !== "BADS"`): those are hand-editable content, and a fork that forgets
18
+ * to flip one would silently keep showing template-only docs. The identity file
19
+ * is written by the script, so it cannot drift from the rename itself.
20
+ */
21
+ export const IS_CLIENT_FORK = process.env.NEXT_PUBLIC_BADS_IS_FORK === "1";
@@ -0,0 +1,66 @@
1
+ /**
2
+ * getIconColor — map a semantic icon *role* to the Tailwind class bound to the
3
+ * matching `--icon-*` token. This is the pattern for giving a custom icon set
4
+ * semantic colors instead of leaving everything to `currentColor`
5
+ * (see CLAUDE.md → Icons, and the `icon-*` token family in tokens.json).
6
+ *
7
+ * Adapted from web-common's `get-icon-color.ts`. Their failure mode: passing a
8
+ * token name (`"icon-brand-primary"`) or a raw Tailwind class (`"text-brand-…"`)
9
+ * instead of a semantic role falls through the map and renders the icon
10
+ * UNSTYLED — three call sites did exactly that and nothing caught it. Two guards
11
+ * here close that gap:
12
+ * 1. The input is the typed `IconRole` union, so a wrong string literal fails
13
+ * to type-check at compile time (better than a runtime fallthrough).
14
+ * 2. `pnpm lint:icon-color` catches the any-typed / prop-forwarded call sites a
15
+ * fork might add where the type can't see the value.
16
+ */
17
+ export const ICON_ROLES = [
18
+ "default",
19
+ "muted",
20
+ "primary",
21
+ "success",
22
+ "warning",
23
+ "error",
24
+ "info",
25
+ "inverse",
26
+ "disabled",
27
+ ] as const;
28
+
29
+ export type IconRole = (typeof ICON_ROLES)[number];
30
+
31
+ const ICON_COLOR_CLASS: Record<IconRole, string> = {
32
+ default: "text-icon-default",
33
+ muted: "text-icon-muted",
34
+ primary: "text-icon-primary",
35
+ success: "text-icon-success",
36
+ warning: "text-icon-warning",
37
+ error: "text-icon-error",
38
+ info: "text-icon-info",
39
+ inverse: "text-icon-inverse",
40
+ disabled: "text-icon-disabled",
41
+ };
42
+
43
+ /** Runtime guard for the any-typed boundary (a prop from JSON, a CMS field, etc.). */
44
+ export function isIconRole(value: unknown): value is IconRole {
45
+ return typeof value === "string" && (ICON_ROLES as readonly string[]).includes(value);
46
+ }
47
+
48
+ /**
49
+ * Returns the `text-icon-*` class for a semantic role. Pass a ROLE (`"error"`),
50
+ * never a token name (`"icon-error"`) or a class (`"text-icon-error"`). An
51
+ * unrecognized value logs a dev warning and falls back to `"default"` so the
52
+ * icon is never rendered invisibly; in production it falls back silently.
53
+ */
54
+ export function getIconColor(role: IconRole): string {
55
+ const cls = ICON_COLOR_CLASS[role];
56
+ if (!cls) {
57
+ if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
58
+ // eslint-disable-next-line no-console
59
+ console.warn(
60
+ `getIconColor: "${String(role)}" is not an icon role. Pass one of: ${ICON_ROLES.join(", ")}. Falling back to "default".`,
61
+ );
62
+ }
63
+ return ICON_COLOR_CLASS.default;
64
+ }
65
+ return cls;
66
+ }
@@ -10,12 +10,19 @@ import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badg
10
10
  * semantic color, while the label stays text-foreground so it holds the
11
11
  * AAA 7:1 floor. Pair status badges with an icon or distinct label — never
12
12
  * color alone.
13
+ *
14
+ * Size ladder (peer parity: Mantine size, MUI Chip size, Chakra size):
15
+ * sm = dense inline labels, default = unchanged, lg = prominent surfaces.
16
+ * BADS text-xs = 14px and text-sm = 16px — both meet the AAA 14px floor.
13
17
  */
14
18
  const meta: Meta<typeof Badge> = {
15
19
  title: "Components/Badge",
16
20
  component: Badge,
17
21
  parameters: { layout: "centered" },
18
22
  tags: ["autodocs"],
23
+ argTypes: {
24
+ size: { control: "select", options: ["sm", "default", "lg"] },
25
+ },
19
26
  };
20
27
 
21
28
  export default meta;
@@ -81,6 +88,65 @@ export const Variant_Info: Story = {
81
88
  ),
82
89
  };
83
90
 
91
+ /**
92
+ * Size ladder — sm for dense inline labels, lg for prominent status callouts.
93
+ * All sizes use text-xs (14px) or text-sm (16px) — never below the 14px floor.
94
+ */
95
+ export const Size_Sm: Story = {
96
+ render: () => (
97
+ <div className="flex items-center gap-2">
98
+ <Badge size="sm">v2.4.1</Badge>
99
+ <Badge size="sm" variant="success">
100
+ <CircleCheck strokeWidth={1.5} aria-hidden />
101
+ Passing
102
+ </Badge>
103
+ </div>
104
+ ),
105
+ };
106
+
107
+ export const Size_Lg: Story = {
108
+ render: () => (
109
+ <div className="flex items-center gap-2">
110
+ <Badge size="lg">Beta</Badge>
111
+ <Badge size="lg" variant="warning">
112
+ <TriangleAlert strokeWidth={1.5} aria-hidden />
113
+ Degraded
114
+ </Badge>
115
+ </div>
116
+ ),
117
+ };
118
+
119
+ export const Sizes: Story = {
120
+ render: () => (
121
+ <div className="space-y-3">
122
+ <div className="flex items-center gap-2">
123
+ <Badge size="sm">sm</Badge>
124
+ <Badge size="sm" variant="secondary">Secondary</Badge>
125
+ <Badge size="sm" variant="success">
126
+ <CircleCheck strokeWidth={1.5} aria-hidden />
127
+ Passing
128
+ </Badge>
129
+ </div>
130
+ <div className="flex items-center gap-2">
131
+ <Badge>default</Badge>
132
+ <Badge variant="secondary">Secondary</Badge>
133
+ <Badge variant="success">
134
+ <CircleCheck strokeWidth={1.5} aria-hidden />
135
+ Passing
136
+ </Badge>
137
+ </div>
138
+ <div className="flex items-center gap-2">
139
+ <Badge size="lg">lg</Badge>
140
+ <Badge size="lg" variant="secondary">Secondary</Badge>
141
+ <Badge size="lg" variant="success">
142
+ <CircleCheck strokeWidth={1.5} aria-hidden />
143
+ Passing
144
+ </Badge>
145
+ </div>
146
+ </div>
147
+ ),
148
+ };
149
+
84
150
  export const RealisticUse: Story = {
85
151
  render: () => (
86
152
  <div className="flex max-w-md flex-col gap-3">
@@ -1,3 +1,6 @@
1
+ // Button is a client component: it always attaches its own onClick/onKeyDown to
2
+ // guard the aria-disabled pattern, so it cannot be rendered from a React Server
3
+ // Component. See the note at the top of components/ui/button.tsx.
1
4
  // Motion: base transition narrowed transition-all → transition-colors (Vercel/Rauno "list only the properties you animate" + BADS microanimation rule). Focus ring now appears instantly rather than fading — strictly better for a11y.
2
5
  import { Meta, StoryObj } from "@storybook/react"
3
6
  import { userEvent, within, expect, fn } from "storybook/test"
@@ -1,3 +1,5 @@
1
+ // size prop added 2026-08-23: sm=24px visible box, default=32px (unchanged).
2
+ // Hit area stays 44px via before:size-11 in both sizes (WCAG 2.2 SC 2.5.5 AAA).
1
3
  import type { Meta, StoryObj } from "@storybook/react";
2
4
  import { Checkbox } from "@behavioral-agentic-design-system/core/components/ui/checkbox";
3
5
  import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
@@ -7,6 +9,9 @@ const meta: Meta<typeof Checkbox> = {
7
9
  component: Checkbox,
8
10
  parameters: { layout: "centered" },
9
11
  tags: ["autodocs"],
12
+ argTypes: {
13
+ size: { control: "select", options: ["sm", "default"] },
14
+ },
10
15
  };
11
16
 
12
17
  export default meta;
@@ -41,10 +46,59 @@ export const Disabled: Story = {
41
46
  args: { disabled: true, "aria-label": "I agree to the terms" } as any,
42
47
  };
43
48
 
49
+ /**
50
+ * Size ladder (peer parity: Mantine size, MUI size, Chakra size).
51
+ * sm = 24px visible box — fits dense tables and list rows.
52
+ * default = 32px visible box — unchanged.
53
+ * Hit area is 44px in both sizes (WCAG 2.2 SC 2.5.5 AAA pointer target).
54
+ */
55
+ export const Size_Sm: Story = {
56
+ render: () => (
57
+ <div className="flex items-center gap-2">
58
+ <Checkbox id="size-sm" size="sm" defaultChecked />
59
+ <Label htmlFor="size-sm">Compact checkbox</Label>
60
+ </div>
61
+ ),
62
+ };
63
+
64
+ export const Sizes: Story = {
65
+ render: () => (
66
+ <div className="space-y-3">
67
+ <div className="flex items-center gap-2">
68
+ <Checkbox id="sz-sm" size="sm" defaultChecked />
69
+ <Label htmlFor="sz-sm">Small (24px)</Label>
70
+ </div>
71
+ <div className="flex items-center gap-2">
72
+ <Checkbox id="sz-default" defaultChecked />
73
+ <Label htmlFor="sz-default">Default (32px)</Label>
74
+ </div>
75
+ </div>
76
+ ),
77
+ };
78
+
44
79
  export const RealisticUse: Story = {
45
- render: () => (<div className="flex items-center gap-2">
46
- <Checkbox id="terms-realistic" defaultChecked />
47
- <Label htmlFor="terms-realistic">I agree to the terms</Label>
48
- </div>),
80
+ render: () => (
81
+ <div className="space-y-4">
82
+ <div className="flex items-center gap-2">
83
+ <Checkbox id="terms-realistic" defaultChecked />
84
+ <Label htmlFor="terms-realistic">I agree to the terms</Label>
85
+ </div>
86
+ <div className="space-y-2">
87
+ <p className="text-sm font-medium text-foreground">Notification preferences</p>
88
+ <div className="flex items-center gap-2">
89
+ <Checkbox id="notif-email" size="sm" defaultChecked />
90
+ <Label htmlFor="notif-email">Email updates</Label>
91
+ </div>
92
+ <div className="flex items-center gap-2">
93
+ <Checkbox id="notif-slack" size="sm" />
94
+ <Label htmlFor="notif-slack">Slack notifications</Label>
95
+ </div>
96
+ <div className="flex items-center gap-2">
97
+ <Checkbox id="notif-all" size="sm" checked="indeterminate" />
98
+ <Label htmlFor="notif-all">Select all</Label>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ ),
49
103
  };
50
104
 
@@ -1,3 +1,6 @@
1
+ // Input itself is server-renderable: it attaches no handler of its own and only
2
+ // forwards the caller's onChange. The clear affordance is the client half, split
3
+ // into components/ui/input-clear-button.tsx — see the Clearable stories below.
1
4
  import * as React from "react";
2
5
  import { Meta, StoryObj } from "@storybook/react";
3
6
  import { CalendarIcon, MailIcon, SearchIcon } from "lucide-react";
@@ -0,0 +1,53 @@
1
+ // The client half of Input's clearable affordance. It lives in its own module so
2
+ // that a plain <Input /> stays renderable from a React Server Component and
3
+ // costs a consumer nothing on the client — only <Input clearable /> pulls this
4
+ // in. Storied separately so visual regression covers the button on its own,
5
+ // including the offset variant used when Input also has a rightSection.
6
+ import type { Meta, StoryObj } from "@storybook/react";
7
+ import { InputClearButton } from "@behavioral-agentic-design-system/core/components/ui/input-clear-button";
8
+ import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";
9
+ import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
10
+
11
+ const meta: Meta<typeof InputClearButton> = {
12
+ title: "Components/InputClearButton",
13
+ component: InputClearButton,
14
+ parameters: { layout: "centered" },
15
+ tags: ["autodocs"],
16
+ };
17
+
18
+ export default meta;
19
+ type Story = StoryObj<typeof meta>;
20
+
21
+ export const Default: Story = {
22
+ render: () => (
23
+ // Positioned absolutely against its input, so it needs a relative box to
24
+ // sit in even when shown in isolation.
25
+ <div className="relative h-9 w-[240px] rounded-md border border-input">
26
+ <InputClearButton className="right-1.5" />
27
+ </div>
28
+ ),
29
+ };
30
+
31
+ export const OffsetForRightSection: Story = {
32
+ name: "Offset (input has a rightSection)",
33
+ render: () => (
34
+ <div className="relative h-9 w-[240px] rounded-md border border-input">
35
+ <InputClearButton className="right-8" />
36
+ <span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3 text-sm text-muted-foreground">
37
+ USD
38
+ </span>
39
+ </div>
40
+ ),
41
+ };
42
+
43
+ export const RealisticUse: Story = {
44
+ render: () => (
45
+ <div className="flex w-[320px] flex-col gap-3">
46
+ <Label htmlFor="search-city">Search by city</Label>
47
+ <Input id="search-city" clearable value="Nashville, TN" readOnly />
48
+ <p className="text-sm text-muted-foreground">
49
+ The clear button appears once the field has a value.
50
+ </p>
51
+ </div>
52
+ ),
53
+ };
@@ -25,8 +25,12 @@ const meta: Meta<typeof MultiSelect> = {
25
25
  // <button> (valid per ARIA). X-remove pill buttons live in a sibling z-10 span —
26
26
  // not nested inside the trigger button — so axe nested-interactive never fires.
27
27
  // When disabled=true the X buttons are not rendered (disabled form controls must
28
- // not contain interactive elements that are still reachable).
29
- component: "Multi-value combobox. Transparent full-area trigger <button> ensures aria-expanded is ARIA-valid; pill X-remove buttons are siblings (not nested) so no axe nested-interactive violation. Pill badges use py-0 min-h-6 so the content area is exactly 24px; X buttons use h-6 w-6 to meet the 24×24 WCAG 2.2 SC 2.5.8 target-size minimum (self-stretch would only fill the inner content-box, which is 20px when py-0.5 is present). When disabled, X-remove buttons are hidden — a disabled field cannot have interactive children.",
28
+ // not contain interactive elements that are still reachable). The container gets
29
+ // aria-disabled="true" so axe exempts its children from contrast checks (WCAG
30
+ // 1.4.3 inactive UI component exception). The trigger is NOT wrapped in
31
+ // PopoverTrigger when disabled — this prevents Radix from adding aria-controls
32
+ // pointing to an unmounted PopoverContent (axe aria-valid-attr-value).
33
+ component: "Multi-value combobox. Transparent full-area trigger <button> ensures aria-expanded is ARIA-valid; pill X-remove buttons are siblings (not nested) so no axe nested-interactive violation. Pill badges use py-0 min-h-6 so the content area is exactly 24px; X buttons use h-6 w-6 to meet the 24×24 WCAG 2.2 SC 2.5.8 target-size minimum (self-stretch would only fill the inner content-box, which is 20px when py-0.5 is present). When disabled, X-remove buttons are hidden and the trigger skips PopoverTrigger so Radix does not add aria-controls to a non-existent popover element.",
30
34
  },
31
35
  },
32
36
  },
@@ -123,12 +123,66 @@ export const Sizes: Story = {
123
123
  ),
124
124
  };
125
125
 
126
+ /**
127
+ * Semantic color intent (peer parity: Mantine Progress `color`, MUI
128
+ * LinearProgress `color`, Chakra `colorScheme`, Ant Design `status`). Only
129
+ * the indicator fill changes — the track stays primary-tinted. Intent is
130
+ * visual only; always pair with a label or aria-label naming the state.
131
+ */
132
+ export const Intent_Success: Story = {
133
+ args: { value: 100, intent: "success", label: "Deployment complete", showValue: true },
134
+ render: (args) => (
135
+ <div className="w-72">
136
+ <Progress {...args} />
137
+ </div>
138
+ ),
139
+ };
140
+
141
+ export const Intent_Warning: Story = {
142
+ args: { value: 78, intent: "warning", label: "Disk quota: 78% used", showValue: true },
143
+ render: (args) => (
144
+ <div className="w-72">
145
+ <Progress {...args} />
146
+ </div>
147
+ ),
148
+ };
149
+
150
+ export const Intent_Error: Story = {
151
+ args: { value: 100, intent: "error", label: "Build failed", showValue: true },
152
+ render: (args) => (
153
+ <div className="w-72">
154
+ <Progress {...args} />
155
+ </div>
156
+ ),
157
+ };
158
+
159
+ export const Intent_Info: Story = {
160
+ args: { value: 42, intent: "info", label: "Syncing design tokens", showValue: true },
161
+ render: (args) => (
162
+ <div className="w-72">
163
+ <Progress {...args} />
164
+ </div>
165
+ ),
166
+ };
167
+
168
+ export const Intents: Story = {
169
+ render: () => (
170
+ <div className="w-72 space-y-4">
171
+ <Progress value={60} intent="default" aria-label="Default progress" />
172
+ <Progress value={100} intent="success" label="Deployment complete" showValue />
173
+ <Progress value={78} intent="warning" label="Disk quota: 78% used" showValue />
174
+ <Progress value={100} intent="error" label="Build failed" showValue />
175
+ <Progress value={42} intent="info" label="Syncing design tokens" showValue />
176
+ </div>
177
+ ),
178
+ };
179
+
126
180
  export const RealisticUse: Story = {
127
181
  render: () => (
128
182
  <div className="w-72 space-y-6">
129
183
  <Progress value={28} label="Uploading brand-fonts.woff2" showValue />
130
184
  <Progress value={72} label="Processing tokens" showValue />
131
- <Progress value={100} label="Storybook coverage" showValue />
185
+ <Progress value={100} intent="success" label="Storybook coverage" showValue />
132
186
  <Progress
133
187
  value={14}
134
188
  max={36}
@@ -136,9 +190,7 @@ export const RealisticUse: Story = {
136
190
  showValue
137
191
  getValueLabel={(value, max) => `${value} of ${max}`}
138
192
  />
139
- {/* sm reads as quiet inline progress in dense rows; lg carries an
140
- upload panel. */}
141
- <Progress value={64} size="sm" aria-label="Background sync" />
193
+ <Progress value={78} intent="warning" size="sm" aria-label="Storage: 78% used" />
142
194
  <Progress value={38} size="lg" label="Uploading brand assets" showValue />
143
195
  </div>
144
196
  ),