@behavioral-agentic-design-system/core 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/check-stories.mjs +12 -5
- package/scripts/fix-stories.mjs +6 -6
- package/scripts/generate-stories.cjs +7 -7
- package/src/app/preview/components/page.tsx +165 -50
- package/src/components/ui/code.tsx +55 -0
- package/src/components/ui/index.ts +0 -1
- package/src/components/ui/indicator.tsx +9 -7
- package/src/components/ui/native-select.tsx +68 -0
- package/src/components/ui/navigation-menu.tsx +23 -0
- package/src/components/ui/sheet.tsx +23 -6
- package/src/components/ui/spinner.tsx +14 -3
- package/src/components/ui/tags-input.tsx +210 -69
- package/src/stories/Accordion.stories.tsx +152 -0
- package/src/stories/Alert.stories.tsx +102 -0
- package/src/stories/AlertDialog.stories.tsx +125 -0
- package/src/stories/AspectRatio.stories.tsx +82 -0
- package/src/stories/Avatar.stories.tsx +36 -0
- package/src/stories/Badge.stories.tsx +54 -0
- package/src/stories/Breadcrumb.stories.tsx +36 -0
- package/src/stories/Button.stories.tsx +144 -0
- package/src/stories/ButtonGroup.stories.tsx +176 -0
- package/src/stories/Calendar.stories.tsx +67 -0
- package/src/stories/Card.stories.tsx +43 -0
- package/src/stories/Carousel.stories.tsx +233 -0
- package/src/stories/Chart.stories.tsx +174 -0
- package/src/stories/Checkbox.stories.tsx +32 -0
- package/src/stories/CircularProgress.stories.tsx +136 -0
- package/src/stories/Code.stories.tsx +131 -0
- package/src/stories/Collapsible.stories.tsx +27 -0
- package/src/stories/ColorPicker.stories.tsx +155 -0
- package/src/stories/Combobox.stories.tsx +168 -0
- package/src/stories/Command.stories.tsx +40 -0
- package/src/stories/ContextMenu.stories.tsx +293 -0
- package/src/stories/CopyButton.stories.tsx +111 -0
- package/src/stories/DatePicker.stories.tsx +176 -0
- package/src/stories/DateRangePicker.stories.tsx +95 -0
- package/src/stories/Dialog.stories.tsx +186 -0
- package/src/stories/DropdownMenu.stories.tsx +47 -0
- package/src/stories/EmptyState.stories.tsx +199 -0
- package/src/stories/Field.stories.tsx +155 -0
- package/src/stories/FileUpload.stories.tsx +134 -0
- package/src/stories/HoverCard.stories.tsx +149 -0
- package/src/stories/Indicator.stories.tsx +255 -0
- package/src/stories/Input.stories.tsx +69 -0
- package/src/stories/Kbd.stories.tsx +123 -0
- package/src/stories/Label.stories.tsx +27 -0
- package/src/stories/List.stories.tsx +159 -0
- package/src/stories/Menubar.stories.tsx +190 -0
- package/src/stories/MultiSelect.stories.tsx +107 -0
- package/src/stories/NativeSelect.stories.tsx +107 -0
- package/src/stories/NavigationMenu.stories.tsx +322 -0
- package/src/stories/NumberInput.stories.tsx +100 -0
- package/src/stories/Pagination.stories.tsx +201 -0
- package/src/stories/PasswordInput.stories.tsx +62 -0
- package/src/stories/PinInput.stories.tsx +136 -0
- package/src/stories/Popover.stories.tsx +37 -0
- package/src/stories/Progress.stories.tsx +64 -0
- package/src/stories/RadioGroup.stories.tsx +39 -0
- package/src/stories/RatingGroup.stories.tsx +102 -0
- package/src/stories/Resizable.stories.tsx +28 -0
- package/src/stories/Reveal.stories.tsx +63 -0
- package/src/stories/ScrollArea.stories.tsx +76 -0
- package/src/stories/SegmentedControl.stories.tsx +182 -0
- package/src/stories/Select.stories.tsx +62 -0
- package/src/stories/Separator.stories.tsx +28 -0
- package/src/stories/Sheet.stories.tsx +193 -0
- package/src/stories/Sidebar.stories.tsx +53 -0
- package/src/stories/Skeleton.stories.tsx +32 -0
- package/src/stories/Slider.stories.tsx +67 -0
- package/src/stories/Sonner.stories.tsx +146 -0
- package/src/stories/Spinner.stories.tsx +94 -0
- package/src/stories/Stepper.stories.tsx +228 -0
- package/src/stories/Switch.stories.tsx +58 -0
- package/src/stories/Table.stories.tsx +38 -0
- package/src/stories/Tabs.stories.tsx +128 -0
- package/src/stories/Tag.stories.tsx +51 -0
- package/src/stories/TagsInput.stories.tsx +154 -0
- package/src/stories/Textarea.stories.tsx +31 -0
- package/src/stories/TimePicker.stories.tsx +54 -0
- package/src/stories/Timeline.stories.tsx +263 -0
- package/src/stories/Toggle.stories.tsx +45 -0
- package/src/stories/ToggleGroup.stories.tsx +39 -0
- package/src/stories/Toolbar.stories.tsx +295 -0
- package/src/stories/Tooltip.stories.tsx +37 -0
- package/src/stories/TreeView.stories.tsx +293 -0
- package/src/components/ui/bottom-sheet.tsx +0 -133
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
|
|
@@ -3,8 +3,14 @@
|
|
|
3
3
|
* Storybook coverage check.
|
|
4
4
|
*
|
|
5
5
|
* Strict rule: every primitive in packages/core/src/components/ui/*.tsx must
|
|
6
|
-
* have a matching
|
|
7
|
-
* is touched in a commit, its story file must be touched in the
|
|
6
|
+
* have a matching packages/core/src/stories/<PascalCase>.stories.tsx. When a
|
|
7
|
+
* component file is touched in a commit, its story file must be touched in the
|
|
8
|
+
* same commit.
|
|
9
|
+
*
|
|
10
|
+
* Stories live INSIDE the published @core package (under src/) so they ship to
|
|
11
|
+
* forks over npm the same way the Foundations stories already do — a fork's
|
|
12
|
+
* Storybook globs node_modules/@.../core/src/stories/*.stories.tsx and gets
|
|
13
|
+
* every upstream story automatically on the next @core bump.
|
|
8
14
|
*
|
|
9
15
|
* Modes:
|
|
10
16
|
* pnpm check:stories → precommit mode (staged-only, used by hook)
|
|
@@ -19,7 +25,7 @@ import { join, basename } from "node:path";
|
|
|
19
25
|
|
|
20
26
|
const ROOT = process.cwd();
|
|
21
27
|
const COMPONENTS_DIR = join(ROOT, "packages/core/src/components/ui");
|
|
22
|
-
const STORIES_DIR = join(ROOT, "
|
|
28
|
+
const STORIES_DIR = join(ROOT, "packages/core/src/stories");
|
|
23
29
|
|
|
24
30
|
const ALL = process.argv.includes("--all");
|
|
25
31
|
|
|
@@ -32,8 +38,9 @@ function pascal(kebab) {
|
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
function componentToStoryPath(componentRel) {
|
|
35
|
-
// packages/core/src/components/ui/dropdown-menu.tsx
|
|
36
|
-
|
|
41
|
+
// packages/core/src/components/ui/dropdown-menu.tsx
|
|
42
|
+
// → packages/core/src/stories/DropdownMenu.stories.tsx
|
|
43
|
+
return `packages/core/src/stories/${pascal(basename(componentRel))}.stories.tsx`;
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
function listAllComponents() {
|
package/scripts/fix-stories.mjs
CHANGED
|
@@ -20,14 +20,14 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from
|
|
|
20
20
|
import { join, basename, dirname } from "node:path";
|
|
21
21
|
import { fileURLToPath } from "node:url";
|
|
22
22
|
|
|
23
|
-
// Shipped as the `bads-fix-stories` bin.
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
23
|
+
// Shipped as the `bads-fix-stories` bin. Both the component SOURCE and the
|
|
24
|
+
// stories OUTPUT are package-owned: stories now live in the core package under
|
|
25
|
+
// src/stories/ so they ship to forks over npm (a fork's Storybook globs
|
|
26
|
+
// node_modules/@.../core/src/stories/*.stories.tsx). Resolve both relative to
|
|
27
|
+
// this script's own location inside the package.
|
|
27
28
|
const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url));
|
|
28
|
-
const ROOT = process.cwd();
|
|
29
29
|
const COMPONENTS_DIR = join(SCRIPT_DIR, "..", "src/components/ui");
|
|
30
|
-
const STORIES_DIR = join(
|
|
30
|
+
const STORIES_DIR = join(SCRIPT_DIR, "..", "src/stories");
|
|
31
31
|
if (!existsSync(STORIES_DIR)) mkdirSync(STORIES_DIR, { recursive: true });
|
|
32
32
|
|
|
33
33
|
function pascal(kebab) {
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
|
|
6
|
-
// Shipped as the `bads-generate-stories` bin.
|
|
7
|
-
// package-owned
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// land in the fork's components/ dir, and imports always reference the core
|
|
6
|
+
// Shipped as the `bads-generate-stories` bin. Both the component SOURCE and the
|
|
7
|
+
// stories OUTPUT are package-owned: stories live under the core package's
|
|
8
|
+
// src/stories/ so they ship to forks over npm. Resolve both relative to this
|
|
9
|
+
// script's own location inside the package. Imports still reference the core
|
|
11
10
|
// package by its real published name (read from core's own package.json, so a
|
|
12
|
-
// fork's rename never corrupts the scope)
|
|
11
|
+
// fork's rename never corrupts the scope) — the specifier self-resolves both
|
|
12
|
+
// inside the package and from a consumer's node_modules.
|
|
13
13
|
const CORE = require(path.join(__dirname, '..', 'package.json')).name;
|
|
14
14
|
const componentDir = path.join(__dirname, '..', 'src/components/ui');
|
|
15
|
-
const storiesDir = path.join(
|
|
15
|
+
const storiesDir = path.join(__dirname, '..', 'src/stories');
|
|
16
16
|
|
|
17
17
|
if (!fs.existsSync(storiesDir)) fs.mkdirSync(storiesDir, { recursive: true });
|
|
18
18
|
|
|
@@ -54,16 +54,6 @@ import {
|
|
|
54
54
|
AlertDialogTrigger,
|
|
55
55
|
} from "@behavioral-agentic-design-system/core/components/ui/alert-dialog";
|
|
56
56
|
import { buttonVariants } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
57
|
-
import {
|
|
58
|
-
BottomSheet,
|
|
59
|
-
BottomSheetClose,
|
|
60
|
-
BottomSheetContent,
|
|
61
|
-
BottomSheetDescription,
|
|
62
|
-
BottomSheetFooter,
|
|
63
|
-
BottomSheetHeader,
|
|
64
|
-
BottomSheetTitle,
|
|
65
|
-
BottomSheetTrigger,
|
|
66
|
-
} from "@behavioral-agentic-design-system/core/components/ui/bottom-sheet";
|
|
67
57
|
import {
|
|
68
58
|
Carousel,
|
|
69
59
|
CarouselContent,
|
|
@@ -123,6 +113,7 @@ import {
|
|
|
123
113
|
import { Combobox } from "@behavioral-agentic-design-system/core/components/ui/combobox";
|
|
124
114
|
import { MultiSelect } from "@behavioral-agentic-design-system/core/components/ui/multi-select";
|
|
125
115
|
import { Kbd } from "@behavioral-agentic-design-system/core/components/ui/kbd";
|
|
116
|
+
import { Code } from "@behavioral-agentic-design-system/core/components/ui/code";
|
|
126
117
|
import {
|
|
127
118
|
Toolbar,
|
|
128
119
|
ToolbarButton,
|
|
@@ -272,6 +263,7 @@ import {
|
|
|
272
263
|
TreeItemContent,
|
|
273
264
|
} from "@behavioral-agentic-design-system/core/components/ui/tree-view";
|
|
274
265
|
import { ColorPicker } from "@behavioral-agentic-design-system/core/components/ui/color-picker";
|
|
266
|
+
import { NativeSelect } from "@behavioral-agentic-design-system/core/components/ui/native-select";
|
|
275
267
|
|
|
276
268
|
// Stable, deterministic data for ScrollArea — never use Math.random in
|
|
277
269
|
// SSR-rendered output, it causes hydration mismatches.
|
|
@@ -850,50 +842,53 @@ export default function ComponentsPreview() {
|
|
|
850
842
|
<SegmentedControlShowcase />
|
|
851
843
|
</Section>
|
|
852
844
|
|
|
853
|
-
<Section title="
|
|
845
|
+
<Section title="Bottom Sheet">
|
|
846
|
+
{/* Bottom sheets are just <Sheet> with side="bottom" — they pick up
|
|
847
|
+
the rounded top, grab handle, capped height + scroll, and safe-area
|
|
848
|
+
padding automatically. Pass showHandle={false} to hide the handle. */}
|
|
854
849
|
<div className="flex flex-wrap gap-3">
|
|
855
850
|
{/* Default — grab handle + close button */}
|
|
856
|
-
<
|
|
857
|
-
<
|
|
851
|
+
<Sheet>
|
|
852
|
+
<SheetTrigger asChild>
|
|
858
853
|
<Button variant="outline">Open</Button>
|
|
859
|
-
</
|
|
860
|
-
<
|
|
861
|
-
<
|
|
862
|
-
<
|
|
863
|
-
<
|
|
854
|
+
</SheetTrigger>
|
|
855
|
+
<SheetContent side="bottom">
|
|
856
|
+
<SheetHeader>
|
|
857
|
+
<SheetTitle>Display density</SheetTitle>
|
|
858
|
+
<SheetDescription>
|
|
864
859
|
Choose how much information shows on each row.
|
|
865
|
-
</
|
|
866
|
-
</
|
|
867
|
-
</
|
|
868
|
-
</
|
|
860
|
+
</SheetDescription>
|
|
861
|
+
</SheetHeader>
|
|
862
|
+
</SheetContent>
|
|
863
|
+
</Sheet>
|
|
869
864
|
|
|
870
865
|
{/* No handle variant */}
|
|
871
|
-
<
|
|
872
|
-
<
|
|
866
|
+
<Sheet>
|
|
867
|
+
<SheetTrigger asChild>
|
|
873
868
|
<Button variant="outline">No handle</Button>
|
|
874
|
-
</
|
|
875
|
-
<
|
|
876
|
-
<
|
|
877
|
-
<
|
|
878
|
-
<
|
|
869
|
+
</SheetTrigger>
|
|
870
|
+
<SheetContent side="bottom" showHandle={false}>
|
|
871
|
+
<SheetHeader>
|
|
872
|
+
<SheetTitle>No grab handle</SheetTitle>
|
|
873
|
+
<SheetDescription>
|
|
879
874
|
Handle hidden via showHandle={"{false}"}.
|
|
880
|
-
</
|
|
881
|
-
</
|
|
882
|
-
</
|
|
883
|
-
</
|
|
875
|
+
</SheetDescription>
|
|
876
|
+
</SheetHeader>
|
|
877
|
+
</SheetContent>
|
|
878
|
+
</Sheet>
|
|
884
879
|
|
|
885
880
|
{/* Realistic action sheet with a footer */}
|
|
886
|
-
<
|
|
887
|
-
<
|
|
881
|
+
<Sheet>
|
|
882
|
+
<SheetTrigger asChild>
|
|
888
883
|
<Button>View settings</Button>
|
|
889
|
-
</
|
|
890
|
-
<
|
|
891
|
-
<
|
|
892
|
-
<
|
|
893
|
-
<
|
|
884
|
+
</SheetTrigger>
|
|
885
|
+
<SheetContent side="bottom">
|
|
886
|
+
<SheetHeader>
|
|
887
|
+
<SheetTitle>View settings</SheetTitle>
|
|
888
|
+
<SheetDescription>
|
|
894
889
|
These apply to the Components board only.
|
|
895
|
-
</
|
|
896
|
-
</
|
|
890
|
+
</SheetDescription>
|
|
891
|
+
</SheetHeader>
|
|
897
892
|
<div className="flex flex-col gap-5 px-4 py-2">
|
|
898
893
|
<div className="flex items-center justify-between">
|
|
899
894
|
<Label htmlFor="density-group">Group by status</Label>
|
|
@@ -904,16 +899,16 @@ export default function ComponentsPreview() {
|
|
|
904
899
|
<Switch id="density-sub" />
|
|
905
900
|
</div>
|
|
906
901
|
</div>
|
|
907
|
-
<
|
|
908
|
-
<
|
|
902
|
+
<SheetFooter className="flex-row justify-end gap-2">
|
|
903
|
+
<SheetClose asChild>
|
|
909
904
|
<Button variant="ghost">Cancel</Button>
|
|
910
|
-
</
|
|
911
|
-
<
|
|
905
|
+
</SheetClose>
|
|
906
|
+
<SheetClose asChild>
|
|
912
907
|
<Button>Apply</Button>
|
|
913
|
-
</
|
|
914
|
-
</
|
|
915
|
-
</
|
|
916
|
-
</
|
|
908
|
+
</SheetClose>
|
|
909
|
+
</SheetFooter>
|
|
910
|
+
</SheetContent>
|
|
911
|
+
</Sheet>
|
|
917
912
|
</div>
|
|
918
913
|
</Section>
|
|
919
914
|
|
|
@@ -1908,6 +1903,58 @@ export default function ComponentsPreview() {
|
|
|
1908
1903
|
</div>
|
|
1909
1904
|
</div>
|
|
1910
1905
|
</Section>
|
|
1906
|
+
<Section title="Code">
|
|
1907
|
+
<div className="space-y-6">
|
|
1908
|
+
<div className="space-y-2">
|
|
1909
|
+
<p className="text-sm font-medium text-muted-foreground">Inline (default)</p>
|
|
1910
|
+
<p className="text-sm text-foreground leading-relaxed max-w-sm">
|
|
1911
|
+
Set the primary brand color via{" "}
|
|
1912
|
+
<Code>--primary</Code> in{" "}
|
|
1913
|
+
<Code>tokens.json</Code> and run{" "}
|
|
1914
|
+
<Code>pnpm build:tokens</Code> to regenerate.
|
|
1915
|
+
</p>
|
|
1916
|
+
</div>
|
|
1917
|
+
<div className="space-y-2">
|
|
1918
|
+
<p className="text-sm font-medium text-muted-foreground">Block variant</p>
|
|
1919
|
+
<div className="w-[480px]">
|
|
1920
|
+
<Code variant="block">
|
|
1921
|
+
{`// tokens.json — semantic layer\n{\n "theme": {\n "light": {\n "primary": "#1a1a1a",\n "primary-foreground": "#ffffff"\n }\n }\n}`}
|
|
1922
|
+
</Code>
|
|
1923
|
+
</div>
|
|
1924
|
+
</div>
|
|
1925
|
+
<div className="space-y-2">
|
|
1926
|
+
<p className="text-sm font-medium text-muted-foreground">Sizes — sm / default / lg</p>
|
|
1927
|
+
<div className="flex flex-col gap-3">
|
|
1928
|
+
<div className="flex items-center gap-3">
|
|
1929
|
+
<Code size="sm">pnpm a11y</Code>
|
|
1930
|
+
<Code size="default">pnpm wcag:audit</Code>
|
|
1931
|
+
<Code size="lg">design-tokens</Code>
|
|
1932
|
+
</div>
|
|
1933
|
+
<div className="w-[440px] space-y-1.5">
|
|
1934
|
+
<Code variant="block" size="sm">{`78 pass · 0 fail · 0 warn`}</Code>
|
|
1935
|
+
<Code variant="block" size="default">{`✓ primary on background 12.6:1 AAA`}</Code>
|
|
1936
|
+
<Code variant="block" size="lg">{`@behavioral-agentic-design-system/core@0.16.0`}</Code>
|
|
1937
|
+
</div>
|
|
1938
|
+
</div>
|
|
1939
|
+
</div>
|
|
1940
|
+
<div className="space-y-2">
|
|
1941
|
+
<p className="text-sm font-medium text-muted-foreground">Realistic use</p>
|
|
1942
|
+
<div className="max-w-md space-y-4 text-sm text-foreground leading-relaxed">
|
|
1943
|
+
<div className="space-y-1">
|
|
1944
|
+
<p className="font-medium text-foreground">Install the package</p>
|
|
1945
|
+
<Code variant="block">{`pnpm add @behavioral-agentic-design-system/core`}</Code>
|
|
1946
|
+
</div>
|
|
1947
|
+
<p>
|
|
1948
|
+
Import tokens via <Code>import "@behavioral-agentic-design-system/core/styles.css"</Code>{" "}
|
|
1949
|
+
in your root layout, then use any component:
|
|
1950
|
+
</p>
|
|
1951
|
+
<Code variant="block">
|
|
1952
|
+
{`import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"\n\nexport function Example() {\n return <Button variant="default">Get started</Button>\n}`}
|
|
1953
|
+
</Code>
|
|
1954
|
+
</div>
|
|
1955
|
+
</div>
|
|
1956
|
+
</div>
|
|
1957
|
+
</Section>
|
|
1911
1958
|
<Section title="Combobox">
|
|
1912
1959
|
<div className="space-y-6">
|
|
1913
1960
|
<div className="grid grid-cols-1 gap-6 sm:grid-cols-2">
|
|
@@ -2198,6 +2245,24 @@ export default function ComponentsPreview() {
|
|
|
2198
2245
|
placeholder="Add stroke…"
|
|
2199
2246
|
/>
|
|
2200
2247
|
</div>
|
|
2248
|
+
<div className="space-y-3">
|
|
2249
|
+
<p className="text-sm font-medium text-muted-foreground">With suggestions (autocomplete) — type "fly" or "back"</p>
|
|
2250
|
+
<TagsInputShowcase
|
|
2251
|
+
placeholder="Add a stroke or event…"
|
|
2252
|
+
suggestions={[
|
|
2253
|
+
"Butterfly",
|
|
2254
|
+
"Backstroke",
|
|
2255
|
+
"Breaststroke",
|
|
2256
|
+
"Freestyle",
|
|
2257
|
+
"Individual Medley",
|
|
2258
|
+
"50m Freestyle",
|
|
2259
|
+
"100m Butterfly",
|
|
2260
|
+
"200m Backstroke",
|
|
2261
|
+
"400m IM",
|
|
2262
|
+
"Medley Relay",
|
|
2263
|
+
]}
|
|
2264
|
+
/>
|
|
2265
|
+
</div>
|
|
2201
2266
|
<div className="space-y-3">
|
|
2202
2267
|
<p className="text-sm font-medium text-muted-foreground">Max tags (4)</p>
|
|
2203
2268
|
<TagsInputShowcase
|
|
@@ -2426,6 +2491,52 @@ export default function ComponentsPreview() {
|
|
|
2426
2491
|
</div>
|
|
2427
2492
|
</Section>
|
|
2428
2493
|
|
|
2494
|
+
<Section title="Native Select">
|
|
2495
|
+
<div className="grid gap-6 sm:grid-cols-2">
|
|
2496
|
+
<div className="space-y-2">
|
|
2497
|
+
<Label htmlFor="ns-focus">Design Focus Area</Label>
|
|
2498
|
+
<NativeSelect id="ns-focus" defaultValue="components">
|
|
2499
|
+
<option value="">Choose a focus area</option>
|
|
2500
|
+
<option value="tokens">Design Tokens</option>
|
|
2501
|
+
<option value="components">Components</option>
|
|
2502
|
+
<option value="patterns">Patterns</option>
|
|
2503
|
+
<option value="a11y">Accessibility</option>
|
|
2504
|
+
<option value="motion">Motion & Animation</option>
|
|
2505
|
+
</NativeSelect>
|
|
2506
|
+
</div>
|
|
2507
|
+
<div className="space-y-2">
|
|
2508
|
+
<Label htmlFor="ns-disabled">Disabled</Label>
|
|
2509
|
+
<NativeSelect id="ns-disabled" disabled defaultValue="components">
|
|
2510
|
+
<option value="components">Components (locked)</option>
|
|
2511
|
+
</NativeSelect>
|
|
2512
|
+
</div>
|
|
2513
|
+
<div className="space-y-2">
|
|
2514
|
+
<Label htmlFor="ns-invalid">Invalid</Label>
|
|
2515
|
+
<NativeSelect id="ns-invalid" aria-invalid defaultValue="">
|
|
2516
|
+
<option value="">Select a valid option</option>
|
|
2517
|
+
<option value="tokens">Design Tokens</option>
|
|
2518
|
+
</NativeSelect>
|
|
2519
|
+
</div>
|
|
2520
|
+
<div className="space-y-2">
|
|
2521
|
+
<p className="text-sm font-medium text-foreground">Sizes</p>
|
|
2522
|
+
<div className="flex flex-col gap-2">
|
|
2523
|
+
<NativeSelect size="sm" defaultValue="sm">
|
|
2524
|
+
<option value="sm">Small (sm)</option>
|
|
2525
|
+
</NativeSelect>
|
|
2526
|
+
<NativeSelect size="default" defaultValue="default">
|
|
2527
|
+
<option value="default">Default</option>
|
|
2528
|
+
</NativeSelect>
|
|
2529
|
+
<NativeSelect size="lg" defaultValue="lg">
|
|
2530
|
+
<option value="lg">Large (lg)</option>
|
|
2531
|
+
</NativeSelect>
|
|
2532
|
+
<NativeSelect size="xl" defaultValue="xl">
|
|
2533
|
+
<option value="xl">Extra Large (xl)</option>
|
|
2534
|
+
</NativeSelect>
|
|
2535
|
+
</div>
|
|
2536
|
+
</div>
|
|
2537
|
+
</div>
|
|
2538
|
+
</Section>
|
|
2539
|
+
|
|
2429
2540
|
<Section title="Textarea">
|
|
2430
2541
|
<div className="grid gap-6 sm:grid-cols-2">
|
|
2431
2542
|
<div className="space-y-2">
|
|
@@ -2526,6 +2637,9 @@ export default function ComponentsPreview() {
|
|
|
2526
2637
|
</Section>
|
|
2527
2638
|
|
|
2528
2639
|
<Section title="Dropdown Menu">
|
|
2640
|
+
{/* flex wrapper keeps the trigger button content-width — Section's
|
|
2641
|
+
Card is a flex column, so a bare trigger stretches to full width. */}
|
|
2642
|
+
<div className="flex">
|
|
2529
2643
|
<DropdownMenu>
|
|
2530
2644
|
<DropdownMenuTrigger asChild>
|
|
2531
2645
|
<Button variant="outline" className="gap-2">
|
|
@@ -2552,6 +2666,7 @@ export default function ComponentsPreview() {
|
|
|
2552
2666
|
<DropdownMenuItem variant="destructive">Scratch swimmer</DropdownMenuItem>
|
|
2553
2667
|
</DropdownMenuContent>
|
|
2554
2668
|
</DropdownMenu>
|
|
2669
|
+
</div>
|
|
2555
2670
|
</Section>
|
|
2556
2671
|
|
|
2557
2672
|
<Section title="Command">
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
|
|
8
|
+
const codeVariants = cva("font-mono text-muted-foreground bg-muted", {
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
inline: "inline rounded px-[0.3em] py-[0.1em] text-xs",
|
|
12
|
+
block:
|
|
13
|
+
"block w-full rounded-md border border-border px-3 py-2.5 text-sm leading-relaxed overflow-x-auto whitespace-pre outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
sm: "",
|
|
17
|
+
default: "",
|
|
18
|
+
lg: "",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
compoundVariants: [
|
|
22
|
+
{ variant: "inline", size: "sm", class: "text-xs" },
|
|
23
|
+
{ variant: "inline", size: "default", class: "text-xs" },
|
|
24
|
+
{ variant: "inline", size: "lg", class: "text-sm" },
|
|
25
|
+
{ variant: "block", size: "sm", class: "text-xs" },
|
|
26
|
+
{ variant: "block", size: "default", class: "text-sm" },
|
|
27
|
+
{ variant: "block", size: "lg", class: "text-base" },
|
|
28
|
+
],
|
|
29
|
+
defaultVariants: {
|
|
30
|
+
variant: "inline",
|
|
31
|
+
size: "default",
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export interface CodeProps
|
|
36
|
+
extends React.ComponentProps<"code">,
|
|
37
|
+
VariantProps<typeof codeVariants> {}
|
|
38
|
+
|
|
39
|
+
function Code({ className, variant, size, children, ...props }: CodeProps) {
|
|
40
|
+
const isBlock = variant === "block"
|
|
41
|
+
return (
|
|
42
|
+
<code
|
|
43
|
+
data-slot={isBlock ? "code-block" : "code"}
|
|
44
|
+
className={cn(codeVariants({ variant, size }), className)}
|
|
45
|
+
// Block code scrolls horizontally (overflow-x-auto); make the scroll
|
|
46
|
+
// region reachable by keyboard so it satisfies axe scrollable-region-focusable.
|
|
47
|
+
tabIndex={isBlock ? 0 : undefined}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</code>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { Code, codeVariants }
|
|
@@ -26,9 +26,9 @@ const indicatorDotVariants = cva(
|
|
|
26
26
|
},
|
|
27
27
|
size: {
|
|
28
28
|
// Dot-only base dimensions; labeled mode overrides height + min-width below
|
|
29
|
-
sm: "size-
|
|
30
|
-
default: "size-
|
|
31
|
-
lg: "size-
|
|
29
|
+
sm: "size-2",
|
|
30
|
+
default: "size-3",
|
|
31
|
+
lg: "size-4",
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
defaultVariants: {
|
|
@@ -125,10 +125,12 @@ function Indicator({
|
|
|
125
125
|
className={cn(
|
|
126
126
|
indicatorDotVariants({ variant, size }),
|
|
127
127
|
positionMap[position],
|
|
128
|
-
// Labeled mode:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
showLabel &&
|
|
128
|
+
// Labeled mode: text stays at the 14px floor (AAA SC 1.4.4); the
|
|
129
|
+
// circle around it is sized up via height + min-width so the count
|
|
130
|
+
// reads with breathing room instead of cramping the digits.
|
|
131
|
+
showLabel && "text-xs leading-none px-1.5",
|
|
132
|
+
showLabel && size === "default" && "h-5 min-w-5",
|
|
133
|
+
showLabel && size === "lg" && "h-6 min-w-6",
|
|
132
134
|
withBorder && "ring-2 ring-background",
|
|
133
135
|
indicatorClassName
|
|
134
136
|
)}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
import { ChevronDown } from "lucide-react"
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/utils"
|
|
6
|
+
|
|
7
|
+
const nativeSelectVariants = cva(
|
|
8
|
+
"w-full min-w-0 appearance-none rounded-md border border-input bg-transparent shadow-xs outline-none text-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
size: {
|
|
12
|
+
sm: "h-8 px-2.5 pr-8 py-1 text-sm",
|
|
13
|
+
default: "h-9 px-3 pr-9 py-1 text-base md:text-sm",
|
|
14
|
+
lg: "h-10 px-4 pr-10 py-2 text-base",
|
|
15
|
+
xl: "h-11 px-4 pr-11 py-2 text-base",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: "default",
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const chevronSizeMap: Record<string, string> = {
|
|
25
|
+
sm: "size-3.5 right-2.5",
|
|
26
|
+
default: "size-4 right-3",
|
|
27
|
+
lg: "size-4 right-3",
|
|
28
|
+
xl: "size-4 right-3.5",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function NativeSelect({
|
|
32
|
+
className,
|
|
33
|
+
size,
|
|
34
|
+
children,
|
|
35
|
+
...props
|
|
36
|
+
}: Omit<React.ComponentProps<"select">, "size"> &
|
|
37
|
+
VariantProps<typeof nativeSelectVariants>) {
|
|
38
|
+
const resolvedSize = size ?? "default"
|
|
39
|
+
const chevronClasses = chevronSizeMap[resolvedSize] ?? chevronSizeMap["default"]
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div data-slot="native-select" className="relative w-full">
|
|
43
|
+
<select
|
|
44
|
+
data-slot="native-select-element"
|
|
45
|
+
data-size={resolvedSize}
|
|
46
|
+
className={cn(nativeSelectVariants({ size, className }))}
|
|
47
|
+
style={{
|
|
48
|
+
transitionProperty: "color, box-shadow",
|
|
49
|
+
transitionDuration: "var(--duration-fast)",
|
|
50
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
51
|
+
}}
|
|
52
|
+
{...props}
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
</select>
|
|
56
|
+
<ChevronDown
|
|
57
|
+
strokeWidth={1.5}
|
|
58
|
+
aria-hidden
|
|
59
|
+
className={cn(
|
|
60
|
+
"pointer-events-none absolute top-1/2 -translate-y-1/2 text-muted-foreground",
|
|
61
|
+
chevronClasses
|
|
62
|
+
)}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { NativeSelect, nativeSelectVariants }
|
|
@@ -57,8 +57,18 @@ function NavigationMenuItem({
|
|
|
57
57
|
function NavigationMenuTrigger({
|
|
58
58
|
className,
|
|
59
59
|
children,
|
|
60
|
+
onClick,
|
|
61
|
+
onPointerEnter,
|
|
60
62
|
...props
|
|
61
63
|
}: React.ComponentProps<typeof NavigationMenuPrimitive.Trigger>) {
|
|
64
|
+
// Radix opens this on hover, but a click on an already-open trigger toggles
|
|
65
|
+
// it closed — so "hover then click" flickers the panel open→closed and feels
|
|
66
|
+
// buggy. Swallow ONLY the click that lands right after a hover-open: record
|
|
67
|
+
// the hover timestamp, then preventDefault on a click within 700ms while the
|
|
68
|
+
// panel is open. Because Radix composes the prop handler before its internal
|
|
69
|
+
// toggle (with checkForDefaultPrevented), preventing the default skips the
|
|
70
|
+
// close. Keyboard Enter-to-close still works — it has no recent pointer-enter.
|
|
71
|
+
const hoverOpenedAt = React.useRef(0)
|
|
62
72
|
return (
|
|
63
73
|
<NavigationMenuPrimitive.Trigger
|
|
64
74
|
data-slot="navigation-menu-trigger"
|
|
@@ -66,6 +76,19 @@ function NavigationMenuTrigger({
|
|
|
66
76
|
"group inline-flex h-9 w-max items-center justify-center gap-1 rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-hidden disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50",
|
|
67
77
|
className
|
|
68
78
|
)}
|
|
79
|
+
onPointerEnter={(event) => {
|
|
80
|
+
hoverOpenedAt.current = event.timeStamp
|
|
81
|
+
onPointerEnter?.(event)
|
|
82
|
+
}}
|
|
83
|
+
onClick={(event) => {
|
|
84
|
+
if (
|
|
85
|
+
event.currentTarget.dataset.state === "open" &&
|
|
86
|
+
event.timeStamp - hoverOpenedAt.current < 700
|
|
87
|
+
) {
|
|
88
|
+
event.preventDefault()
|
|
89
|
+
}
|
|
90
|
+
onClick?.(event)
|
|
91
|
+
}}
|
|
69
92
|
{...props}
|
|
70
93
|
>
|
|
71
94
|
{children}
|