@behavioral-agentic-design-system/core 0.1.1

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.
Files changed (41) hide show
  1. package/README.md +22 -0
  2. package/package.json +25 -0
  3. package/src/components/ui/alert.tsx +66 -0
  4. package/src/components/ui/avatar.tsx +109 -0
  5. package/src/components/ui/badge.tsx +48 -0
  6. package/src/components/ui/breadcrumb.tsx +109 -0
  7. package/src/components/ui/button.tsx +65 -0
  8. package/src/components/ui/calendar.tsx +217 -0
  9. package/src/components/ui/card.tsx +92 -0
  10. package/src/components/ui/chart.tsx +387 -0
  11. package/src/components/ui/checkbox.tsx +32 -0
  12. package/src/components/ui/collapsible.tsx +33 -0
  13. package/src/components/ui/command.tsx +184 -0
  14. package/src/components/ui/dialog.tsx +158 -0
  15. package/src/components/ui/dropdown-menu.tsx +257 -0
  16. package/src/components/ui/index.ts +35 -0
  17. package/src/components/ui/input.tsx +21 -0
  18. package/src/components/ui/label.tsx +24 -0
  19. package/src/components/ui/popover.tsx +89 -0
  20. package/src/components/ui/progress.tsx +31 -0
  21. package/src/components/ui/radio-group.tsx +45 -0
  22. package/src/components/ui/resizable.tsx +53 -0
  23. package/src/components/ui/scroll-area.tsx +58 -0
  24. package/src/components/ui/select.tsx +190 -0
  25. package/src/components/ui/separator.tsx +29 -0
  26. package/src/components/ui/sheet.tsx +143 -0
  27. package/src/components/ui/sidebar.tsx +726 -0
  28. package/src/components/ui/skeleton.tsx +13 -0
  29. package/src/components/ui/slider.tsx +63 -0
  30. package/src/components/ui/sonner.tsx +40 -0
  31. package/src/components/ui/switch.tsx +35 -0
  32. package/src/components/ui/table.tsx +116 -0
  33. package/src/components/ui/tabs.tsx +88 -0
  34. package/src/components/ui/tag.tsx +46 -0
  35. package/src/components/ui/textarea.tsx +18 -0
  36. package/src/components/ui/toggle-group.tsx +83 -0
  37. package/src/components/ui/toggle.tsx +47 -0
  38. package/src/components/ui/tooltip.tsx +57 -0
  39. package/src/index.ts +2 -0
  40. package/src/lib/utils.ts +6 -0
  41. package/src/tokens.json +476 -0
@@ -0,0 +1,92 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "@/lib/utils"
4
+
5
+ function Card({ className, ...props }: React.ComponentProps<"div">) {
6
+ return (
7
+ <div
8
+ data-slot="card"
9
+ className={cn(
10
+ "flex flex-col gap-4 rounded-lg border bg-card text-card-foreground shadow-sm",
11
+ className
12
+ )}
13
+ {...props}
14
+ />
15
+ )
16
+ }
17
+
18
+ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
19
+ return (
20
+ <div
21
+ data-slot="card-header"
22
+ className={cn(
23
+ "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 py-4 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-4",
24
+ className
25
+ )}
26
+ {...props}
27
+ />
28
+ )
29
+ }
30
+
31
+ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
32
+ return (
33
+ <div
34
+ data-slot="card-title"
35
+ className={cn("leading-none font-semibold", className)}
36
+ {...props}
37
+ />
38
+ )
39
+ }
40
+
41
+ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
42
+ return (
43
+ <div
44
+ data-slot="card-description"
45
+ className={cn("text-sm text-muted-foreground", className)}
46
+ {...props}
47
+ />
48
+ )
49
+ }
50
+
51
+ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
52
+ return (
53
+ <div
54
+ data-slot="card-action"
55
+ className={cn(
56
+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
57
+ className
58
+ )}
59
+ {...props}
60
+ />
61
+ )
62
+ }
63
+
64
+ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
65
+ return (
66
+ <div
67
+ data-slot="card-content"
68
+ className={cn("px-6 py-4", className)}
69
+ {...props}
70
+ />
71
+ )
72
+ }
73
+
74
+ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
75
+ return (
76
+ <div
77
+ data-slot="card-footer"
78
+ className={cn("flex items-center px-6 py-4 [.border-t]:pt-4", className)}
79
+ {...props}
80
+ />
81
+ )
82
+ }
83
+
84
+ export {
85
+ Card,
86
+ CardHeader,
87
+ CardFooter,
88
+ CardTitle,
89
+ CardAction,
90
+ CardDescription,
91
+ CardContent,
92
+ }
@@ -0,0 +1,387 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as RechartsPrimitive from "recharts"
5
+
6
+ import { cn } from "@/lib/utils"
7
+
8
+ // Format: { THEME_NAME: CSS_SELECTOR }
9
+ const THEMES = { light: "", dark: ".dark" } as const
10
+
11
+ export type ChartConfig = {
12
+ [k in string]: {
13
+ label?: React.ReactNode
14
+ icon?: React.ComponentType
15
+ } & (
16
+ | { color?: string; theme?: never }
17
+ | { color?: never; theme: Record<keyof typeof THEMES, string> }
18
+ )
19
+ }
20
+
21
+ type ChartContextProps = {
22
+ config: ChartConfig
23
+ }
24
+
25
+ const ChartContext = React.createContext<ChartContextProps | null>(null)
26
+
27
+ function useChart() {
28
+ const context = React.useContext(ChartContext)
29
+
30
+ if (!context) {
31
+ throw new Error("useChart must be used within a <ChartContainer />")
32
+ }
33
+
34
+ return context
35
+ }
36
+
37
+ function ChartContainer({
38
+ id,
39
+ className,
40
+ children,
41
+ config,
42
+ style,
43
+ ...props
44
+ }: React.ComponentProps<"div"> & {
45
+ config: ChartConfig
46
+ children: React.ComponentProps<
47
+ typeof RechartsPrimitive.ResponsiveContainer
48
+ >["children"]
49
+ }) {
50
+ const uniqueId = React.useId()
51
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
52
+
53
+ return (
54
+ <ChartContext.Provider value={{ config }}>
55
+ <div
56
+ data-slot="chart"
57
+ data-chart={chartId}
58
+ className={cn(
59
+ "relative w-full text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
60
+ className
61
+ )}
62
+ style={{
63
+ display: "grid",
64
+ ...style,
65
+ }}
66
+ {...props}
67
+ >
68
+ <ChartStyle id={chartId} config={config} />
69
+ <RechartsPrimitive.ResponsiveContainer width="100%" height="100%">
70
+ {children}
71
+ </RechartsPrimitive.ResponsiveContainer>
72
+ </div>
73
+ </ChartContext.Provider>
74
+ )
75
+ }
76
+
77
+ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
78
+ const colorConfig = Object.entries(config).filter(
79
+ ([, config]) => config.theme || config.color
80
+ )
81
+
82
+ if (!colorConfig.length) {
83
+ return null
84
+ }
85
+
86
+ return (
87
+ <style
88
+ dangerouslySetInnerHTML={{
89
+ __html: `
90
+ @keyframes chart-dot-fade-in {
91
+ 0% {
92
+ opacity: 0;
93
+ }
94
+ 100% {
95
+ opacity: 1;
96
+ }
97
+ }
98
+
99
+ ${Object.entries(THEMES)
100
+ .map(
101
+ ([theme, prefix]) => `
102
+ ${prefix} [data-chart=${id}] {
103
+ ${colorConfig
104
+ .map(([key, itemConfig]) => {
105
+ const color =
106
+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
107
+ itemConfig.color
108
+ return color ? ` --color-${key}: ${color};` : null
109
+ })
110
+ .join("\n")}
111
+ }
112
+ ${prefix} [data-chart=${id}] .recharts-dot {
113
+ animation: chart-dot-fade-in 400ms ease-out 800ms both;
114
+ }
115
+ `
116
+ )
117
+ .join("\n")}
118
+ `,
119
+ }}
120
+ />
121
+ )
122
+ }
123
+
124
+ const ChartTooltip = RechartsPrimitive.Tooltip
125
+
126
+ interface ChartTooltipContentProps extends React.ComponentProps<"div"> {
127
+ active?: boolean
128
+ payload?: Array<any>
129
+ label?: string | number
130
+ labelFormatter?: (value: any, payload: any) => React.ReactNode
131
+ formatter?: (value: any, name: string, entry: any, index: number, payload: any) => React.ReactNode
132
+ hideLabel?: boolean
133
+ hideIndicator?: boolean
134
+ indicator?: "line" | "dot" | "dashed"
135
+ nameKey?: string
136
+ labelKey?: string
137
+ labelClassName?: string
138
+ color?: string
139
+ }
140
+
141
+ function ChartTooltipContent({
142
+ active,
143
+ payload,
144
+ className,
145
+ indicator = "dot",
146
+ hideLabel = false,
147
+ hideIndicator = false,
148
+ label,
149
+ labelFormatter,
150
+ labelClassName,
151
+ formatter,
152
+ color,
153
+ nameKey,
154
+ labelKey,
155
+ }: ChartTooltipContentProps) {
156
+ const { config } = useChart()
157
+
158
+ const tooltipLabel = React.useMemo(() => {
159
+ if (hideLabel || !payload?.length) {
160
+ return null
161
+ }
162
+
163
+ const [item] = payload
164
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`
165
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
166
+ const value =
167
+ !labelKey && typeof label === "string"
168
+ ? config[label as keyof typeof config]?.label || label
169
+ : itemConfig?.label
170
+
171
+ if (labelFormatter) {
172
+ return (
173
+ <div className={cn("font-medium", labelClassName)}>
174
+ {labelFormatter(value, payload)}
175
+ </div>
176
+ )
177
+ }
178
+
179
+ if (!value) {
180
+ return null
181
+ }
182
+
183
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>
184
+ }, [
185
+ label,
186
+ labelFormatter,
187
+ payload,
188
+ hideLabel,
189
+ labelClassName,
190
+ config,
191
+ labelKey,
192
+ ])
193
+
194
+ if (!active || !payload?.length) {
195
+ return null
196
+ }
197
+
198
+ const nestLabel = payload.length === 1 && indicator !== "dot"
199
+
200
+ return (
201
+ <div
202
+ className={cn(
203
+ "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
204
+ className
205
+ )}
206
+ >
207
+ {!nestLabel ? tooltipLabel : null}
208
+ <div className="grid gap-1.5">
209
+ {payload
210
+ .filter((item) => item.type !== "none")
211
+ .map((item, index) => {
212
+ const key = `${nameKey || item.name || item.dataKey || "value"}`
213
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
214
+ const indicatorColor = color || item.payload.fill || item.color
215
+
216
+ return (
217
+ <div
218
+ key={item.dataKey}
219
+ className={cn(
220
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
221
+ indicator === "dot" && "items-center"
222
+ )}
223
+ >
224
+ {formatter && item?.value !== undefined && item.name ? (
225
+ formatter(item.value, item.name, item, index, item.payload)
226
+ ) : (
227
+ <>
228
+ {itemConfig?.icon ? (
229
+ <itemConfig.icon />
230
+ ) : (
231
+ !hideIndicator && (
232
+ <div
233
+ className={cn(
234
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
235
+ {
236
+ "h-2.5 w-2.5": indicator === "dot",
237
+ "w-1": indicator === "line",
238
+ "w-0 border-[1.5px] border-dashed bg-transparent":
239
+ indicator === "dashed",
240
+ "my-0.5": nestLabel && indicator === "dashed",
241
+ }
242
+ )}
243
+ style={
244
+ {
245
+ "--color-bg": indicatorColor,
246
+ "--color-border": indicatorColor,
247
+ } as React.CSSProperties
248
+ }
249
+ />
250
+ )
251
+ )}
252
+ <div
253
+ className={cn(
254
+ "flex flex-1 justify-between leading-none",
255
+ nestLabel ? "items-end" : "items-center"
256
+ )}
257
+ >
258
+ <div className="grid gap-1.5">
259
+ {nestLabel ? tooltipLabel : null}
260
+ <span className="text-muted-foreground">
261
+ {itemConfig?.label || item.name}
262
+ </span>
263
+ </div>
264
+ {item.value && (
265
+ <span className="font-mono font-bold text-foreground tabular-nums">
266
+ {item.value.toLocaleString()}
267
+ </span>
268
+ )}
269
+ </div>
270
+ </>
271
+ )}
272
+ </div>
273
+ )
274
+ })}
275
+ </div>
276
+ </div>
277
+ )
278
+ }
279
+
280
+ const ChartLegend = RechartsPrimitive.Legend
281
+
282
+ interface ChartLegendContentProps extends React.ComponentProps<"div"> {
283
+ hideIcon?: boolean
284
+ nameKey?: string
285
+ payload?: Array<any>
286
+ verticalAlign?: "top" | "bottom" | "middle"
287
+ }
288
+
289
+ function ChartLegendContent({
290
+ className,
291
+ hideIcon = false,
292
+ payload,
293
+ verticalAlign = "bottom",
294
+ nameKey,
295
+ }: ChartLegendContentProps) {
296
+ const { config } = useChart()
297
+
298
+ if (!payload?.length) {
299
+ return null
300
+ }
301
+
302
+ return (
303
+ <div
304
+ className={cn(
305
+ "flex items-center justify-center gap-4",
306
+ verticalAlign === "top" ? "pb-3" : "pt-3",
307
+ className
308
+ )}
309
+ >
310
+ {payload
311
+ .filter((item) => item.type !== "none")
312
+ .map((item) => {
313
+ const key = `${nameKey || item.dataKey || "value"}`
314
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
315
+
316
+ return (
317
+ <div
318
+ key={item.value}
319
+ className={cn(
320
+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
321
+ )}
322
+ >
323
+ {itemConfig?.icon && !hideIcon ? (
324
+ <itemConfig.icon />
325
+ ) : (
326
+ <div
327
+ className="h-2 w-2 shrink-0 rounded-[2px]"
328
+ style={{
329
+ backgroundColor: item.color,
330
+ }}
331
+ />
332
+ )}
333
+ {itemConfig?.label}
334
+ </div>
335
+ )
336
+ })}
337
+ </div>
338
+ )
339
+ }
340
+
341
+ // Helper to extract item config from a payload.
342
+ function getPayloadConfigFromPayload(
343
+ config: ChartConfig,
344
+ payload: unknown,
345
+ key: string
346
+ ) {
347
+ if (typeof payload !== "object" || payload === null) {
348
+ return undefined
349
+ }
350
+
351
+ const payloadPayload =
352
+ "payload" in payload &&
353
+ typeof payload.payload === "object" &&
354
+ payload.payload !== null
355
+ ? payload.payload
356
+ : undefined
357
+
358
+ let configLabelKey: string = key
359
+
360
+ if (
361
+ key in payload &&
362
+ typeof payload[key as keyof typeof payload] === "string"
363
+ ) {
364
+ configLabelKey = payload[key as keyof typeof payload] as string
365
+ } else if (
366
+ payloadPayload &&
367
+ key in payloadPayload &&
368
+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
369
+ ) {
370
+ configLabelKey = payloadPayload[
371
+ key as keyof typeof payloadPayload
372
+ ] as string
373
+ }
374
+
375
+ return configLabelKey in config
376
+ ? config[configLabelKey]
377
+ : config[key as keyof typeof config]
378
+ }
379
+
380
+ export {
381
+ ChartContainer,
382
+ ChartTooltip,
383
+ ChartTooltipContent,
384
+ ChartLegend,
385
+ ChartLegendContent,
386
+ ChartStyle,
387
+ }
@@ -0,0 +1,32 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { CheckIcon } from "lucide-react"
5
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
6
+
7
+ import { cn } from "@/lib/utils"
8
+
9
+ function Checkbox({
10
+ className,
11
+ ...props
12
+ }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
13
+ return (
14
+ <CheckboxPrimitive.Root
15
+ data-slot="checkbox"
16
+ className={cn(
17
+ "peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary",
18
+ className
19
+ )}
20
+ {...props}
21
+ >
22
+ <CheckboxPrimitive.Indicator
23
+ data-slot="checkbox-indicator"
24
+ className="grid place-content-center text-current transition-none"
25
+ >
26
+ <CheckIcon className="size-3.5" />
27
+ </CheckboxPrimitive.Indicator>
28
+ </CheckboxPrimitive.Root>
29
+ )
30
+ }
31
+
32
+ export { Checkbox }
@@ -0,0 +1,33 @@
1
+ "use client"
2
+
3
+ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible"
4
+
5
+ function Collapsible({
6
+ ...props
7
+ }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
8
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
9
+ }
10
+
11
+ function CollapsibleTrigger({
12
+ ...props
13
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
14
+ return (
15
+ <CollapsiblePrimitive.CollapsibleTrigger
16
+ data-slot="collapsible-trigger"
17
+ {...props}
18
+ />
19
+ )
20
+ }
21
+
22
+ function CollapsibleContent({
23
+ ...props
24
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
25
+ return (
26
+ <CollapsiblePrimitive.CollapsibleContent
27
+ data-slot="collapsible-content"
28
+ {...props}
29
+ />
30
+ )
31
+ }
32
+
33
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent }