@behavioral-agentic-design-system/core 0.42.0 → 0.45.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/LICENSE +21 -0
- package/package.json +25 -9
- package/scripts/a11y-lint.cjs +25 -1
- package/scripts/check-spec.mjs +73 -0
- package/scripts/deal-directions.mjs +186 -0
- package/scripts/health-report.mjs +20 -14
- package/scripts/lib/counted-lint.mjs +100 -0
- package/scripts/lib/marketing-library.mjs +129 -0
- package/scripts/lib/on-system.mjs +249 -0
- package/scripts/lib/random.mjs +22 -0
- package/scripts/lib/spec-parse.d.mts +25 -0
- package/scripts/lib/spec-parse.mjs +188 -0
- package/scripts/lib/tells.mjs +128 -0
- package/scripts/lint-css-vars.mjs +175 -0
- package/scripts/lint-html-nesting.mjs +116 -0
- package/scripts/lint-live-ctas.mjs +138 -0
- package/scripts/on-system-score.mjs +95 -0
- package/scripts/slop-rules.mjs +1 -1
- package/scripts/source-images.mjs +180 -0
- package/scripts/ux-tells.mjs +78 -0
- package/src/api/brand-colors.ts +3 -0
- package/src/api/brand-fonts.ts +3 -0
- package/src/api/brand-mark.ts +6 -1
- package/src/api/dev-write-guard.ts +53 -0
- package/src/api/layers/file.ts +7 -4
- package/src/api/onboarding-extract.ts +85 -30
- package/src/api/onboarding.ts +3 -0
- package/src/api/save-tokens.ts +3 -0
- package/src/app/layout.tsx +6 -0
- package/src/app/preview/canvas/page.tsx +12 -0
- package/src/app/preview/components/page.tsx +734 -0
- package/src/app/preview/studio/blank-screen.tsx +143 -0
- package/src/app/preview/studio/page.tsx +7 -0
- package/src/app/shell.tsx +160 -44
- package/src/components/canvas/canvas.tsx +458 -0
- package/src/components/canvas/layout.ts +72 -0
- package/src/components/canvas/parse-canvas.ts +32 -0
- package/src/components/canvas/sample.ts +90 -0
- package/src/components/canvas/spec-frame.tsx +43 -0
- package/src/components/canvas/types.ts +33 -0
- package/src/components/docs-tab.tsx +7 -7
- package/src/components/home-recent.tsx +73 -0
- package/src/components/home-tab.tsx +13 -13
- package/src/components/layers-tab.tsx +2 -2
- package/src/components/markdown-preview.tsx +60 -12
- package/src/components/studio/control-panel.tsx +299 -0
- package/src/components/studio/control-row.tsx +77 -0
- package/src/components/studio/preview-frame.tsx +165 -0
- package/src/components/studio/preview-pane.tsx +247 -0
- package/src/components/studio/studio.tsx +133 -128
- package/src/components/studio/types.ts +218 -0
- package/src/components/studio/use-studio-tweaks.ts +128 -0
- package/src/components/studio/use-studio-view-state.ts +72 -0
- package/src/components/ui/autocomplete.tsx +1 -1
- package/src/components/ui/color-picker.tsx +20 -4
- package/src/components/ui/data-table.tsx +64 -3
- package/src/components/ui/date-field.tsx +1 -1
- package/src/components/ui/editable.tsx +1 -0
- package/src/components/ui/faceted-filter.tsx +187 -0
- package/src/components/ui/gauge-chart.tsx +18 -4
- package/src/components/ui/inline-edit.tsx +175 -0
- package/src/components/ui/month-picker.tsx +1 -1
- package/src/components/ui/number-input.tsx +28 -5
- package/src/components/ui/otp-input.tsx +208 -0
- package/src/components/ui/phone-input.tsx +274 -0
- package/src/components/ui/search-input.tsx +1 -1
- package/src/components/ui/tags-input.tsx +1 -1
- package/src/components/ui/timer.tsx +1 -0
- package/src/components/ui/transfer-list.tsx +13 -26
- package/src/components/ui/week-picker.tsx +1 -1
- package/src/components/ui/year-picker.tsx +1 -1
- package/src/data/component-added.json +958 -0
- package/src/data/docs-index.ts +13 -1
- package/src/hooks/use-global-mono-font.ts +1 -0
- package/src/hooks/use-global-primary-color.ts +1 -0
- package/src/hooks/use-global-sans-font.ts +1 -0
- package/src/hooks/use-global-serif-font.ts +1 -0
- package/src/hooks/use-global-type-scale.ts +17 -2
- package/src/hooks/use-mobile.ts +2 -0
- package/src/hooks/use-sync-type-scale.ts +7 -11
- package/src/lib/spec-parse.ts +4 -0
- package/src/lib/svg-sanitize.ts +19 -9
- package/src/stories/Autocomplete.stories.tsx +2 -0
- package/src/stories/Canvas.stories.tsx +45 -0
- package/src/stories/ColorPicker.stories.tsx +40 -0
- package/src/stories/DataTable.stories.tsx +30 -0
- package/src/stories/DateField.stories.tsx +21 -0
- package/src/stories/Editable.stories.tsx +2 -0
- package/src/stories/FacetedFilter.stories.tsx +197 -0
- package/src/stories/GaugeChart.stories.tsx +9 -3
- package/src/stories/InlineEdit.stories.tsx +106 -0
- package/src/stories/MarkdownPreview.stories.tsx +53 -0
- package/src/stories/MonthPicker.stories.tsx +21 -0
- package/src/stories/NumberInput.stories.tsx +25 -0
- package/src/stories/OtpInput.stories.tsx +110 -0
- package/src/stories/PhoneInput.stories.tsx +127 -0
- package/src/stories/SearchInput.stories.tsx +2 -0
- package/src/stories/TagsInput.stories.tsx +2 -0
- package/src/stories/Timer.stories.tsx +26 -0
- package/src/stories/TransferList.stories.tsx +4 -0
- package/src/stories/WeekPicker.stories.tsx +21 -0
- package/src/stories/YearPicker.stories.tsx +21 -0
- package/src/stories/story-groups.json +22 -16
- package/src/tokens.json +82 -54
|
@@ -30,9 +30,15 @@ const meta: Meta<typeof GaugeChart> = {
|
|
|
30
30
|
export default meta
|
|
31
31
|
type Story = StoryObj<typeof meta>
|
|
32
32
|
|
|
33
|
-
// The entrance draw-in
|
|
34
|
-
//
|
|
35
|
-
//
|
|
33
|
+
// The entrance draw-in reads reduced-motion synchronously at mount (via
|
|
34
|
+
// hooks/use-reduced-motion's `prefersReducedMotion()`), not through the
|
|
35
|
+
// reactive `useReducedMotion()` hook ChartContainer and Sparkline use. The
|
|
36
|
+
// reactive hook starts `false` on every render and corrects a tick later;
|
|
37
|
+
// if that correction landed after react-smooth had already started tweening
|
|
38
|
+
// the value arc, Recharts froze on the near-zero-angle interpolated frame
|
|
39
|
+
// instead of jumping to the final one, so a reduced-motion user could see
|
|
40
|
+
// the value arc render as permanently invisible. Reading synchronously
|
|
41
|
+
// means a reduced-motion user gets the final arc immediately in every story.
|
|
36
42
|
export const Default: Story = {
|
|
37
43
|
render: (args) => (
|
|
38
44
|
<div className="w-48">
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import { InlineEdit } from "@behavioral-agentic-design-system/core/components/ui/inline-edit"
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof InlineEdit> = {
|
|
6
|
+
title: "Components/Forms/InlineEdit",
|
|
7
|
+
component: InlineEdit,
|
|
8
|
+
parameters: { layout: "centered" },
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default meta
|
|
13
|
+
type Story = StoryObj<typeof meta>
|
|
14
|
+
|
|
15
|
+
export const Default: Story = {
|
|
16
|
+
args: { defaultValue: "Click to edit me" },
|
|
17
|
+
render: (args) => (
|
|
18
|
+
<div className="w-64">
|
|
19
|
+
<InlineEdit {...args} />
|
|
20
|
+
</div>
|
|
21
|
+
),
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const Variant_Ghost: Story = {
|
|
25
|
+
args: { variant: "ghost", defaultValue: "Ghost variant" },
|
|
26
|
+
render: (args) => (
|
|
27
|
+
<div className="w-64">
|
|
28
|
+
<InlineEdit {...args} />
|
|
29
|
+
</div>
|
|
30
|
+
),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const Variant_Outline: Story = {
|
|
34
|
+
args: { variant: "outline", defaultValue: "Outline variant" },
|
|
35
|
+
render: (args) => (
|
|
36
|
+
<div className="w-64">
|
|
37
|
+
<InlineEdit {...args} />
|
|
38
|
+
</div>
|
|
39
|
+
),
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Size_Sm: Story = {
|
|
43
|
+
args: { size: "sm", defaultValue: "Small size" },
|
|
44
|
+
render: (args) => (
|
|
45
|
+
<div className="w-64">
|
|
46
|
+
<InlineEdit {...args} />
|
|
47
|
+
</div>
|
|
48
|
+
),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const Size_Default: Story = {
|
|
52
|
+
args: { size: "default", defaultValue: "Default size" },
|
|
53
|
+
render: (args) => (
|
|
54
|
+
<div className="w-64">
|
|
55
|
+
<InlineEdit {...args} />
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const Size_Lg: Story = {
|
|
61
|
+
args: { size: "lg", defaultValue: "Large size" },
|
|
62
|
+
render: (args) => (
|
|
63
|
+
<div className="w-64">
|
|
64
|
+
<InlineEdit {...args} />
|
|
65
|
+
</div>
|
|
66
|
+
),
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const Disabled: Story = {
|
|
70
|
+
args: { disabled: true, defaultValue: "Cannot edit" },
|
|
71
|
+
render: (args) => (
|
|
72
|
+
<div className="w-64">
|
|
73
|
+
<InlineEdit {...args} />
|
|
74
|
+
</div>
|
|
75
|
+
),
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const Empty: Story = {
|
|
79
|
+
args: { placeholder: "Enter a project name…" },
|
|
80
|
+
render: (args) => (
|
|
81
|
+
<div className="w-64">
|
|
82
|
+
<InlineEdit {...args} />
|
|
83
|
+
</div>
|
|
84
|
+
),
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const RealisticUse: Story = {
|
|
88
|
+
parameters: { controls: { disable: true } },
|
|
89
|
+
render: () => {
|
|
90
|
+
const [name, setName] = React.useState("Untitled project")
|
|
91
|
+
return (
|
|
92
|
+
<div className="flex w-72 flex-col gap-2">
|
|
93
|
+
<p className="text-muted-foreground text-xs">Project name</p>
|
|
94
|
+
<InlineEdit
|
|
95
|
+
value={name}
|
|
96
|
+
onConfirm={setName}
|
|
97
|
+
placeholder="Enter project name…"
|
|
98
|
+
variant="outline"
|
|
99
|
+
/>
|
|
100
|
+
<p className="text-muted-foreground text-xs">
|
|
101
|
+
Saved: <span className="text-foreground">{name}</span>
|
|
102
|
+
</p>
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
},
|
|
106
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { MarkdownPreview } from "@behavioral-agentic-design-system/core/components/markdown-preview";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof MarkdownPreview> = {
|
|
5
|
+
title: "Components/Content and data/MarkdownPreview",
|
|
6
|
+
component: MarkdownPreview,
|
|
7
|
+
parameters: { layout: "padded" },
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
args: {
|
|
16
|
+
source: "# Release notes\n\nThe canvas ships with **doc frames**.\n\n- Pan and zoom\n- Pin the spec\n\n## Next\n\nSee [the report](docs/prototype-spec-report.md).",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Headings carry an id built from their text, so a frame can scroll to a section. */
|
|
21
|
+
export const HeadingAnchors: Story = {
|
|
22
|
+
args: { source: "## Element inventory\n\nEvery drawn element.\n\n## Open questions\n\nOne per line." },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A `frame:` link calls onFrameLink instead of navigating. The canvas uses it to pan to
|
|
27
|
+
* the frame an inventory row names.
|
|
28
|
+
*/
|
|
29
|
+
export const FrameLink: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
source: "| Element | View |\n|---|---|\n| Card grid | [cards](frame:cards) |",
|
|
32
|
+
onFrameLink: () => {},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A table wider than its box scrolls sideways. The scroll region takes focus, so a
|
|
38
|
+
* keyboard user can reach the clipped columns (axe: scrollable-region-focusable).
|
|
39
|
+
*/
|
|
40
|
+
export const WideOverflowing: Story = {
|
|
41
|
+
decorators: [(Story) => <div className="w-[380px]"><Story /></div>],
|
|
42
|
+
args: {
|
|
43
|
+
source:
|
|
44
|
+
"| Element | Source | Built | Notes | View |\n|---|---|---|---|---|\n| Filter drawer, Sort by group | companion text, depth 2 | yes | Three options, ranked by distance, price, and rating. | listing-editorial |\n| Version number in footer | wireframe | deferred | Approved by Matthew on 2026-10-14. | |",
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const RealisticUse: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
source:
|
|
51
|
+
"# Spec\n\n## Open questions\n\n- Matthew: Should the dashboard ship a loading state before the first client review?\n- Kelsey: Does the share dialog need real event copy?\n",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -97,3 +97,24 @@ export const RealisticUse: Story = {
|
|
|
97
97
|
);
|
|
98
98
|
},
|
|
99
99
|
};
|
|
100
|
+
|
|
101
|
+
// Controlled from an empty state: `useState<Date>()` starts as undefined, which used to read as
|
|
102
|
+
// "uncontrolled", so a later Clear showed the first pick again.
|
|
103
|
+
export const ControlledStartsEmpty: Story = {
|
|
104
|
+
parameters: { controls: { disable: true } },
|
|
105
|
+
render: () => {
|
|
106
|
+
const [value, setValue] = useState<Date>()
|
|
107
|
+
return (
|
|
108
|
+
<div className="flex flex-col items-start gap-3">
|
|
109
|
+
<MonthPicker value={value} onChange={(v) => setValue(v)} />
|
|
110
|
+
<button
|
|
111
|
+
type="button"
|
|
112
|
+
className="min-h-11 rounded-md border px-4 text-sm font-medium"
|
|
113
|
+
onClick={() => setValue(undefined)}
|
|
114
|
+
>
|
|
115
|
+
Clear
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
118
|
+
)
|
|
119
|
+
},
|
|
120
|
+
}
|
|
@@ -49,6 +49,31 @@ export const Step: Story = {
|
|
|
49
49
|
name: "Step of 5",
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
// Stepping a fraction must not leak float noise (0.2 + 0.1 shows 0.3, not 0.30000000000000004).
|
|
53
|
+
export const DecimalStep: Story = {
|
|
54
|
+
render: () => <Controlled step={0.1} defaultValue={0.2} aria-label="Discount rate" />,
|
|
55
|
+
name: "Decimal step (0.1)",
|
|
56
|
+
parameters: { controls: { disable: true } },
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// A caller's onBlur runs alongside commit-on-blur instead of replacing it.
|
|
60
|
+
export const WithOnBlur: Story = {
|
|
61
|
+
parameters: { controls: { disable: true } },
|
|
62
|
+
render: () => {
|
|
63
|
+
const [seen, setSeen] = React.useState("none yet");
|
|
64
|
+
return (
|
|
65
|
+
<div className="flex flex-col gap-3">
|
|
66
|
+
<NumberInput
|
|
67
|
+
defaultValue={3}
|
|
68
|
+
aria-label="Seats"
|
|
69
|
+
onBlur={(e) => setSeen(e.currentTarget.value)}
|
|
70
|
+
/>
|
|
71
|
+
<p className="text-sm text-muted-foreground">Last blur saw: {seen}</p>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
52
77
|
// ─── Disabled ─────────────────────────────────────────────────────────────────
|
|
53
78
|
export const Disabled: Story = {
|
|
54
79
|
render: () => <NumberInput value={42} disabled aria-label="Quantity" />,
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { OTPInput } from "@behavioral-agentic-design-system/core/components/ui/otp-input";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof OTPInput> = {
|
|
6
|
+
title: "Components/Forms/OTPInput",
|
|
7
|
+
component: OTPInput,
|
|
8
|
+
parameters: { layout: "centered" },
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof meta>;
|
|
14
|
+
|
|
15
|
+
export const Default: Story = {
|
|
16
|
+
render: (args) => <OTPInput {...args} />,
|
|
17
|
+
args: { length: 6, numeric: true },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Size_Sm: Story = {
|
|
21
|
+
render: (args) => <OTPInput {...args} />,
|
|
22
|
+
args: { length: 6, size: "sm" },
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Size_Default: Story = {
|
|
26
|
+
render: (args) => <OTPInput {...args} />,
|
|
27
|
+
args: { length: 6, size: "default" },
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Size_Lg: Story = {
|
|
31
|
+
render: (args) => <OTPInput {...args} />,
|
|
32
|
+
args: { length: 6, size: "lg" },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const WithSeparator: Story = {
|
|
36
|
+
render: (args) => <OTPInput {...args} />,
|
|
37
|
+
args: { length: 6, separatorAfter: 2 },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const FourDigit: Story = {
|
|
41
|
+
render: (args) => <OTPInput {...args} />,
|
|
42
|
+
args: { length: 4, numeric: true },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const Alphanumeric: Story = {
|
|
46
|
+
render: (args) => <OTPInput {...args} />,
|
|
47
|
+
args: { length: 6, numeric: false },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Disabled: Story = {
|
|
51
|
+
render: (args) => <OTPInput {...args} />,
|
|
52
|
+
args: { length: 6, disabled: true, value: "123456" } as any,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Invalid: Story = {
|
|
56
|
+
render: (args) => <OTPInput {...args} />,
|
|
57
|
+
args: { length: 6, invalid: true, value: "12345" } as any,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const RealisticUse: Story = {
|
|
61
|
+
parameters: { controls: { disable: true } },
|
|
62
|
+
render: () => {
|
|
63
|
+
const [value, setValue] = React.useState("");
|
|
64
|
+
const [status, setStatus] = React.useState<"idle" | "verifying" | "success" | "error">("idle");
|
|
65
|
+
|
|
66
|
+
function handleComplete(v: string) {
|
|
67
|
+
setStatus("verifying");
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
setStatus(v === "000000" ? "error" : "success");
|
|
70
|
+
}, 800);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div className="flex flex-col items-center gap-4 text-center">
|
|
75
|
+
<div className="space-y-1">
|
|
76
|
+
<p className="text-sm font-medium text-foreground">Enter verification code</p>
|
|
77
|
+
<p className="text-sm text-muted-foreground">
|
|
78
|
+
Sent to elara.voss@designcraft.co
|
|
79
|
+
</p>
|
|
80
|
+
</div>
|
|
81
|
+
<OTPInput
|
|
82
|
+
value={value}
|
|
83
|
+
onChange={(v) => {
|
|
84
|
+
setValue(v);
|
|
85
|
+
if (status !== "idle") setStatus("idle");
|
|
86
|
+
}}
|
|
87
|
+
onComplete={handleComplete}
|
|
88
|
+
separatorAfter={2}
|
|
89
|
+
invalid={status === "error"}
|
|
90
|
+
disabled={status === "verifying" || status === "success"}
|
|
91
|
+
aria-label="Email verification code"
|
|
92
|
+
/>
|
|
93
|
+
{status === "verifying" && (
|
|
94
|
+
<p className="text-sm text-muted-foreground">Verifying…</p>
|
|
95
|
+
)}
|
|
96
|
+
{status === "success" && (
|
|
97
|
+
<p className="text-sm text-green-600 dark:text-green-400">Verified successfully</p>
|
|
98
|
+
)}
|
|
99
|
+
{status === "error" && (
|
|
100
|
+
<p className="text-sm text-destructive">Incorrect code. Try again.</p>
|
|
101
|
+
)}
|
|
102
|
+
{status === "idle" && value.length === 0 && (
|
|
103
|
+
<p className="text-xs text-muted-foreground">
|
|
104
|
+
Use <code className="rounded bg-muted px-1 py-0.5 font-mono text-xs">000000</code> to test error state
|
|
105
|
+
</p>
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { PhoneInput } from "@behavioral-agentic-design-system/core/components/ui/phone-input";
|
|
4
|
+
import {
|
|
5
|
+
Field,
|
|
6
|
+
FieldLabel,
|
|
7
|
+
FieldHelper,
|
|
8
|
+
FieldError,
|
|
9
|
+
} from "@behavioral-agentic-design-system/core/components/ui/field";
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof PhoneInput> = {
|
|
12
|
+
title: "Components/Forms/PhoneInput",
|
|
13
|
+
component: PhoneInput,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "centered",
|
|
16
|
+
},
|
|
17
|
+
tags: ["autodocs"],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
export const Default: Story = {
|
|
24
|
+
args: {
|
|
25
|
+
"aria-label": "Phone number",
|
|
26
|
+
defaultCountry: "US",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const WithValue: Story = {
|
|
31
|
+
name: "With value (controlled)",
|
|
32
|
+
parameters: { controls: { disable: true } },
|
|
33
|
+
render: () => {
|
|
34
|
+
const [phone, setPhone] = React.useState("+14155550182");
|
|
35
|
+
return (
|
|
36
|
+
<div className="w-72">
|
|
37
|
+
<PhoneInput
|
|
38
|
+
aria-label="Phone number"
|
|
39
|
+
value={phone}
|
|
40
|
+
onChange={setPhone}
|
|
41
|
+
/>
|
|
42
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
43
|
+
E.164: <code className="font-mono">{phone || "(empty)"}</code>
|
|
44
|
+
</p>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Disabled: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
"aria-label": "Phone number",
|
|
53
|
+
disabled: true,
|
|
54
|
+
defaultCountry: "GB",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const Error: Story = {
|
|
59
|
+
name: "Error state",
|
|
60
|
+
parameters: { controls: { disable: true } },
|
|
61
|
+
render: () => (
|
|
62
|
+
<div className="w-72">
|
|
63
|
+
<Field name="phone" invalid>
|
|
64
|
+
<FieldLabel>Phone number</FieldLabel>
|
|
65
|
+
<PhoneInput id="phone" aria-label="Phone number" error defaultCountry="US" />
|
|
66
|
+
<FieldError>Please enter a valid phone number.</FieldError>
|
|
67
|
+
</Field>
|
|
68
|
+
</div>
|
|
69
|
+
),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Canada and the United States share +1. A controlled field must keep the country the user picked, and
|
|
73
|
+
// emit digits only: typing "(415) 555-0182" reports "+14155550182".
|
|
74
|
+
export const ControlledKeepsCountry: Story = {
|
|
75
|
+
name: "Controlled, keeps Canada, emits E.164",
|
|
76
|
+
parameters: { controls: { disable: true } },
|
|
77
|
+
render: () => {
|
|
78
|
+
const [value, setValue] = React.useState("");
|
|
79
|
+
return (
|
|
80
|
+
<div className="flex w-80 flex-col gap-3">
|
|
81
|
+
<PhoneInput aria-label="Mobile number" value={value} onChange={setValue} name="phone" />
|
|
82
|
+
<p className="text-sm text-muted-foreground">Value: {value || "empty"}</p>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const DifferentCountries: Story = {
|
|
89
|
+
name: "Different default countries",
|
|
90
|
+
parameters: { controls: { disable: true } },
|
|
91
|
+
render: () => (
|
|
92
|
+
<div className="flex w-80 flex-col gap-3">
|
|
93
|
+
<PhoneInput aria-label="UK number" defaultCountry="GB" />
|
|
94
|
+
<PhoneInput aria-label="Australian number" defaultCountry="AU" />
|
|
95
|
+
<PhoneInput aria-label="German number" defaultCountry="DE" />
|
|
96
|
+
<PhoneInput aria-label="Brazilian number" defaultCountry="BR" />
|
|
97
|
+
</div>
|
|
98
|
+
),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const RealisticUse: Story = {
|
|
102
|
+
name: "Realistic use: account settings — Jordan Reeves",
|
|
103
|
+
parameters: { controls: { disable: true } },
|
|
104
|
+
render: () => {
|
|
105
|
+
const [phone, setPhone] = React.useState("+14155550182");
|
|
106
|
+
return (
|
|
107
|
+
<div className="w-80">
|
|
108
|
+
<Field name="phone-realistic">
|
|
109
|
+
<FieldLabel>Phone number</FieldLabel>
|
|
110
|
+
<PhoneInput
|
|
111
|
+
id="phone-realistic"
|
|
112
|
+
aria-label="Phone number"
|
|
113
|
+
value={phone}
|
|
114
|
+
onChange={setPhone}
|
|
115
|
+
defaultCountry="US"
|
|
116
|
+
/>
|
|
117
|
+
<FieldHelper>
|
|
118
|
+
Used for two-factor authentication and account recovery.
|
|
119
|
+
</FieldHelper>
|
|
120
|
+
</Field>
|
|
121
|
+
<p className="mt-3 text-xs text-muted-foreground">
|
|
122
|
+
Stored value: <code className="font-mono">{phone || "(empty)"}</code>
|
|
123
|
+
</p>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
},
|
|
127
|
+
};
|
|
@@ -103,6 +103,8 @@ export const Loading: Story = {
|
|
|
103
103
|
),
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
// Enter pressed to confirm an IME candidate (Japanese, Chinese, Korean) is ignored by this component.
|
|
107
|
+
// Not scriptable in a story; check by hand with an IME on.
|
|
106
108
|
export const RealisticUse: Story = {
|
|
107
109
|
decorators: [
|
|
108
110
|
(Story) => (
|
|
@@ -166,6 +166,8 @@ export const Empty: Story = {
|
|
|
166
166
|
};
|
|
167
167
|
|
|
168
168
|
// Realistic use: design system docs, article tag filter
|
|
169
|
+
// Enter pressed to confirm an IME candidate (Japanese, Chinese, Korean) is ignored by this component.
|
|
170
|
+
// Not scriptable in a story; check by hand with an IME on.
|
|
169
171
|
export const RealisticUse: Story = {
|
|
170
172
|
render: () => {
|
|
171
173
|
const [tags, setTags] = React.useState<string[]>(["Accessibility", "Tokens"]);
|
|
@@ -116,6 +116,32 @@ export const FormatMM_SS: Story = {
|
|
|
116
116
|
),
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
export const Variant_Completed: Story = {
|
|
120
|
+
name: "Variant — Completed (zero)",
|
|
121
|
+
render: function CompletedStory() {
|
|
122
|
+
const [completed, setCompleted] = React.useState(false);
|
|
123
|
+
return (
|
|
124
|
+
<div className="flex flex-col items-center gap-3">
|
|
125
|
+
<Timer
|
|
126
|
+
mode="countdown"
|
|
127
|
+
startMs={0}
|
|
128
|
+
completeAnnouncement="Time is up"
|
|
129
|
+
onComplete={() => setCompleted(true)}
|
|
130
|
+
className="text-2xl"
|
|
131
|
+
/>
|
|
132
|
+
{completed && (
|
|
133
|
+
<p className="text-sm text-muted-foreground">onComplete fired</p>
|
|
134
|
+
)}
|
|
135
|
+
<p className="text-sm text-muted-foreground max-w-xs text-center">
|
|
136
|
+
Timer at zero: the screen reader gets a single polite announcement via
|
|
137
|
+
a one-shot role=status element that mounts on completion and is
|
|
138
|
+
annotated with allow-conditional-aria-live.
|
|
139
|
+
</p>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
119
145
|
// Real content from content/personas/bads.json (primary persona pool).
|
|
120
146
|
export const RealisticUse: Story = {
|
|
121
147
|
render: function RealisticUseStory() {
|
|
@@ -63,6 +63,10 @@ export const Default: Story = {
|
|
|
63
63
|
),
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// The checked-state visual (corrections.md #026 — was a hand-rolled div
|
|
67
|
+
// rendering as a circle, not a checkbox) doesn't need its own story: unlike
|
|
68
|
+
// FacetedFilter's popover, these rows render directly, so initialSelected
|
|
69
|
+
// below already puts real checked Checkbox primitives in front of Chromatic.
|
|
66
70
|
export const WithSearch: Story = {
|
|
67
71
|
render: () => (
|
|
68
72
|
<ControlledTransferList
|
|
@@ -88,3 +88,24 @@ export const RealisticUse: Story = {
|
|
|
88
88
|
)
|
|
89
89
|
},
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
// Controlled from an empty state: `useState<Date>()` starts as undefined, which used to read as
|
|
93
|
+
// "uncontrolled", so a later Clear showed the first pick again.
|
|
94
|
+
export const ControlledStartsEmpty: Story = {
|
|
95
|
+
parameters: { controls: { disable: true } },
|
|
96
|
+
render: () => {
|
|
97
|
+
const [value, setValue] = React.useState<Date>()
|
|
98
|
+
return (
|
|
99
|
+
<div className="flex flex-col items-start gap-3">
|
|
100
|
+
<WeekPicker value={value} onValueChange={(v) => setValue(v)} />
|
|
101
|
+
<button
|
|
102
|
+
type="button"
|
|
103
|
+
className="min-h-11 rounded-md border px-4 text-sm font-medium"
|
|
104
|
+
onClick={() => setValue(undefined)}
|
|
105
|
+
>
|
|
106
|
+
Clear
|
|
107
|
+
</button>
|
|
108
|
+
</div>
|
|
109
|
+
)
|
|
110
|
+
},
|
|
111
|
+
}
|
|
@@ -98,3 +98,24 @@ export const RealisticUse: Story = {
|
|
|
98
98
|
);
|
|
99
99
|
},
|
|
100
100
|
};
|
|
101
|
+
|
|
102
|
+
// Controlled from an empty state: `useState<number>()` starts as undefined, which used to read as
|
|
103
|
+
// "uncontrolled", so a later Clear showed the first pick again.
|
|
104
|
+
export const ControlledStartsEmpty: Story = {
|
|
105
|
+
parameters: { controls: { disable: true } },
|
|
106
|
+
render: () => {
|
|
107
|
+
const [value, setValue] = useState<number>()
|
|
108
|
+
return (
|
|
109
|
+
<div className="flex flex-col items-start gap-3">
|
|
110
|
+
<YearPicker value={value} onValueChange={(v) => setValue(v)} />
|
|
111
|
+
<button
|
|
112
|
+
type="button"
|
|
113
|
+
className="min-h-11 rounded-md border px-4 text-sm font-medium"
|
|
114
|
+
onClick={() => setValue(undefined)}
|
|
115
|
+
>
|
|
116
|
+
Clear
|
|
117
|
+
</button>
|
|
118
|
+
</div>
|
|
119
|
+
)
|
|
120
|
+
},
|
|
121
|
+
}
|
|
@@ -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
|
|
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
|
"",
|
|
@@ -36,25 +36,28 @@
|
|
|
36
36
|
"Clipboard"
|
|
37
37
|
],
|
|
38
38
|
"Forms": [
|
|
39
|
+
"Editable",
|
|
40
|
+
"Field",
|
|
41
|
+
"Fieldset",
|
|
42
|
+
"FileUpload",
|
|
43
|
+
"FloatLabel",
|
|
44
|
+
"InlineEdit",
|
|
39
45
|
"Input",
|
|
40
|
-
"InputGroup",
|
|
41
46
|
"InputClearButton",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
47
|
+
"InputGroup",
|
|
48
|
+
"JsonInput",
|
|
49
|
+
"Label",
|
|
50
|
+
"NumberInput",
|
|
51
|
+
"OTPInput",
|
|
44
52
|
"PasswordInput",
|
|
45
53
|
"PasswordStrengthInput",
|
|
46
|
-
"
|
|
54
|
+
"PhoneInput",
|
|
47
55
|
"PinInput",
|
|
48
|
-
"TagsInput",
|
|
49
|
-
"Editable",
|
|
50
|
-
"Field",
|
|
51
|
-
"Fieldset",
|
|
52
|
-
"Label",
|
|
53
|
-
"FloatLabel",
|
|
54
|
-
"FileUpload",
|
|
55
|
-
"SignaturePad",
|
|
56
56
|
"Questionnaire",
|
|
57
|
-
"
|
|
57
|
+
"SearchInput",
|
|
58
|
+
"SignaturePad",
|
|
59
|
+
"TagsInput",
|
|
60
|
+
"Textarea"
|
|
58
61
|
],
|
|
59
62
|
"Selection": [
|
|
60
63
|
"Select",
|
|
@@ -158,11 +161,13 @@
|
|
|
158
161
|
"Carousel",
|
|
159
162
|
"Card",
|
|
160
163
|
"PageHeader",
|
|
161
|
-
"SortableList"
|
|
164
|
+
"SortableList",
|
|
165
|
+
"Canvas"
|
|
162
166
|
],
|
|
163
167
|
"Content and data": [
|
|
164
168
|
"Table",
|
|
165
169
|
"DataTable",
|
|
170
|
+
"FacetedFilter",
|
|
166
171
|
"DataList",
|
|
167
172
|
"Chart",
|
|
168
173
|
"Timeline",
|
|
@@ -188,7 +193,8 @@
|
|
|
188
193
|
"Icon",
|
|
189
194
|
"ProgressStack",
|
|
190
195
|
"GaugeChart",
|
|
191
|
-
"Heatmap"
|
|
196
|
+
"Heatmap",
|
|
197
|
+
"MarkdownPreview"
|
|
192
198
|
],
|
|
193
199
|
"Badges and avatars": [
|
|
194
200
|
"Avatar",
|