@behavioral-agentic-design-system/core 0.27.0 → 0.29.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 +5 -5
- package/scripts/a11y-lint.cjs +78 -9
- package/scripts/build-tokens.cjs +273 -15
- package/scripts/wcag-audit.cjs +37 -7
- package/src/api/layers/file.ts +1 -0
- package/src/app/font-ready.tsx +6 -5
- package/src/app/layout.tsx +54 -3
- package/src/app/preview/components/page.tsx +5735 -2500
- package/src/app/preview/layout.tsx +4 -1
- package/src/app/preview/showcase-filter.tsx +66 -0
- package/src/app/preview/tab-replay.tsx +63 -0
- package/src/app/shell.tsx +91 -18
- package/src/components/customize/save-bar.tsx +19 -6
- package/src/components/docs-tab.tsx +36 -24
- package/src/components/layers-tab.tsx +37 -5
- package/src/components/ui/ai-badge.tsx +74 -0
- package/src/components/ui/alert.tsx +12 -0
- package/src/components/ui/badge.tsx +19 -0
- package/src/components/ui/chat-bubble.tsx +298 -0
- package/src/components/ui/chat-marker.tsx +120 -0
- package/src/components/ui/checkbox.tsx +9 -1
- package/src/components/ui/clipboard.tsx +291 -0
- package/src/components/ui/close-button.tsx +71 -0
- package/src/components/ui/combobox.tsx +62 -3
- package/src/components/ui/container.tsx +65 -0
- package/src/components/ui/copy-button.tsx +5 -1
- package/src/components/ui/data-table.tsx +388 -0
- package/src/components/ui/date-field.tsx +368 -0
- package/src/components/ui/drawer.tsx +334 -0
- package/src/components/ui/file-button.tsx +145 -0
- package/src/components/ui/floating-indicator.tsx +217 -0
- package/src/components/ui/focus-trap.tsx +184 -0
- package/src/components/ui/format-byte.tsx +113 -0
- package/src/components/ui/index.ts +28 -0
- package/src/components/ui/input.tsx +38 -3
- package/src/components/ui/keyboard-shortcut.tsx +146 -0
- package/src/components/ui/loading-dots.tsx +99 -0
- package/src/components/ui/mark.tsx +69 -0
- package/src/components/ui/month-picker.tsx +296 -0
- package/src/components/ui/multi-select.tsx +15 -13
- package/src/components/ui/nav-link.tsx +200 -0
- package/src/components/ui/navigation-rail.tsx +256 -0
- package/src/components/ui/notification.tsx +20 -0
- package/src/components/ui/password-input.tsx +34 -1
- package/src/components/ui/progress.tsx +15 -1
- package/src/components/ui/prose.tsx +62 -0
- package/src/components/ui/result.tsx +151 -0
- package/src/components/ui/rolling-number.tsx +201 -0
- package/src/components/ui/simple-grid.tsx +110 -0
- package/src/components/ui/skeleton.tsx +52 -3
- package/src/components/ui/squircle.tsx +274 -0
- package/src/components/ui/stack.tsx +105 -0
- package/src/components/ui/status-badge.tsx +93 -0
- package/src/components/ui/tabs.tsx +34 -7
- package/src/components/ui/tag.tsx +46 -5
- package/src/components/ui/theme-icon.tsx +138 -0
- package/src/components/ui/timeline.tsx +27 -10
- package/src/components/ui/tooltip.tsx +12 -1
- package/src/components/ui/tree-select.tsx +386 -0
- package/src/components/ui/typing-indicator.tsx +2 -2
- package/src/components/ui/word-rotate.tsx +6 -1
- package/src/components/ui/year-picker.tsx +307 -0
- package/src/data/docs-index.ts +10 -0
- package/src/hooks/use-global-primary-color.ts +57 -6
- package/src/stories/AiBadge.stories.tsx +67 -0
- package/src/stories/Alert.stories.tsx +31 -1
- package/src/stories/Badge.stories.tsx +63 -6
- package/src/stories/ChatBubble.stories.tsx +222 -0
- package/src/stories/ChatMarker.stories.tsx +59 -0
- package/src/stories/Checkbox.stories.tsx +5 -0
- package/src/stories/Clipboard.stories.tsx +136 -0
- package/src/stories/CloseButton.stories.tsx +65 -0
- package/src/stories/Combobox.stories.tsx +74 -3
- package/src/stories/Container.stories.tsx +134 -0
- package/src/stories/CopyButton.stories.tsx +2 -0
- package/src/stories/DataTable.stories.tsx +271 -0
- package/src/stories/DateField.stories.tsx +114 -0
- package/src/stories/Drawer.stories.tsx +211 -0
- package/src/stories/FileButton.stories.tsx +117 -0
- package/src/stories/FloatingIndicator.stories.tsx +343 -0
- package/src/stories/FocusTrap.stories.tsx +218 -0
- package/src/stories/FormatByte.stories.tsx +142 -0
- package/src/stories/Input.stories.tsx +91 -0
- package/src/stories/KeyboardShortcut.stories.tsx +87 -0
- package/src/stories/LoadingDots.stories.tsx +73 -0
- package/src/stories/Mark.stories.tsx +84 -0
- package/src/stories/MonthPicker.stories.tsx +99 -0
- package/src/stories/MultiSelect.stories.tsx +3 -1
- package/src/stories/NavLink.stories.tsx +213 -0
- package/src/stories/NavigationRail.stories.tsx +413 -0
- package/src/stories/Notification.stories.tsx +53 -0
- package/src/stories/PasswordInput.stories.tsx +21 -0
- package/src/stories/Progress.stories.tsx +38 -0
- package/src/stories/Prose.stories.tsx +232 -0
- package/src/stories/Result.stories.tsx +145 -0
- package/src/stories/RollingNumber.stories.tsx +226 -0
- package/src/stories/SimpleGrid.stories.tsx +130 -0
- package/src/stories/Skeleton.stories.tsx +62 -1
- package/src/stories/Squircle.stories.tsx +127 -0
- package/src/stories/Stack.stories.tsx +139 -0
- package/src/stories/StatusBadge.stories.tsx +125 -0
- package/src/stories/Tabs.stories.tsx +56 -1
- package/src/stories/Tag.stories.tsx +31 -0
- package/src/stories/ThemeIcon.stories.tsx +97 -0
- package/src/stories/Timeline.stories.tsx +69 -0
- package/src/stories/Tooltip.stories.tsx +18 -0
- package/src/stories/TreeSelect.stories.tsx +222 -0
- package/src/stories/TypingIndicator.stories.tsx +1 -0
- package/src/stories/WordRotate.stories.tsx +1 -0
- package/src/stories/YearPicker.stories.tsx +100 -0
- package/src/styles.css +289 -15
- package/src/tokens.json +96 -1
- package/LICENSE +0 -21
|
@@ -32,9 +32,11 @@ export * from "./hover-card";
|
|
|
32
32
|
export * from "./input";
|
|
33
33
|
export * from "./input-group";
|
|
34
34
|
export * from "./kbd";
|
|
35
|
+
export * from "./keyboard-shortcut";
|
|
35
36
|
export * from "./label";
|
|
36
37
|
export * from "./link";
|
|
37
38
|
export * from "./menubar";
|
|
39
|
+
export * from "./month-picker";
|
|
38
40
|
export * from "./motion-toggle";
|
|
39
41
|
export * from "./navigation-menu";
|
|
40
42
|
export * from "./notification";
|
|
@@ -71,6 +73,7 @@ export * from "./toggle-group";
|
|
|
71
73
|
export * from "./toolbar";
|
|
72
74
|
export * from "./tooltip";
|
|
73
75
|
export * from "./tree-view";
|
|
76
|
+
export * from "./tree-select";
|
|
74
77
|
export * from "./editable";
|
|
75
78
|
export * from "./qr-code";
|
|
76
79
|
export * from "./highlight";
|
|
@@ -100,6 +103,7 @@ export * from "./burger";
|
|
|
100
103
|
export * from "./action-bar";
|
|
101
104
|
export * from "./checkbox-card";
|
|
102
105
|
export * from "./watermark";
|
|
106
|
+
export * from "./loading-dots";
|
|
103
107
|
export * from "./loading-overlay";
|
|
104
108
|
export * from "./float-label";
|
|
105
109
|
export * from "./tour";
|
|
@@ -115,3 +119,27 @@ export * from "./skip-link";
|
|
|
115
119
|
export * from "./timer";
|
|
116
120
|
export * from "./signature-pad";
|
|
117
121
|
export * from "./floating-action-button";
|
|
122
|
+
export * from "./clipboard";
|
|
123
|
+
export * from "./chat-bubble";
|
|
124
|
+
export * from "./chat-marker";
|
|
125
|
+
export * from "./data-table";
|
|
126
|
+
export * from "./focus-trap";
|
|
127
|
+
export * from "./mark";
|
|
128
|
+
export * from "./rolling-number";
|
|
129
|
+
export * from "./ai-badge";
|
|
130
|
+
export * from "./prose";
|
|
131
|
+
export * from "./result";
|
|
132
|
+
export * from "./navigation-rail";
|
|
133
|
+
export * from "./squircle";
|
|
134
|
+
export * from "./drawer";
|
|
135
|
+
export * from "./floating-indicator";
|
|
136
|
+
export * from "./nav-link";
|
|
137
|
+
export * from "./year-picker";
|
|
138
|
+
export * from "./format-byte";
|
|
139
|
+
export * from "./file-button";
|
|
140
|
+
export * from "./theme-icon";
|
|
141
|
+
export * from "./date-field";
|
|
142
|
+
export * from "./stack";
|
|
143
|
+
export * from "./container";
|
|
144
|
+
export * from "./simple-grid";
|
|
145
|
+
export * from "./close-button";
|
|
@@ -27,6 +27,13 @@ type InputProps = Omit<React.ComponentProps<"input">, "size"> &
|
|
|
27
27
|
/** When true, shows a dismiss (×) button on the right when the input has a value.
|
|
28
28
|
* Calls onChange with an empty string on click. Only meaningful for controlled inputs. */
|
|
29
29
|
clearable?: boolean
|
|
30
|
+
/** Content rendered inside the field boundary, left of the text caret (icon, "$", …).
|
|
31
|
+
* Pointer-events are disabled on the slot; add `pointer-events-auto` to interactive
|
|
32
|
+
* children. Purely decorative content should carry `aria-hidden="true"`. */
|
|
33
|
+
leftSection?: React.ReactNode
|
|
34
|
+
/** Content rendered inside the field boundary, right of the text caret (icon, unit, …).
|
|
35
|
+
* Same pointer-events / aria-hidden guidance as `leftSection`. */
|
|
36
|
+
rightSection?: React.ReactNode
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
function Input({
|
|
@@ -34,19 +41,28 @@ function Input({
|
|
|
34
41
|
type,
|
|
35
42
|
size,
|
|
36
43
|
clearable,
|
|
44
|
+
leftSection,
|
|
45
|
+
rightSection,
|
|
37
46
|
value,
|
|
38
47
|
onChange,
|
|
39
48
|
disabled,
|
|
40
49
|
...props
|
|
41
50
|
}: InputProps) {
|
|
42
51
|
const showClear = clearable && !disabled && value !== undefined && value !== ""
|
|
52
|
+
const hasWrapper = Boolean(clearable || leftSection || rightSection)
|
|
43
53
|
|
|
44
54
|
const inputEl = (
|
|
45
55
|
<input
|
|
46
56
|
type={type}
|
|
47
57
|
data-slot="input"
|
|
48
58
|
data-size={size ?? "default"}
|
|
49
|
-
className={cn(
|
|
59
|
+
className={cn(
|
|
60
|
+
inputVariants({ size, className }),
|
|
61
|
+
clearable && "pr-8",
|
|
62
|
+
leftSection && "pl-9",
|
|
63
|
+
rightSection && "pr-9",
|
|
64
|
+
clearable && rightSection && "pr-14"
|
|
65
|
+
)}
|
|
50
66
|
value={value}
|
|
51
67
|
onChange={onChange}
|
|
52
68
|
disabled={disabled}
|
|
@@ -54,18 +70,37 @@ function Input({
|
|
|
54
70
|
/>
|
|
55
71
|
)
|
|
56
72
|
|
|
57
|
-
if (!
|
|
73
|
+
if (!hasWrapper) {
|
|
58
74
|
return inputEl
|
|
59
75
|
}
|
|
60
76
|
|
|
61
77
|
return (
|
|
62
78
|
<div className="relative">
|
|
79
|
+
{leftSection && (
|
|
80
|
+
<div
|
|
81
|
+
data-slot="input-left-section"
|
|
82
|
+
className="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3 text-muted-foreground"
|
|
83
|
+
>
|
|
84
|
+
{leftSection}
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
63
87
|
{inputEl}
|
|
88
|
+
{rightSection && (
|
|
89
|
+
<div
|
|
90
|
+
data-slot="input-right-section"
|
|
91
|
+
className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3 text-muted-foreground"
|
|
92
|
+
>
|
|
93
|
+
{rightSection}
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
64
96
|
{showClear && (
|
|
65
97
|
<button
|
|
66
98
|
type="button"
|
|
67
99
|
aria-label="Clear input"
|
|
68
|
-
className=
|
|
100
|
+
className={cn(
|
|
101
|
+
"absolute top-1/2 -translate-y-1/2 inline-flex items-center justify-center size-6 rounded text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",
|
|
102
|
+
rightSection ? "right-8" : "right-1.5"
|
|
103
|
+
)}
|
|
69
104
|
style={{
|
|
70
105
|
transitionDuration: "var(--duration-fast)",
|
|
71
106
|
transitionTimingFunction: "var(--ease-out)",
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* KeyboardShortcut — displays a keyboard shortcut as a sequence of Kbd keys
|
|
5
|
+
* separated by a "+" or "then" separator.
|
|
6
|
+
*
|
|
7
|
+
* Composes the existing Kbd primitive. Handles platform-specific modifier
|
|
8
|
+
* symbols (⌘, ⌃, ⌥, ⇧ on Mac; Ctrl, Alt, Shift on Windows/Linux).
|
|
9
|
+
*
|
|
10
|
+
* Sources: Linear, Raycast, VS Code, GitHub command palette shortcut display
|
|
11
|
+
* patterns. Kbd is the single-key primitive; KeyboardShortcut is the
|
|
12
|
+
* multi-key composition with correct semantic markup and platform awareness.
|
|
13
|
+
*
|
|
14
|
+
* Accessibility: wraps in <kbd> with aria-label describing the full
|
|
15
|
+
* combination in plain text so screen readers announce "Command K" rather
|
|
16
|
+
* than reading each symbol separately.
|
|
17
|
+
*
|
|
18
|
+
* Motion: none — shortcut labels are presentational, no interaction.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import * as React from "react"
|
|
22
|
+
|
|
23
|
+
import { cn } from "../../lib/utils"
|
|
24
|
+
import { Kbd, type KbdProps } from "./kbd"
|
|
25
|
+
|
|
26
|
+
/** Canonical key names that map to platform-specific display symbols. */
|
|
27
|
+
export type ModifierKey = "meta" | "ctrl" | "alt" | "shift"
|
|
28
|
+
|
|
29
|
+
const macSymbols: Record<ModifierKey, string> = {
|
|
30
|
+
meta: "⌘",
|
|
31
|
+
ctrl: "⌃",
|
|
32
|
+
alt: "⌥",
|
|
33
|
+
shift: "⇧",
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const windowsLabels: Record<ModifierKey, string> = {
|
|
37
|
+
meta: "Win",
|
|
38
|
+
ctrl: "Ctrl",
|
|
39
|
+
alt: "Alt",
|
|
40
|
+
shift: "Shift",
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isModifier(key: string): key is ModifierKey {
|
|
44
|
+
return key === "meta" || key === "ctrl" || key === "alt" || key === "shift"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface KeyboardShortcutProps extends React.ComponentProps<"kbd"> {
|
|
48
|
+
/**
|
|
49
|
+
* Array of key strings. Use lowercase modifier names ("meta", "ctrl",
|
|
50
|
+
* "alt", "shift") and literal key characters ("K", "Enter", "Tab", "↑").
|
|
51
|
+
* Order: modifiers first, then the main key.
|
|
52
|
+
* @example ["meta", "K"] → ⌘K
|
|
53
|
+
* @example ["ctrl", "shift", "P"] → Ctrl+Shift+P
|
|
54
|
+
*/
|
|
55
|
+
keys: string[]
|
|
56
|
+
/**
|
|
57
|
+
* Separator rendered between keys.
|
|
58
|
+
* @default "+"
|
|
59
|
+
*/
|
|
60
|
+
separator?: string
|
|
61
|
+
/**
|
|
62
|
+
* Controls modifier display style.
|
|
63
|
+
* - "mac" renders ⌘⌃⌥⇧ symbols (default)
|
|
64
|
+
* - "windows" renders Ctrl/Alt/Shift/Win labels
|
|
65
|
+
* - "auto" detects via navigator.platform (SSR-safe: falls back to "mac")
|
|
66
|
+
*/
|
|
67
|
+
platform?: "mac" | "windows" | "auto"
|
|
68
|
+
/** Size forwarded to each Kbd element. */
|
|
69
|
+
size?: KbdProps["size"]
|
|
70
|
+
/** Variant forwarded to each Kbd element. */
|
|
71
|
+
variant?: KbdProps["variant"]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function resolveKey(
|
|
75
|
+
key: string,
|
|
76
|
+
platform: "mac" | "windows"
|
|
77
|
+
): string {
|
|
78
|
+
if (isModifier(key)) {
|
|
79
|
+
return platform === "mac" ? macSymbols[key] : windowsLabels[key]
|
|
80
|
+
}
|
|
81
|
+
return key
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function buildAriaLabel(keys: string[]): string {
|
|
85
|
+
return keys
|
|
86
|
+
.map((k) =>
|
|
87
|
+
isModifier(k)
|
|
88
|
+
? k === "meta"
|
|
89
|
+
? "Command"
|
|
90
|
+
: k === "ctrl"
|
|
91
|
+
? "Control"
|
|
92
|
+
: k === "alt"
|
|
93
|
+
? "Alt"
|
|
94
|
+
: "Shift"
|
|
95
|
+
: k
|
|
96
|
+
)
|
|
97
|
+
.join(" ")
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function KeyboardShortcut({
|
|
101
|
+
keys,
|
|
102
|
+
separator = "+",
|
|
103
|
+
platform = "mac",
|
|
104
|
+
size,
|
|
105
|
+
variant,
|
|
106
|
+
className,
|
|
107
|
+
...props
|
|
108
|
+
}: KeyboardShortcutProps) {
|
|
109
|
+
const resolvedPlatform: "mac" | "windows" =
|
|
110
|
+
platform === "auto"
|
|
111
|
+
? typeof navigator !== "undefined" &&
|
|
112
|
+
navigator.platform.toLowerCase().includes("win")
|
|
113
|
+
? "windows"
|
|
114
|
+
: "mac"
|
|
115
|
+
: platform
|
|
116
|
+
|
|
117
|
+
const displayKeys = keys.map((k) => resolveKey(k, resolvedPlatform))
|
|
118
|
+
const ariaLabel = buildAriaLabel(keys)
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<kbd
|
|
122
|
+
aria-label={ariaLabel}
|
|
123
|
+
data-slot="keyboard-shortcut"
|
|
124
|
+
className={cn("inline-flex items-center gap-0.5", className)}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
{displayKeys.map((key, i) => (
|
|
128
|
+
<React.Fragment key={i}>
|
|
129
|
+
{i > 0 && (
|
|
130
|
+
<span
|
|
131
|
+
aria-hidden="true"
|
|
132
|
+
className="text-[0.65em] text-muted-foreground select-none"
|
|
133
|
+
>
|
|
134
|
+
{separator}
|
|
135
|
+
</span>
|
|
136
|
+
)}
|
|
137
|
+
<Kbd size={size} variant={variant}>
|
|
138
|
+
{key}
|
|
139
|
+
</Kbd>
|
|
140
|
+
</React.Fragment>
|
|
141
|
+
))}
|
|
142
|
+
</kbd>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { KeyboardShortcut }
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LoadingDots — three-dot inline loading indicator for async states.
|
|
5
|
+
*
|
|
6
|
+
* Distinct from TypingIndicator (chat-specific "person is typing" widget).
|
|
7
|
+
* LoadingDots is a general-purpose inline spinner substitute — used inside
|
|
8
|
+
* buttons during submission, in list placeholders, in nav items that are
|
|
9
|
+
* fetching, and anywhere a compact animated signal replaces a full spinner.
|
|
10
|
+
*
|
|
11
|
+
* Sources: common cross-library pattern (GitHub, Vercel, Linear, Notion);
|
|
12
|
+
* inline button-loading convention established in shadcn/ui + Base UI.
|
|
13
|
+
*
|
|
14
|
+
* Motion (spec §4):
|
|
15
|
+
* - reuses the `typing-dot` @keyframe from styles.css (pattern b delivery,
|
|
16
|
+
* keyed off [data-slot="chat-bubble-typing"] → we use the same keyframe
|
|
17
|
+
* by name, with inline animationDelay per dot for stagger — pattern c).
|
|
18
|
+
* - reduced-motion: base layer forces animation-duration to 0.01ms.
|
|
19
|
+
*
|
|
20
|
+
* Accessibility: aria-label defaults to "Loading" — override when the
|
|
21
|
+
* context is more specific ("Saving", "Sending"). role="status" surfaces
|
|
22
|
+
* it as a live region so screen readers announce the state.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import * as React from "react"
|
|
26
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
27
|
+
|
|
28
|
+
import { cn } from "../../lib/utils"
|
|
29
|
+
|
|
30
|
+
const loadingDotsVariants = cva(
|
|
31
|
+
"inline-flex items-center gap-[0.2em]",
|
|
32
|
+
{
|
|
33
|
+
variants: {
|
|
34
|
+
size: {
|
|
35
|
+
xs: "h-3",
|
|
36
|
+
sm: "h-4",
|
|
37
|
+
default: "h-5",
|
|
38
|
+
lg: "h-6",
|
|
39
|
+
},
|
|
40
|
+
tone: {
|
|
41
|
+
current: "",
|
|
42
|
+
muted: "text-muted-foreground",
|
|
43
|
+
primary: "text-primary",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
defaultVariants: {
|
|
47
|
+
size: "default",
|
|
48
|
+
tone: "current",
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
const dotSizeMap: Record<string, string> = {
|
|
54
|
+
xs: "size-1",
|
|
55
|
+
sm: "size-1.5",
|
|
56
|
+
default: "size-2",
|
|
57
|
+
lg: "size-2.5",
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface LoadingDotsProps
|
|
61
|
+
extends React.ComponentProps<"span">,
|
|
62
|
+
VariantProps<typeof loadingDotsVariants> {
|
|
63
|
+
/** Accessible label for the loading state. */
|
|
64
|
+
"aria-label"?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function LoadingDots({
|
|
68
|
+
size = "default",
|
|
69
|
+
tone = "current",
|
|
70
|
+
className,
|
|
71
|
+
"aria-label": ariaLabel = "Loading",
|
|
72
|
+
...props
|
|
73
|
+
}: LoadingDotsProps) {
|
|
74
|
+
const dotClass = dotSizeMap[size ?? "default"]
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<span
|
|
78
|
+
role="status"
|
|
79
|
+
aria-label={ariaLabel}
|
|
80
|
+
data-slot="loading-dots"
|
|
81
|
+
className={cn(loadingDotsVariants({ size, tone }), className)}
|
|
82
|
+
{...props}
|
|
83
|
+
>
|
|
84
|
+
{[0, 1, 2].map((i) => (
|
|
85
|
+
<span
|
|
86
|
+
key={i}
|
|
87
|
+
aria-hidden="true"
|
|
88
|
+
className={cn("rounded-full bg-current", dotClass)}
|
|
89
|
+
style={{
|
|
90
|
+
animation: "typing-dot 1.2s ease-in-out infinite",
|
|
91
|
+
animationDelay: `${i * 0.2}s`,
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
))}
|
|
95
|
+
</span>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { LoadingDots, loadingDotsVariants }
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Semantic <mark> wrapper for editorial inline emphasis — the static
|
|
10
|
+
* counterpart to Highlight (which dynamically marks search-query matches).
|
|
11
|
+
*
|
|
12
|
+
* Use Mark when an author intentionally annotates a phrase as relevant:
|
|
13
|
+
*
|
|
14
|
+
* <p>
|
|
15
|
+
* The key constraint is <Mark>token discipline</Mark> — every color,
|
|
16
|
+
* spacing, and radius traces back to a single authoritative source.
|
|
17
|
+
* </p>
|
|
18
|
+
*
|
|
19
|
+
* Display-only: <mark> carries no interactive role, no focus contract, and
|
|
20
|
+
* no keyboard target. Most screen readers do not announce it as highlighted —
|
|
21
|
+
* never make the mark the sole carrier of meaning. Pair it with surrounding
|
|
22
|
+
* prose context.
|
|
23
|
+
*
|
|
24
|
+
* Microanimation: no interactive states; rule vacuously satisfied (same
|
|
25
|
+
* exemption as Blockquote, Code). No motion declarations needed.
|
|
26
|
+
*
|
|
27
|
+
* The `default` variant uses bg-warning/25 — a pale amber wash that reads
|
|
28
|
+
* as a physical highlighter across both light and dark themes. The
|
|
29
|
+
* foreground color is always `text-foreground` (the computed near-black or
|
|
30
|
+
* near-white), so WCAG contrast depends on the surrounding text, not the
|
|
31
|
+
* mark background.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
const markVariants = cva(
|
|
35
|
+
"rounded-[2px] px-[0.2em] py-[0.05em]",
|
|
36
|
+
{
|
|
37
|
+
variants: {
|
|
38
|
+
variant: {
|
|
39
|
+
/** Pale amber/warning wash — the physical-highlighter register. */
|
|
40
|
+
default: "bg-warning/25 text-foreground",
|
|
41
|
+
/** Pale primary tint — use for branded or navigational emphasis. */
|
|
42
|
+
primary: "bg-primary/20 text-foreground",
|
|
43
|
+
/** Muted secondary surface — use for neutral, non-semantic callout. */
|
|
44
|
+
secondary: "bg-secondary text-secondary-foreground",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
variant: "default",
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export interface MarkProps
|
|
54
|
+
extends React.ComponentProps<"mark">,
|
|
55
|
+
VariantProps<typeof markVariants> {}
|
|
56
|
+
|
|
57
|
+
function Mark({ className, variant, children, ...props }: MarkProps) {
|
|
58
|
+
return (
|
|
59
|
+
<mark
|
|
60
|
+
data-slot="mark"
|
|
61
|
+
className={cn(markVariants({ variant }), className)}
|
|
62
|
+
{...props}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</mark>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { Mark, markVariants };
|