@behavioral-agentic-design-system/core 0.39.1 → 0.40.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 (69) hide show
  1. package/package.json +8 -3
  2. package/scripts/a11y-lint.cjs +47 -6
  3. package/scripts/bads-components.mjs +118 -0
  4. package/scripts/build-tokens.cjs +133 -12
  5. package/scripts/check-stories.mjs +1 -1
  6. package/scripts/lint-component-source.mjs +100 -0
  7. package/scripts/lint-microanimation.mjs +267 -0
  8. package/scripts/size-audit.cjs +79 -0
  9. package/scripts/source-of-truth.cjs +58 -0
  10. package/scripts/ux-smoke.mjs +438 -0
  11. package/scripts/wcag-audit.cjs +49 -1
  12. package/src/api/layers/file.ts +1 -0
  13. package/src/app/preview/components/page.tsx +968 -0
  14. package/src/app/shell.tsx +11 -13
  15. package/src/components/customize/brand-mark-section.tsx +4 -2
  16. package/src/components/customize/design-controls.tsx +1 -1
  17. package/src/components/customize/discipline-section.tsx +3 -6
  18. package/src/components/customize/font-pickers.tsx +1 -1
  19. package/src/components/customize/letter-spacing.tsx +1 -1
  20. package/src/components/customize/save-bar.tsx +2 -2
  21. package/src/components/customize/theme-io.tsx +7 -7
  22. package/src/components/customize/type-scale.tsx +1 -1
  23. package/src/components/customize-tab.tsx +7 -4
  24. package/src/components/home-tab.tsx +3 -0
  25. package/src/components/ui/accordion.tsx +7 -0
  26. package/src/components/ui/alert.tsx +1 -0
  27. package/src/components/ui/announcement-bar.tsx +256 -0
  28. package/src/components/ui/badge.tsx +1 -0
  29. package/src/components/ui/callout.tsx +218 -0
  30. package/src/components/ui/chart.tsx +2 -14
  31. package/src/components/ui/color-picker.tsx +1 -1
  32. package/src/components/ui/format-relative-time.tsx +139 -0
  33. package/src/components/ui/grid.tsx +255 -0
  34. package/src/components/ui/icon.tsx +108 -0
  35. package/src/components/ui/index.ts +8 -0
  36. package/src/components/ui/page-header.tsx +63 -0
  37. package/src/components/ui/portal.tsx +111 -0
  38. package/src/components/ui/presence.tsx +172 -0
  39. package/src/components/ui/progress-stack.tsx +258 -0
  40. package/src/components/ui/select.tsx +89 -4
  41. package/src/components/ui/separator.tsx +1 -0
  42. package/src/components/ui/slider.tsx +83 -3
  43. package/src/components/ui/sparkline.tsx +2 -14
  44. package/src/components/ui/textarea.tsx +28 -1
  45. package/src/data/docs-index.ts +1 -0
  46. package/src/hooks/use-reduced-motion.ts +6 -0
  47. package/src/stories/Accordion.stories.tsx +59 -0
  48. package/src/stories/Alert.stories.tsx +3 -1
  49. package/src/stories/AnnouncementBar.stories.tsx +261 -0
  50. package/src/stories/Badge.stories.tsx +3 -0
  51. package/src/stories/Calendar.stories.tsx +1 -1
  52. package/src/stories/Callout.stories.tsx +219 -0
  53. package/src/stories/Chart.stories.tsx +4 -0
  54. package/src/stories/ColorPicker.stories.tsx +23 -0
  55. package/src/stories/FormatRelativeTime.stories.tsx +116 -0
  56. package/src/stories/Grid.stories.tsx +197 -0
  57. package/src/stories/Icon.stories.tsx +175 -0
  58. package/src/stories/MultiSelect.stories.tsx +1 -1
  59. package/src/stories/PageHeader.stories.tsx +102 -0
  60. package/src/stories/Portal.stories.tsx +189 -0
  61. package/src/stories/Presence.stories.tsx +228 -0
  62. package/src/stories/ProgressStack.stories.tsx +287 -0
  63. package/src/stories/Select.stories.tsx +25 -0
  64. package/src/stories/Separator.stories.tsx +3 -0
  65. package/src/stories/Slider.stories.tsx +54 -5
  66. package/src/stories/Sparkline.stories.tsx +3 -0
  67. package/src/stories/Textarea.stories.tsx +18 -0
  68. package/src/stories/story-groups.json +14 -5
  69. package/src/styles.css +133 -12
@@ -4,6 +4,7 @@
4
4
  // the portal. See components/Sheet.stories.tsx → WithPortalTheme for the\
5
5
  // canonical demonstration. Mechanism is identical here; no separate\
6
6
  // story added because the demo would duplicate Sheet's.
7
+ import * as React from "react";
7
8
  import type { Meta, StoryObj } from "@storybook/react";
8
9
  import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@behavioral-agentic-design-system/core/components/ui/select";
9
10
 
@@ -132,3 +133,27 @@ export const RealisticUse: Story = {
132
133
  </SelectContent>
133
134
  </Select>),
134
135
  };
136
+
137
+ export const Clearable: Story = {
138
+ // Controlled story uses React.useState — args panel can't drive it.
139
+ parameters: { controls: { disable: true } },
140
+ render: () => {
141
+ // eslint-disable-next-line react-hooks/rules-of-hooks
142
+ const [value, setValue] = React.useState("apple");
143
+ return (
144
+ <Select value={value} onValueChange={setValue} clearable>
145
+ <SelectTrigger className="w-[220px]" aria-label="Pick a fruit — clearable">
146
+ <SelectValue placeholder="Pick a fruit" />
147
+ </SelectTrigger>
148
+ <SelectContent>
149
+ <SelectGroup>
150
+ <SelectLabel>Fruits</SelectLabel>
151
+ <SelectItem value="apple">Apple</SelectItem>
152
+ <SelectItem value="banana">Banana</SelectItem>
153
+ <SelectItem value="cherry">Cherry</SelectItem>
154
+ </SelectGroup>
155
+ </SelectContent>
156
+ </Select>
157
+ );
158
+ },
159
+ };
@@ -1,6 +1,9 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator";
3
3
 
4
+ // Separator always renders a <div> (see the recipe-note in separator.tsx) —
5
+ // never nest it inside a <p>; that's invalid HTML and throws React hydration
6
+ // error #418 at runtime even though `next build` reports success.
4
7
  const meta: Meta<typeof Separator> = {
5
8
  title: "Components/Layout/Separator",
6
9
  component: Separator,
@@ -66,6 +66,48 @@ export const WithMarks: Story = {
66
66
  ),
67
67
  };
68
68
 
69
+ /**
70
+ * `valueLabel="auto"` shows a thumb-anchored value bubble on hover, focus, and
71
+ * drag (Mantine `label`, MUI `valueLabelDisplay="auto"`, Ant `tooltip`). The
72
+ * bubble is `aria-hidden` — the thumb announces the value — and a string from
73
+ * `valueLabelFormat` is mirrored to `aria-valuetext`. Default `never` keeps
74
+ * the slider byte-identical to before.
75
+ */
76
+ export const WithValueLabel: Story = {
77
+ args: {
78
+ defaultValue: [62],
79
+ min: 0,
80
+ max: 100,
81
+ step: 1,
82
+ "aria-label": "Volume",
83
+ valueLabel: "auto",
84
+ valueLabelFormat: (v: number) => `${v}%`,
85
+ },
86
+ render: (args) => (
87
+ <div className="w-72">
88
+ <Slider {...args} />
89
+ </div>
90
+ ),
91
+ };
92
+
93
+ /** `valueLabel="always"` keeps the bubble persistent and reserves room above the track for it. */
94
+ export const ValueLabelAlways: Story = {
95
+ args: {
96
+ defaultValue: [120, 375],
97
+ min: 0,
98
+ max: 500,
99
+ step: 5,
100
+ "aria-label": "Retainer range",
101
+ valueLabel: "always",
102
+ valueLabelFormat: (v: number) => `$${v}`,
103
+ },
104
+ render: (args) => (
105
+ <div className="w-72">
106
+ <Slider {...args} />
107
+ </div>
108
+ ),
109
+ };
110
+
69
111
  export const RealisticUse: Story = {
70
112
  render: () => (
71
113
  <div className="w-80 space-y-6">
@@ -84,11 +126,18 @@ export const RealisticUse: Story = {
84
126
  <Slider defaultValue={[28]} min={0} max={100} step={1} aria-labelledby="slider-brightness" />
85
127
  </div>
86
128
  <div className="space-y-3">
87
- <div className="flex items-baseline justify-between">
88
- <label className="text-sm font-medium">Range</label>
89
- <span className="text-xs text-muted-foreground tabular-nums">20 — 75</span>
90
- </div>
91
- <Slider defaultValue={[20, 75]} min={0} max={100} step={1} aria-label="Range" />
129
+ <label id="slider-retainer" className="text-sm font-medium">
130
+ Monthly retainer range
131
+ </label>
132
+ <Slider
133
+ defaultValue={[120, 375]}
134
+ min={0}
135
+ max={500}
136
+ step={5}
137
+ aria-labelledby="slider-retainer"
138
+ valueLabel="always"
139
+ valueLabelFormat={(v) => `$${v}`}
140
+ />
92
141
  </div>
93
142
  </div>
94
143
  ),
@@ -39,6 +39,9 @@ const NEGATIVE_DATA = [-12, 4, -8, 15, -3, 22, 8, -5]
39
39
  // no range of its own to scale against.
40
40
  const FLAT_DATA = [64, 64, 64, 64, 64, 64, 64, 64]
41
41
 
42
+ // The entrance draw-in follows the shared `useReducedMotion` hook
43
+ // (hooks/use-reduced-motion), the same one ChartContainer reads, so a
44
+ // reduced-motion user gets the final frame immediately in every story below.
42
45
  export const Default: Story = {
43
46
  render: () => (
44
47
  <div className="flex flex-col gap-2">
@@ -119,3 +119,21 @@ export const RealisticUse: Story = {
119
119
  </div>
120
120
  ),
121
121
  };
122
+
123
+ export const MaxRows: Story = {
124
+ // Static story — maxRows is the feature under test, not a driven arg.
125
+ parameters: { controls: { disable: true } },
126
+ render: () => (
127
+ <div className="flex flex-col gap-2 w-[320px]">
128
+ <Label htmlFor="maxrows-demo">Note (max 4 rows)</Label>
129
+ <Textarea
130
+ id="maxrows-demo"
131
+ placeholder="Start typing — the field grows up to 4 rows then scrolls."
132
+ maxRows={4}
133
+ />
134
+ <p className="text-xs text-muted-foreground">
135
+ Auto-grows with content; caps at 4 lines.
136
+ </p>
137
+ </div>
138
+ ),
139
+ };
@@ -15,7 +15,7 @@
15
15
  "story files.",
16
16
  "",
17
17
  "GROUP NAMES ARE FOR PEOPLE SCANNING A SIDEBAR. They are not an architectural",
18
- "statement and they are not the layer model \u2014 they answer 'where would someone",
18
+ "statement and they are not the layer model — they answer 'where would someone",
19
19
  "look for this', which is why Accordion sits under Layout rather than Actions",
20
20
  "and Carousel sits under Layout rather than Content.",
21
21
  "",
@@ -124,12 +124,16 @@
124
124
  "Meter",
125
125
  "Timer",
126
126
  "TypingIndicator",
127
- "ToggleTip"
127
+ "ToggleTip",
128
+ "Presence",
129
+ "Callout",
130
+ "AnnouncementBar"
128
131
  ],
129
132
  "Layout": [
130
133
  "Container",
131
134
  "Stack",
132
135
  "SimpleGrid",
136
+ "Grid",
133
137
  "Masonry",
134
138
  "Separator",
135
139
  "AspectRatio",
@@ -146,7 +150,8 @@
146
150
  "FloatingIndicator",
147
151
  "FloatingPanel",
148
152
  "Carousel",
149
- "Card"
153
+ "Card",
154
+ "PageHeader"
150
155
  ],
151
156
  "Content and data": [
152
157
  "Table",
@@ -166,12 +171,15 @@
166
171
  "FormatByte",
167
172
  "FormatNumber",
168
173
  "FormatDate",
174
+ "FormatRelativeTime",
169
175
  "RollingNumber",
170
176
  "Watermark",
171
177
  "Marquee",
172
178
  "WordRotate",
173
179
  "Reveal",
174
- "Sparkline"
180
+ "Sparkline",
181
+ "Icon",
182
+ "ProgressStack"
175
183
  ],
176
184
  "Badges and avatars": [
177
185
  "Avatar",
@@ -194,6 +202,7 @@
194
202
  "HoverCard",
195
203
  "Tooltip",
196
204
  "ContextMenu",
197
- "DropdownMenu"
205
+ "DropdownMenu",
206
+ "Portal"
198
207
  ]
199
208
  }
package/src/styles.css CHANGED
@@ -272,10 +272,18 @@
272
272
  :root above already defines --font-sans, and Tailwind picks it up
273
273
  for the font-sans utility automatically. */
274
274
 
275
- --radius-sm: calc(var(--radius) - 4px);
276
- --radius-md: calc(var(--radius) - 2px);
277
- --radius-lg: var(--radius);
278
- --radius-xl: calc(var(--radius) + 4px);
275
+ /* Per-step override hook, same shape as the type scale above: a fork whose
276
+ brand radius ramp isn't linear-from-one-base (e.g. Furnished Finder's
277
+ 4/8/12/16, which no single --radius value produces from these calc()s)
278
+ sets --radius-sm-size etc. directly. Also closes the duplicate-value
279
+ trap this used to have — a brand file that declared --radius-lg in
280
+ :root created a second, silently-losing value under the same name as
281
+ this computed one; the override name is now distinct from the utility
282
+ name it feeds. */
283
+ --radius-sm: var(--radius-sm-size, calc(var(--radius) - 4px));
284
+ --radius-md: var(--radius-md-size, calc(var(--radius) - 2px));
285
+ --radius-lg: var(--radius-lg-size, var(--radius));
286
+ --radius-xl: var(--radius-xl-size, calc(var(--radius) + 4px));
279
287
 
280
288
  /* Map Tailwind's shadow-* utilities through to the :root --shadow-* tokens
281
289
  so the Customize tab's Shadow Opacity slider takes effect. Without this
@@ -328,12 +336,15 @@
328
336
  /* Marketing tier — display sizes for landing pages, hero blocks, editorial.
329
337
  Tailwind only emits utilities that get used, so a non-marketing fork pays
330
338
  nothing for these. line-height drops to 1.1 at scale to keep big type
331
- readable; tracking tightens slightly to compensate for optical loosening. */
332
- --text-4xl: calc(36px * var(--font-size-scale, 1));
333
- --text-5xl: calc(48px * var(--font-size-scale, 1));
334
- --text-6xl: calc(60px * var(--font-size-scale, 1));
335
- --text-7xl: calc(72px * var(--font-size-scale, 1));
336
- --text-8xl: calc(96px * var(--font-size-scale, 1));
339
+ readable; tracking tightens slightly to compensate for optical loosening.
340
+ Same --text-*-size override hook as the body tier above, so a fork with
341
+ its own display scale (corrections.md-class drift otherwise) can retarget
342
+ these steps too instead of hitting a cliff at text-4xl. */
343
+ --text-4xl: calc(var(--text-4xl-size, 36px) * var(--font-size-scale, 1));
344
+ --text-5xl: calc(var(--text-5xl-size, 48px) * var(--font-size-scale, 1));
345
+ --text-6xl: calc(var(--text-6xl-size, 60px) * var(--font-size-scale, 1));
346
+ --text-7xl: calc(var(--text-7xl-size, 72px) * var(--font-size-scale, 1));
347
+ --text-8xl: calc(var(--text-8xl-size, 96px) * var(--font-size-scale, 1));
337
348
  --text-4xl--line-height: 1.15;
338
349
  --text-5xl--line-height: 1.10;
339
350
  --text-6xl--line-height: 1.05;
@@ -427,8 +438,19 @@
427
438
  body { transition: none; }
428
439
  }
429
440
  /* WCAG AAA 1.4.8: paragraph spacing ≥ 1.5× line-height inside running
430
- text. Scope to <p> only — UI primitives stay tight. Last-child has
431
- no trailing margin so containers don't get extra padding. */
441
+ text. Last-child has no trailing margin so containers don't get extra
442
+ padding.
443
+
444
+ "UI primitives stay tight" is NOT this rule's doing — it is the flex/grid
445
+ carve-out immediately below, and you cannot tell that by reading this
446
+ selector. Measured 2026-09-11 across all eight rail destinations: exactly
447
+ 18 paragraphs in the whole app compute to 1.5em, all of them section
448
+ descriptions on the Components showcase, which is running text and is
449
+ what the rule is for. EmptyState, Stepper, Questionnaire, FileUpload and
450
+ HoverCard all compute to margin-bottom 0 because their content sits in a
451
+ flex column. Every one of those five had been reported as "loosened by
452
+ this rule" from counting <p> tags in source rather than reading the DOM.
453
+ If you are about to rescope or delete this rule, measure first. */
432
454
  p:not(:last-child) {
433
455
  margin-bottom: 1.5em;
434
456
  }
@@ -792,6 +814,105 @@ html, body {
792
814
  animation: progress-stripe var(--progress-stripe-duration, 1s) linear infinite;
793
815
  }
794
816
 
817
+ /* Presence enter/exit keyframes — applied via the data-slot + data-transition
818
+ + data-state selectors the Presence primitive sets (spec §4 pattern (b):
819
+ plain CSS in the design-system layer, no Tailwind utility generation in
820
+ the path). The component flips data-state to "closed" and waits on
821
+ element.getAnimations() before unmounting, so the -out keyframe is what
822
+ the user actually sees.
823
+
824
+ - fill-mode "both" is load-bearing: the -out keyframe must HOLD its final
825
+ frame (opacity 0) until React commits the unmount, otherwise the element
826
+ pops back to fully visible for one frame after animationend.
827
+ - Translate distances are small (0.5rem) so the motion reads as a settle,
828
+ not a slide; scale starts at .96 for the same reason.
829
+ - Reduced motion: the base layer forces animation-duration to 0.01ms; the
830
+ finished promise still resolves, so the unmount is effectively instant. */
831
+ @keyframes presence-fade-in {
832
+ from { opacity: 0; }
833
+ to { opacity: 1; }
834
+ }
835
+ @keyframes presence-fade-out {
836
+ from { opacity: 1; }
837
+ to { opacity: 0; }
838
+ }
839
+ @keyframes presence-scale-in {
840
+ from { opacity: 0; transform: scale(0.96); }
841
+ to { opacity: 1; transform: scale(1); }
842
+ }
843
+ @keyframes presence-scale-out {
844
+ from { opacity: 1; transform: scale(1); }
845
+ to { opacity: 0; transform: scale(0.96); }
846
+ }
847
+ @keyframes presence-slide-up-in {
848
+ from { opacity: 0; transform: translateY(0.5rem); }
849
+ to { opacity: 1; transform: translateY(0); }
850
+ }
851
+ @keyframes presence-slide-up-out {
852
+ from { opacity: 1; transform: translateY(0); }
853
+ to { opacity: 0; transform: translateY(0.5rem); }
854
+ }
855
+ @keyframes presence-slide-down-in {
856
+ from { opacity: 0; transform: translateY(-0.5rem); }
857
+ to { opacity: 1; transform: translateY(0); }
858
+ }
859
+ @keyframes presence-slide-down-out {
860
+ from { opacity: 1; transform: translateY(0); }
861
+ to { opacity: 0; transform: translateY(-0.5rem); }
862
+ }
863
+ @keyframes presence-slide-left-in {
864
+ from { opacity: 0; transform: translateX(0.5rem); }
865
+ to { opacity: 1; transform: translateX(0); }
866
+ }
867
+ @keyframes presence-slide-left-out {
868
+ from { opacity: 1; transform: translateX(0); }
869
+ to { opacity: 0; transform: translateX(0.5rem); }
870
+ }
871
+ @keyframes presence-slide-right-in {
872
+ from { opacity: 0; transform: translateX(-0.5rem); }
873
+ to { opacity: 1; transform: translateX(0); }
874
+ }
875
+ @keyframes presence-slide-right-out {
876
+ from { opacity: 1; transform: translateX(0); }
877
+ to { opacity: 0; transform: translateX(-0.5rem); }
878
+ }
879
+ [data-slot="presence"][data-transition="fade"][data-state="open"] {
880
+ animation: presence-fade-in var(--duration-base) var(--ease-out) both;
881
+ }
882
+ [data-slot="presence"][data-transition="fade"][data-state="closed"] {
883
+ animation: presence-fade-out var(--duration-base) var(--ease-out) both;
884
+ }
885
+ [data-slot="presence"][data-transition="scale"][data-state="open"] {
886
+ animation: presence-scale-in var(--duration-base) var(--ease-out) both;
887
+ }
888
+ [data-slot="presence"][data-transition="scale"][data-state="closed"] {
889
+ animation: presence-scale-out var(--duration-base) var(--ease-out) both;
890
+ }
891
+ [data-slot="presence"][data-transition="slide-up"][data-state="open"] {
892
+ animation: presence-slide-up-in var(--duration-base) var(--ease-out) both;
893
+ }
894
+ [data-slot="presence"][data-transition="slide-up"][data-state="closed"] {
895
+ animation: presence-slide-up-out var(--duration-base) var(--ease-out) both;
896
+ }
897
+ [data-slot="presence"][data-transition="slide-down"][data-state="open"] {
898
+ animation: presence-slide-down-in var(--duration-base) var(--ease-out) both;
899
+ }
900
+ [data-slot="presence"][data-transition="slide-down"][data-state="closed"] {
901
+ animation: presence-slide-down-out var(--duration-base) var(--ease-out) both;
902
+ }
903
+ [data-slot="presence"][data-transition="slide-left"][data-state="open"] {
904
+ animation: presence-slide-left-in var(--duration-base) var(--ease-out) both;
905
+ }
906
+ [data-slot="presence"][data-transition="slide-left"][data-state="closed"] {
907
+ animation: presence-slide-left-out var(--duration-base) var(--ease-out) both;
908
+ }
909
+ [data-slot="presence"][data-transition="slide-right"][data-state="open"] {
910
+ animation: presence-slide-right-in var(--duration-base) var(--ease-out) both;
911
+ }
912
+ [data-slot="presence"][data-transition="slide-right"][data-state="closed"] {
913
+ animation: presence-slide-right-out var(--duration-base) var(--ease-out) both;
914
+ }
915
+
795
916
  /* Prose — long-form typographic rhythm for arbitrary HTML descendants
796
917
  (MDX output, CMS articles, rendered markdown). Keyed off the .prose
797
918
  class the Prose primitive (data-slot="prose") applies — same