@behavioral-agentic-design-system/core 0.14.0 → 0.16.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 +8 -2
- package/scripts/a11y-lint.cjs +229 -0
- package/scripts/build-tokens.cjs +3 -3
- package/scripts/check-stories.mjs +109 -0
- package/scripts/fix-stories.mjs +785 -0
- package/scripts/generate-stories.cjs +101 -0
- package/scripts/oklch-to-hex.cjs +156 -0
- package/scripts/wcag-audit.cjs +444 -0
- package/src/app/preview/components/page.tsx +1118 -7
- package/src/components/dev-identity-badge.tsx +1 -1
- package/src/components/ui/button-group.tsx +57 -0
- package/src/components/ui/calendar.tsx +4 -0
- package/src/components/ui/circular-progress.tsx +120 -0
- package/src/components/ui/color-picker.tsx +219 -0
- package/src/components/ui/copy-button.tsx +114 -0
- package/src/components/ui/date-range-picker.tsx +174 -0
- package/src/components/ui/empty-state.tsx +115 -0
- package/src/components/ui/index.ts +3 -0
- package/src/components/ui/indicator.tsx +144 -0
- package/src/components/ui/list.tsx +70 -0
- package/src/components/ui/multi-select.tsx +196 -0
- package/src/components/ui/password-input.tsx +150 -0
- package/src/components/ui/time-picker.tsx +363 -0
- package/src/components/ui/tree-view.tsx +405 -0
- package/src/data/docs-index.ts +1 -0
- package/src/hooks/use-global-primary-color.ts +1 -1
- package/src/styles.css +2 -2
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { ArrowRightIcon, CalendarIcon, XIcon } from "lucide-react"
|
|
5
|
+
import type { DateRange } from "react-day-picker"
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
import { Calendar } from "./calendar"
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover"
|
|
9
|
+
|
|
10
|
+
export type DateRangeValue = { from?: Date; to?: Date }
|
|
11
|
+
|
|
12
|
+
export interface DateRangePickerProps {
|
|
13
|
+
value?: DateRangeValue
|
|
14
|
+
onValueChange?: (range: DateRangeValue | undefined) => void
|
|
15
|
+
startPlaceholder?: string
|
|
16
|
+
endPlaceholder?: string
|
|
17
|
+
disabled?: boolean
|
|
18
|
+
clearable?: boolean
|
|
19
|
+
size?: "sm" | "default" | "lg"
|
|
20
|
+
className?: string
|
|
21
|
+
fromDate?: Date
|
|
22
|
+
toDate?: Date
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const sizeMap = {
|
|
26
|
+
sm: { height: "h-8", px: "px-2.5", text: "text-sm", gap: "gap-1.5", icon: 14 },
|
|
27
|
+
default: { height: "h-9", px: "px-3", text: "text-sm", gap: "gap-2", icon: 16 },
|
|
28
|
+
lg: { height: "h-10", px: "px-4", text: "text-base", gap: "gap-2", icon: 16 },
|
|
29
|
+
} as const
|
|
30
|
+
|
|
31
|
+
function formatDate(date: Date): string {
|
|
32
|
+
return date.toLocaleDateString("en-US", {
|
|
33
|
+
month: "short",
|
|
34
|
+
day: "numeric",
|
|
35
|
+
year: "numeric",
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function DateRangePicker({
|
|
40
|
+
value,
|
|
41
|
+
onValueChange,
|
|
42
|
+
startPlaceholder = "Start date",
|
|
43
|
+
endPlaceholder = "End date",
|
|
44
|
+
disabled = false,
|
|
45
|
+
clearable = false,
|
|
46
|
+
size = "default",
|
|
47
|
+
className,
|
|
48
|
+
fromDate,
|
|
49
|
+
toDate,
|
|
50
|
+
}: DateRangePickerProps) {
|
|
51
|
+
const [open, setOpen] = React.useState(false)
|
|
52
|
+
const [internalRange, setInternalRange] = React.useState<
|
|
53
|
+
DateRangeValue | undefined
|
|
54
|
+
>(undefined)
|
|
55
|
+
|
|
56
|
+
const isControlled = value !== undefined || onValueChange !== undefined
|
|
57
|
+
const selectedRange = isControlled ? value : internalRange
|
|
58
|
+
|
|
59
|
+
function handleSelect(range: DateRange | undefined) {
|
|
60
|
+
const next: DateRangeValue | undefined = range
|
|
61
|
+
? { from: range.from, to: range.to }
|
|
62
|
+
: undefined
|
|
63
|
+
if (!isControlled) setInternalRange(next)
|
|
64
|
+
onValueChange?.(next)
|
|
65
|
+
if (next?.from && next?.to) setOpen(false)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function handleClear(e: React.MouseEvent) {
|
|
69
|
+
e.stopPropagation()
|
|
70
|
+
if (!isControlled) setInternalRange(undefined)
|
|
71
|
+
onValueChange?.(undefined)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const hasFrom = !!selectedRange?.from
|
|
75
|
+
const hasTo = !!selectedRange?.to
|
|
76
|
+
const hasAny = hasFrom || hasTo
|
|
77
|
+
|
|
78
|
+
const { height, px, text, gap, icon: iconSize } = sizeMap[size]
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Popover open={open} onOpenChange={disabled ? undefined : setOpen}>
|
|
82
|
+
{/*
|
|
83
|
+
Same compound-input pattern as DatePicker: outer div owns border/ring chrome;
|
|
84
|
+
PopoverTrigger button and clear button are siblings (not nested) to satisfy
|
|
85
|
+
the axe-core nested-interactive rule.
|
|
86
|
+
*/}
|
|
87
|
+
<div
|
|
88
|
+
data-slot="date-range-picker-root"
|
|
89
|
+
data-size={size}
|
|
90
|
+
className={cn(
|
|
91
|
+
"inline-flex w-full min-w-0 items-center rounded-md border border-input bg-transparent shadow-xs",
|
|
92
|
+
"focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50",
|
|
93
|
+
disabled && "pointer-events-none cursor-not-allowed opacity-50",
|
|
94
|
+
height,
|
|
95
|
+
px,
|
|
96
|
+
gap,
|
|
97
|
+
className
|
|
98
|
+
)}
|
|
99
|
+
>
|
|
100
|
+
<PopoverTrigger asChild>
|
|
101
|
+
<button
|
|
102
|
+
type="button"
|
|
103
|
+
data-slot="date-range-picker-trigger"
|
|
104
|
+
disabled={disabled}
|
|
105
|
+
aria-haspopup="dialog"
|
|
106
|
+
aria-expanded={open}
|
|
107
|
+
aria-label={
|
|
108
|
+
hasFrom && hasTo
|
|
109
|
+
? `${formatDate(selectedRange!.from!)} to ${formatDate(selectedRange!.to!)}`
|
|
110
|
+
: hasFrom
|
|
111
|
+
? `From ${formatDate(selectedRange!.from!)}`
|
|
112
|
+
: "Select date range"
|
|
113
|
+
}
|
|
114
|
+
className={cn(
|
|
115
|
+
"inline-flex flex-1 min-w-0 h-full items-center text-left font-normal bg-transparent outline-none",
|
|
116
|
+
"transition-[color]",
|
|
117
|
+
gap,
|
|
118
|
+
text
|
|
119
|
+
)}
|
|
120
|
+
style={{
|
|
121
|
+
transitionDuration: "var(--duration-fast)",
|
|
122
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<CalendarIcon
|
|
126
|
+
size={iconSize}
|
|
127
|
+
strokeWidth={1.5}
|
|
128
|
+
className="shrink-0 text-muted-foreground"
|
|
129
|
+
/>
|
|
130
|
+
<span className={cn("truncate", !hasFrom && "text-muted-foreground")}>
|
|
131
|
+
{hasFrom ? formatDate(selectedRange!.from!) : startPlaceholder}
|
|
132
|
+
</span>
|
|
133
|
+
<ArrowRightIcon
|
|
134
|
+
size={iconSize - 2}
|
|
135
|
+
strokeWidth={1.5}
|
|
136
|
+
className="shrink-0 text-muted-foreground mx-1"
|
|
137
|
+
/>
|
|
138
|
+
<span className={cn("truncate", !hasTo && "text-muted-foreground")}>
|
|
139
|
+
{hasTo ? formatDate(selectedRange!.to!) : endPlaceholder}
|
|
140
|
+
</span>
|
|
141
|
+
</button>
|
|
142
|
+
</PopoverTrigger>
|
|
143
|
+
{clearable && hasAny ? (
|
|
144
|
+
<button
|
|
145
|
+
type="button"
|
|
146
|
+
aria-label="Clear date range"
|
|
147
|
+
onClick={handleClear}
|
|
148
|
+
disabled={disabled}
|
|
149
|
+
className="shrink-0 -mr-1 rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
150
|
+
style={{
|
|
151
|
+
transitionDuration: "var(--duration-fast)",
|
|
152
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<XIcon size={iconSize - 2} strokeWidth={1.5} />
|
|
156
|
+
</button>
|
|
157
|
+
) : null}
|
|
158
|
+
</div>
|
|
159
|
+
<PopoverContent className="w-auto p-0" align="start">
|
|
160
|
+
<Calendar
|
|
161
|
+
mode="range"
|
|
162
|
+
selected={selectedRange as DateRange | undefined}
|
|
163
|
+
onSelect={handleSelect}
|
|
164
|
+
fromDate={fromDate}
|
|
165
|
+
toDate={toDate}
|
|
166
|
+
numberOfMonths={2}
|
|
167
|
+
initialFocus
|
|
168
|
+
/>
|
|
169
|
+
</PopoverContent>
|
|
170
|
+
</Popover>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { DateRangePicker }
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
// ─── EmptyState root ──────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
const emptyStateVariants = cva(
|
|
9
|
+
"flex flex-col items-center text-center",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
size: {
|
|
13
|
+
sm: "gap-2 py-6 px-4",
|
|
14
|
+
default: "gap-3 py-10 px-6",
|
|
15
|
+
lg: "gap-4 py-16 px-8",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: "default",
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
export interface EmptyStateProps
|
|
25
|
+
extends React.ComponentPropsWithoutRef<"div">,
|
|
26
|
+
VariantProps<typeof emptyStateVariants> {}
|
|
27
|
+
|
|
28
|
+
function EmptyState({ className, size, children, ...props }: EmptyStateProps) {
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
data-slot="empty-state"
|
|
32
|
+
className={cn(emptyStateVariants({ size }), className)}
|
|
33
|
+
{...props}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ─── EmptyStateIcon ───────────────────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
export interface EmptyStateIconProps extends React.ComponentPropsWithoutRef<"div"> {}
|
|
43
|
+
|
|
44
|
+
function EmptyStateIcon({ className, children, ...props }: EmptyStateIconProps) {
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
data-slot="empty-state-icon"
|
|
48
|
+
className={cn(
|
|
49
|
+
"flex items-center justify-center rounded-full bg-muted text-muted-foreground",
|
|
50
|
+
"size-12 [&>svg]:size-6 [&>svg]:stroke-[1.5]",
|
|
51
|
+
className
|
|
52
|
+
)}
|
|
53
|
+
{...props}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ─── EmptyStateTitle ──────────────────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
export interface EmptyStateTitleProps extends React.ComponentPropsWithoutRef<"p"> {}
|
|
63
|
+
|
|
64
|
+
function EmptyStateTitle({ className, children, ...props }: EmptyStateTitleProps) {
|
|
65
|
+
return (
|
|
66
|
+
<p
|
|
67
|
+
data-slot="empty-state-title"
|
|
68
|
+
className={cn("text-sm font-semibold text-foreground", className)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
</p>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ─── EmptyStateDescription ────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
export interface EmptyStateDescriptionProps extends React.ComponentPropsWithoutRef<"p"> {}
|
|
79
|
+
|
|
80
|
+
function EmptyStateDescription({ className, children, ...props }: EmptyStateDescriptionProps) {
|
|
81
|
+
return (
|
|
82
|
+
<p
|
|
83
|
+
data-slot="empty-state-description"
|
|
84
|
+
className={cn("text-sm text-muted-foreground max-w-xs leading-relaxed", className)}
|
|
85
|
+
{...props}
|
|
86
|
+
>
|
|
87
|
+
{children}
|
|
88
|
+
</p>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ─── EmptyStateAction ─────────────────────────────────────────────────────────
|
|
93
|
+
|
|
94
|
+
export interface EmptyStateActionProps extends React.ComponentPropsWithoutRef<"div"> {}
|
|
95
|
+
|
|
96
|
+
function EmptyStateAction({ className, children, ...props }: EmptyStateActionProps) {
|
|
97
|
+
return (
|
|
98
|
+
<div
|
|
99
|
+
data-slot="empty-state-action"
|
|
100
|
+
className={cn("flex items-center gap-2 pt-1", className)}
|
|
101
|
+
{...props}
|
|
102
|
+
>
|
|
103
|
+
{children}
|
|
104
|
+
</div>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
EmptyState,
|
|
110
|
+
emptyStateVariants,
|
|
111
|
+
EmptyStateIcon,
|
|
112
|
+
EmptyStateTitle,
|
|
113
|
+
EmptyStateDescription,
|
|
114
|
+
EmptyStateAction,
|
|
115
|
+
}
|
|
@@ -16,6 +16,7 @@ export * from "./date-picker";
|
|
|
16
16
|
export * from "./chart";
|
|
17
17
|
export * from "./checkbox";
|
|
18
18
|
export * from "./collapsible";
|
|
19
|
+
export * from "./color-picker";
|
|
19
20
|
export * from "./command";
|
|
20
21
|
export * from "./context-menu";
|
|
21
22
|
export * from "./dialog";
|
|
@@ -29,6 +30,7 @@ export * from "./menubar";
|
|
|
29
30
|
export * from "./navigation-menu";
|
|
30
31
|
export * from "./number-input";
|
|
31
32
|
export * from "./pagination";
|
|
33
|
+
export * from "./password-input";
|
|
32
34
|
export * from "./popover";
|
|
33
35
|
export * from "./progress";
|
|
34
36
|
export * from "./radio-group";
|
|
@@ -57,3 +59,4 @@ export * from "./toggle";
|
|
|
57
59
|
export * from "./toggle-group";
|
|
58
60
|
export * from "./toolbar";
|
|
59
61
|
export * from "./tooltip";
|
|
62
|
+
export * from "./tree-view";
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
import { cn } from "../../lib/utils"
|
|
6
|
+
|
|
7
|
+
type Position =
|
|
8
|
+
| "top-right"
|
|
9
|
+
| "top-left"
|
|
10
|
+
| "bottom-right"
|
|
11
|
+
| "bottom-left"
|
|
12
|
+
| "middle-right"
|
|
13
|
+
| "middle-left"
|
|
14
|
+
|
|
15
|
+
// Dot sizes — no text baked in; labeled mode adds text-xs + height overrides separately
|
|
16
|
+
const indicatorDotVariants = cva(
|
|
17
|
+
"absolute inline-flex items-center justify-center rounded-full font-medium",
|
|
18
|
+
{
|
|
19
|
+
variants: {
|
|
20
|
+
variant: {
|
|
21
|
+
default: "bg-primary text-primary-foreground",
|
|
22
|
+
secondary: "bg-secondary text-secondary-foreground",
|
|
23
|
+
destructive: "bg-destructive text-white",
|
|
24
|
+
success: "bg-[hsl(var(--success))] text-white",
|
|
25
|
+
warning: "bg-[hsl(var(--warning))] text-white",
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
// Dot-only base dimensions; labeled mode overrides height + min-width below
|
|
29
|
+
sm: "size-1.5",
|
|
30
|
+
default: "size-2.5",
|
|
31
|
+
lg: "size-3.5",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: "default",
|
|
36
|
+
size: "default",
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const positionMap: Record<Position, string> = {
|
|
42
|
+
"top-right": "top-0 right-0 -translate-y-1/2 translate-x-1/2",
|
|
43
|
+
"top-left": "top-0 left-0 -translate-y-1/2 -translate-x-1/2",
|
|
44
|
+
"bottom-right": "bottom-0 right-0 translate-y-1/2 translate-x-1/2",
|
|
45
|
+
"bottom-left": "bottom-0 left-0 translate-y-1/2 -translate-x-1/2",
|
|
46
|
+
"middle-right": "top-1/2 right-0 -translate-y-1/2 translate-x-1/2",
|
|
47
|
+
"middle-left": "top-1/2 left-0 -translate-y-1/2 -translate-x-1/2",
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IndicatorProps
|
|
51
|
+
extends Omit<React.HTMLAttributes<HTMLSpanElement>, "children">,
|
|
52
|
+
VariantProps<typeof indicatorDotVariants> {
|
|
53
|
+
/** Element to attach the indicator badge to. Required. */
|
|
54
|
+
children: React.ReactNode
|
|
55
|
+
/** Corner / side position of the dot. Default "top-right". */
|
|
56
|
+
position?: Position
|
|
57
|
+
/** Content inside the dot (count, icon). Omit for a plain dot. Ignored when size="sm". */
|
|
58
|
+
label?: React.ReactNode
|
|
59
|
+
/** Adds a 2px background ring around the dot for contrast on any surface. */
|
|
60
|
+
withBorder?: boolean
|
|
61
|
+
/** Pulsing ping animation — use for live / unread signals. */
|
|
62
|
+
processing?: boolean
|
|
63
|
+
/** Hides the dot, rendering only the children. */
|
|
64
|
+
disabled?: boolean
|
|
65
|
+
/** aria-label for the indicator region. Defaults to the string value of label. */
|
|
66
|
+
indicatorLabel?: string
|
|
67
|
+
/** className forwarded to the dot span. */
|
|
68
|
+
indicatorClassName?: string
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function Indicator({
|
|
72
|
+
children,
|
|
73
|
+
position = "top-right",
|
|
74
|
+
label,
|
|
75
|
+
withBorder = false,
|
|
76
|
+
processing = false,
|
|
77
|
+
disabled = false,
|
|
78
|
+
variant = "default",
|
|
79
|
+
size = "default",
|
|
80
|
+
indicatorLabel,
|
|
81
|
+
indicatorClassName,
|
|
82
|
+
className,
|
|
83
|
+
...props
|
|
84
|
+
}: IndicatorProps) {
|
|
85
|
+
const hasContent = label !== undefined && label !== null && label !== ""
|
|
86
|
+
// sm is always dot-only; for other sizes only show label if content exists
|
|
87
|
+
const showLabel = hasContent && size !== "sm"
|
|
88
|
+
|
|
89
|
+
const displayLabel =
|
|
90
|
+
typeof label === "number" && label > 99 ? "99+" : label
|
|
91
|
+
|
|
92
|
+
const dotAriaLabel =
|
|
93
|
+
indicatorLabel ??
|
|
94
|
+
(typeof label === "string" || typeof label === "number" ? String(label) : undefined)
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<span
|
|
98
|
+
data-slot="indicator"
|
|
99
|
+
className={cn("relative inline-flex shrink-0", className)}
|
|
100
|
+
{...props}
|
|
101
|
+
>
|
|
102
|
+
{children}
|
|
103
|
+
{!disabled && (
|
|
104
|
+
<>
|
|
105
|
+
{/* Ping ring for processing state (renders behind the solid dot) */}
|
|
106
|
+
{processing && (
|
|
107
|
+
<span
|
|
108
|
+
aria-hidden="true"
|
|
109
|
+
className={cn(
|
|
110
|
+
"absolute rounded-full animate-ping opacity-60",
|
|
111
|
+
positionMap[position],
|
|
112
|
+
indicatorDotVariants({ variant, size })
|
|
113
|
+
)}
|
|
114
|
+
/>
|
|
115
|
+
)}
|
|
116
|
+
<span
|
|
117
|
+
data-slot="indicator-dot"
|
|
118
|
+
role={dotAriaLabel ? "status" : undefined}
|
|
119
|
+
aria-label={dotAriaLabel}
|
|
120
|
+
aria-hidden={!dotAriaLabel ? "true" : undefined}
|
|
121
|
+
style={{
|
|
122
|
+
transitionDuration: "var(--duration-fast)",
|
|
123
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
124
|
+
}}
|
|
125
|
+
className={cn(
|
|
126
|
+
indicatorDotVariants({ variant, size }),
|
|
127
|
+
positionMap[position],
|
|
128
|
+
// Labeled mode: override to minimum 14px text + taller dot (AAA SC 1.4.4)
|
|
129
|
+
showLabel && "text-xs leading-none px-1",
|
|
130
|
+
showLabel && size === "default" && "h-4 min-w-4",
|
|
131
|
+
showLabel && size === "lg" && "h-5 min-w-5",
|
|
132
|
+
withBorder && "ring-2 ring-background",
|
|
133
|
+
indicatorClassName
|
|
134
|
+
)}
|
|
135
|
+
>
|
|
136
|
+
{showLabel ? displayLabel : null}
|
|
137
|
+
</span>
|
|
138
|
+
</>
|
|
139
|
+
)}
|
|
140
|
+
</span>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export { Indicator, indicatorDotVariants }
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
|
+
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
// ─── List root ────────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
const listVariants = cva("flex flex-col list-none p-0 m-0", {
|
|
9
|
+
variants: {
|
|
10
|
+
spacing: {
|
|
11
|
+
sm: "gap-1",
|
|
12
|
+
default: "gap-2",
|
|
13
|
+
lg: "gap-3",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
spacing: "default",
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
export interface ListProps
|
|
22
|
+
extends React.ComponentPropsWithoutRef<"ul">,
|
|
23
|
+
VariantProps<typeof listVariants> {
|
|
24
|
+
/** "ul" (default) or "ol" — controls the semantic element rendered */
|
|
25
|
+
type?: "ul" | "ol"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function List({ className, type = "ul", spacing, children, ...props }: ListProps) {
|
|
29
|
+
const Tag = type as React.ElementType
|
|
30
|
+
return (
|
|
31
|
+
<Tag
|
|
32
|
+
data-slot="list"
|
|
33
|
+
className={cn(listVariants({ spacing }), className)}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</Tag>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// ─── ListItem ─────────────────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
export interface ListItemProps extends React.ComponentPropsWithoutRef<"li"> {
|
|
44
|
+
/** Optional icon rendered before the text — sized at 16 px and aligned to the first line */
|
|
45
|
+
icon?: React.ReactNode
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function ListItem({ className, icon, children, ...props }: ListItemProps) {
|
|
49
|
+
return (
|
|
50
|
+
<li
|
|
51
|
+
data-slot="list-item"
|
|
52
|
+
className={cn("flex items-start gap-2 text-sm leading-relaxed", className)}
|
|
53
|
+
{...props}
|
|
54
|
+
>
|
|
55
|
+
{icon ? (
|
|
56
|
+
<span
|
|
57
|
+
data-slot="list-item-icon"
|
|
58
|
+
className="mt-0.5 shrink-0 text-muted-foreground [&>svg]:size-4 [&>svg]:stroke-[1.5]"
|
|
59
|
+
>
|
|
60
|
+
{icon}
|
|
61
|
+
</span>
|
|
62
|
+
) : null}
|
|
63
|
+
<span data-slot="list-item-content" className="flex-1 min-w-0">
|
|
64
|
+
{children}
|
|
65
|
+
</span>
|
|
66
|
+
</li>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { List, listVariants, ListItem }
|