@behavioral-agentic-design-system/core 0.15.0 → 0.17.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.
@@ -22,7 +22,7 @@ import { useEffect, useState } from "react";
22
22
  * <html>
23
23
  * <body>
24
24
  * {children}
25
- * <DevIdentityBadge name="swimtopia-prototypes" />
25
+ * <DevIdentityBadge name="my-prototypes" />
26
26
  * </body>
27
27
  * </html>
28
28
  * );
@@ -0,0 +1,57 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "../../lib/utils"
4
+
5
+ // ─── ButtonGroup ──────────────────────────────────────────────────────────────
6
+ // Groups adjacent Button primitives with shared borders and no interior radii.
7
+ // Targets [data-slot="button"] so it composes with Button's asChild mode too.
8
+
9
+ export interface ButtonGroupProps extends React.ComponentPropsWithoutRef<"div"> {
10
+ /** "horizontal" (default) | "vertical" */
11
+ orientation?: "horizontal" | "vertical"
12
+ }
13
+
14
+ function ButtonGroup({
15
+ className,
16
+ orientation = "horizontal",
17
+ children,
18
+ ...props
19
+ }: ButtonGroupProps) {
20
+ return (
21
+ <div
22
+ role="group"
23
+ data-slot="button-group"
24
+ data-orientation={orientation}
25
+ className={cn(
26
+ "inline-flex",
27
+ orientation === "vertical" ? "flex-col" : "flex-row",
28
+ // Strip radii from every direct Button child
29
+ "[&>[data-slot=button]]:rounded-none",
30
+ orientation === "horizontal"
31
+ ? [
32
+ // Restore outer corners
33
+ "[&>[data-slot=button]:first-child]:rounded-l-md",
34
+ "[&>[data-slot=button]:last-child]:rounded-r-md",
35
+ // Collapse shared border between siblings
36
+ "[&>[data-slot=button]:not(:first-child)]:-ml-px",
37
+ // Lift hovered / focused button so its border isn't clipped by sibling
38
+ "[&>[data-slot=button]:hover]:z-10",
39
+ "[&>[data-slot=button]:focus-visible]:z-10",
40
+ ]
41
+ : [
42
+ "[&>[data-slot=button]:first-child]:rounded-t-md",
43
+ "[&>[data-slot=button]:last-child]:rounded-b-md",
44
+ "[&>[data-slot=button]:not(:first-child)]:-mt-px",
45
+ "[&>[data-slot=button]:hover]:z-10",
46
+ "[&>[data-slot=button]:focus-visible]:z-10",
47
+ ],
48
+ className
49
+ )}
50
+ {...props}
51
+ >
52
+ {children}
53
+ </div>
54
+ )
55
+ }
56
+
57
+ export { ButtonGroup }
@@ -205,6 +205,10 @@ function CalendarDayButton({
205
205
  data-range-end={modifiers.range_end}
206
206
  data-range-middle={modifiers.range_middle}
207
207
  className={cn(
208
+ // shadcn calendar day-cell default weight; the nested [&>span] day-number
209
+ // is text-xs. Bumping day numbers to font-medium is a visual change to this
210
+ // shared primitive — deferred to a design decision, not a mechanical fix.
211
+ // allow-font-normal-small
208
212
  "flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
209
213
  defaultClassNames.day,
210
214
  className
@@ -0,0 +1,120 @@
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
+ const SIZES = {
8
+ sm: { size: 32, strokeWidth: 3 },
9
+ default: { size: 48, strokeWidth: 4 },
10
+ lg: { size: 64, strokeWidth: 5 },
11
+ } as const
12
+
13
+ type SizeKey = keyof typeof SIZES
14
+
15
+ const circularProgressVariants = cva(
16
+ "inline-flex items-center justify-center relative",
17
+ {
18
+ variants: {
19
+ variant: {
20
+ default: "text-primary",
21
+ muted: "text-muted-foreground",
22
+ success: "text-[hsl(var(--success))]",
23
+ warning: "text-[hsl(var(--warning))]",
24
+ destructive: "text-destructive",
25
+ },
26
+ },
27
+ defaultVariants: {
28
+ variant: "default",
29
+ },
30
+ }
31
+ )
32
+
33
+ export interface CircularProgressProps
34
+ extends React.HTMLAttributes<HTMLDivElement>,
35
+ VariantProps<typeof circularProgressVariants> {
36
+ /** 0–100. Omit for indeterminate (spinning) mode. */
37
+ value?: number
38
+ /** Required: describes what is progressing for screen readers */
39
+ label: string
40
+ size?: SizeKey
41
+ }
42
+
43
+ function CircularProgress({
44
+ value,
45
+ label,
46
+ variant = "default",
47
+ size = "default",
48
+ className,
49
+ children,
50
+ ...props
51
+ }: CircularProgressProps) {
52
+ const determinate = value !== undefined
53
+ const clampedValue = determinate ? Math.min(100, Math.max(0, value!)) : 0
54
+ const { size: svgSize, strokeWidth } = SIZES[size ?? "default"]
55
+ const cx = svgSize / 2
56
+ const cy = svgSize / 2
57
+ // Radius keeps entire stroke inside the viewBox
58
+ const radius = svgSize / 2 - strokeWidth
59
+ const circumference = 2 * Math.PI * radius
60
+
61
+ return (
62
+ <div
63
+ role="progressbar"
64
+ aria-valuenow={determinate ? clampedValue : undefined}
65
+ aria-valuemin={0}
66
+ aria-valuemax={100}
67
+ aria-label={label}
68
+ data-slot="circular-progress"
69
+ data-size={size}
70
+ data-variant={variant}
71
+ className={cn(circularProgressVariants({ variant }), className)}
72
+ {...props}
73
+ >
74
+ <svg
75
+ width={svgSize}
76
+ height={svgSize}
77
+ viewBox={`0 0 ${svgSize} ${svgSize}`}
78
+ fill="none"
79
+ className={cn(
80
+ "-rotate-90",
81
+ !determinate && "animate-spin"
82
+ )}
83
+ aria-hidden="true"
84
+ >
85
+ {/* Track */}
86
+ <circle
87
+ cx={cx}
88
+ cy={cy}
89
+ r={radius}
90
+ strokeWidth={strokeWidth}
91
+ className="stroke-current opacity-20"
92
+ />
93
+ {/* Fill */}
94
+ <circle
95
+ cx={cx}
96
+ cy={cy}
97
+ r={radius}
98
+ strokeWidth={strokeWidth}
99
+ strokeLinecap="round"
100
+ className="stroke-current transition-[stroke-dashoffset]"
101
+ style={{
102
+ strokeDasharray: determinate ? circumference : circumference * 0.75,
103
+ strokeDashoffset: determinate
104
+ ? circumference * (1 - clampedValue / 100)
105
+ : 0,
106
+ transitionDuration: "var(--duration-base)",
107
+ transitionTimingFunction: "var(--ease-out)",
108
+ }}
109
+ />
110
+ </svg>
111
+ {children !== undefined && (
112
+ <span className="absolute" aria-hidden="true">
113
+ {children}
114
+ </span>
115
+ )}
116
+ </div>
117
+ )
118
+ }
119
+
120
+ export { CircularProgress, circularProgressVariants }
@@ -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 }
@@ -0,0 +1,114 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { CheckIcon, CopyIcon } from "lucide-react"
5
+ import { cn } from "../../lib/utils"
6
+ import { Button, buttonVariants } from "./button"
7
+ import type { VariantProps } from "class-variance-authority"
8
+
9
+ export type CopyButtonProps = Omit<
10
+ React.ComponentPropsWithoutRef<"button">,
11
+ "onClick" | "value" | "children"
12
+ > &
13
+ VariantProps<typeof buttonVariants> & {
14
+ /** The text value to copy to the clipboard. Required. */
15
+ value: string
16
+ /** Milliseconds the "copied" state is held before resetting. Default 2000. */
17
+ copiedDuration?: number
18
+ /** Called after a successful clipboard write. */
19
+ onCopy?: (value: string) => void
20
+ /** Label shown at rest. Omit for icon-only mode. */
21
+ children?: React.ReactNode
22
+ }
23
+
24
+ function CopyButton({
25
+ value,
26
+ copiedDuration = 2000,
27
+ onCopy,
28
+ children,
29
+ variant = "outline",
30
+ size = "default",
31
+ className,
32
+ disabled,
33
+ "aria-label": ariaLabel,
34
+ ...props
35
+ }: CopyButtonProps) {
36
+ const [copied, setCopied] = React.useState(false)
37
+
38
+ const handleCopy = React.useCallback(async () => {
39
+ if (copied) return
40
+ try {
41
+ await navigator.clipboard.writeText(value)
42
+ } catch {
43
+ // Fallback for environments without clipboard API
44
+ const el = document.createElement("textarea")
45
+ el.value = value
46
+ el.style.position = "fixed"
47
+ el.style.opacity = "0"
48
+ document.body.appendChild(el)
49
+ el.focus()
50
+ el.select()
51
+ document.execCommand("copy")
52
+ document.body.removeChild(el)
53
+ }
54
+ setCopied(true)
55
+ onCopy?.(value)
56
+ const timer = setTimeout(() => setCopied(false), copiedDuration)
57
+ return () => clearTimeout(timer)
58
+ }, [value, copied, copiedDuration, onCopy])
59
+
60
+ const iconOnly = children === undefined
61
+
62
+ return (
63
+ <>
64
+ <Button
65
+ data-slot="copy-button"
66
+ data-copied={copied ? "true" : undefined}
67
+ variant={variant}
68
+ size={size}
69
+ disabled={disabled || copied}
70
+ onClick={handleCopy}
71
+ aria-label={ariaLabel ?? (iconOnly ? (copied ? "Copied" : "Copy") : undefined)}
72
+ className={cn("relative overflow-hidden", className)}
73
+ {...props}
74
+ >
75
+ {/* In labeled mode this span provides the button's accessible name — not aria-hidden */}
76
+ <span
77
+ className={cn(
78
+ "inline-flex items-center gap-2 transition-all",
79
+ copied ? "opacity-0 scale-75" : "opacity-100 scale-100"
80
+ )}
81
+ style={{
82
+ transitionDuration: "var(--duration-fast)",
83
+ transitionTimingFunction: "var(--ease-out)",
84
+ }}
85
+ aria-hidden={iconOnly ? "true" : undefined}
86
+ >
87
+ <CopyIcon strokeWidth={1.5} aria-hidden="true" />
88
+ {!iconOnly && (children ?? "Copy")}
89
+ </span>
90
+ {/* Always hidden — state announced by the aria-live region */}
91
+ <span
92
+ className={cn(
93
+ "absolute inset-0 inline-flex items-center justify-center gap-2 transition-all",
94
+ copied ? "opacity-100 scale-100" : "opacity-0 scale-75"
95
+ )}
96
+ style={{
97
+ transitionDuration: "var(--duration-fast)",
98
+ transitionTimingFunction: "var(--ease-out)",
99
+ }}
100
+ aria-hidden="true"
101
+ >
102
+ <CheckIcon strokeWidth={1.5} />
103
+ {!iconOnly && "Copied!"}
104
+ </span>
105
+ </Button>
106
+ {/* Screen-reader live region — announces state change without focus move */}
107
+ <span className="sr-only" aria-live="polite" aria-atomic="true">
108
+ {copied ? "Copied to clipboard" : ""}
109
+ </span>
110
+ </>
111
+ )
112
+ }
113
+
114
+ export { CopyButton }
@@ -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
+ }
@@ -40,7 +40,6 @@ export * from "./scroll-area";
40
40
  export * from "./select";
41
41
  export * from "./separator";
42
42
  export * from "./sheet";
43
- export * from "./bottom-sheet";
44
43
  export * from "./sidebar";
45
44
  export * from "./skeleton";
46
45
  export * from "./slider";
@@ -0,0 +1,146 @@
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-2",
30
+ default: "size-3",
31
+ lg: "size-4",
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: 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",
134
+ withBorder && "ring-2 ring-background",
135
+ indicatorClassName
136
+ )}
137
+ >
138
+ {showLabel ? displayLabel : null}
139
+ </span>
140
+ </>
141
+ )}
142
+ </span>
143
+ )
144
+ }
145
+
146
+ export { Indicator, indicatorDotVariants }