Skip to content

Commit 0ecf52d

Browse files
updating shadcn base ui
adding convenience scripts (format/shadcn:update)
1 parent f456a74 commit 0ecf52d

22 files changed

Lines changed: 1768 additions & 310 deletions

packages/shadcn/components.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "../../docs/storybook/.storybook/tailwind.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide",
21+
"registries": {
22+
"@ai-elements": "https://registry.ai-sdk.dev/{name}.json"
23+
}
24+
}

packages/shadcn/components/agents-ui/agent-disconnect-button.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import { PhoneOffIcon } from 'lucide-react';
1111
* Props for the AgentDisconnectButton component.
1212
*/
1313
export interface AgentDisconnectButtonProps
14-
extends ComponentProps<'button'>,
15-
VariantProps<typeof buttonVariants> {
14+
extends ComponentProps<'button'>, VariantProps<typeof buttonVariants> {
1615
/**
1716
* Custom icon to display. Defaults to PhoneOffIcon.
1817
*/

packages/shadcn/components/ai-elements/conversation.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use client';
22

3+
import { Button } from '@/components/ui/button';
4+
import { cn } from '@/lib/utils';
5+
import { ArrowDownIcon } from 'lucide-react';
36
import type { ComponentProps } from 'react';
47
import { useCallback } from 'react';
5-
import { ArrowDownIcon } from 'lucide-react';
68
import { StickToBottom, useStickToBottomContext } from 'use-stick-to-bottom';
7-
import { Button } from '@/components/ui/button';
8-
import { cn } from '@/lib/utils';
99

1010
export type ConversationProps = ComponentProps<typeof StickToBottom>;
1111

@@ -42,15 +42,15 @@ export const ConversationEmptyState = ({
4242
<div
4343
className={cn(
4444
'flex size-full flex-col items-center justify-center gap-3 p-8 text-center',
45-
className
45+
className,
4646
)}
4747
{...props}
4848
>
4949
{children ?? (
5050
<>
5151
{icon && <div className="text-muted-foreground">{icon}</div>}
5252
<div className="space-y-1">
53-
<h3 className="text-sm font-medium">{title}</h3>
53+
<h3 className="font-medium text-sm">{title}</h3>
5454
{description && <p className="text-muted-foreground text-sm">{description}</p>}
5555
</div>
5656
</>

packages/shadcn/components/ai-elements/message.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use client';
22

3-
import type { ComponentProps, HTMLAttributes, ReactElement } from 'react';
4-
import { createContext, memo, useContext, useEffect, useState } from 'react';
5-
import type { FileUIPart, UIMessage } from 'ai';
6-
import { ChevronLeftIcon, ChevronRightIcon, PaperclipIcon, XIcon } from 'lucide-react';
7-
import { Streamdown } from 'streamdown';
83
import { Button } from '@/components/ui/button';
94
import { ButtonGroup, ButtonGroupText } from '@/components/ui/button-group';
105
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
116
import { cn } from '@/lib/utils';
7+
import type { FileUIPart, UIMessage } from 'ai';
8+
import { ChevronLeftIcon, ChevronRightIcon, PaperclipIcon, XIcon } from 'lucide-react';
9+
import type { ComponentProps, HTMLAttributes, ReactElement } from 'react';
10+
import { createContext, memo, useContext, useEffect, useState } from 'react';
11+
import { Streamdown } from 'streamdown';
1212

1313
export type MessageProps = HTMLAttributes<HTMLDivElement> & {
1414
from: UIMessage['role'];
@@ -17,9 +17,9 @@ export type MessageProps = HTMLAttributes<HTMLDivElement> & {
1717
export const Message = ({ className, from, ...props }: MessageProps) => (
1818
<div
1919
className={cn(
20-
'group flex w-full max-w-[80%] flex-col gap-2',
20+
'group flex w-full max-w-[95%] flex-col gap-2',
2121
from === 'user' ? 'is-user ml-auto justify-end' : 'is-assistant',
22-
className
22+
className,
2323
)}
2424
{...props}
2525
/>
@@ -30,10 +30,10 @@ export type MessageContentProps = HTMLAttributes<HTMLDivElement>;
3030
export const MessageContent = ({ children, className, ...props }: MessageContentProps) => (
3131
<div
3232
className={cn(
33-
'is-user:dark flex w-fit flex-col gap-2 overflow-hidden text-sm',
34-
'group-[.is-user]:bg-secondary group-[.is-user]:text-foreground group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:px-4 group-[.is-user]:py-3',
33+
'is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm',
34+
'group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground',
3535
'group-[.is-assistant]:text-foreground',
36-
className
36+
className,
3737
)}
3838
{...props}
3939
>
@@ -168,7 +168,7 @@ export const MessageBranchContent = ({ children, ...props }: MessageBranchConten
168168
<div
169169
className={cn(
170170
'grid gap-2 overflow-hidden [&>div]:pb-0',
171-
index === currentBranch ? 'block' : 'hidden'
171+
index === currentBranch ? 'block' : 'hidden',
172172
)}
173173
key={branch.key}
174174
{...props}
@@ -250,7 +250,7 @@ export const MessageBranchPage = ({ className, ...props }: MessageBranchPageProp
250250

251251
return (
252252
<ButtonGroupText
253-
className={cn('text-muted-foreground border-none bg-transparent shadow-none', className)}
253+
className={cn('border-none bg-transparent text-muted-foreground shadow-none', className)}
254254
{...props}
255255
>
256256
{currentBranch + 1} of {totalBranches}
@@ -267,7 +267,7 @@ export const MessageResponse = memo(
267267
{...props}
268268
/>
269269
),
270-
(prevProps, nextProps) => prevProps.children === nextProps.children
270+
(prevProps, nextProps) => prevProps.children === nextProps.children,
271271
);
272272

273273
MessageResponse.displayName = 'MessageResponse';
@@ -298,7 +298,7 @@ export function MessageAttachment({ data, className, onRemove, ...props }: Messa
298298
{onRemove && (
299299
<Button
300300
aria-label="Remove attachment"
301-
className="bg-background/80 hover:bg-background absolute top-2 right-2 size-6 rounded-full p-0 opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 [&>svg]:size-3"
301+
className="absolute top-2 right-2 size-6 rounded-full bg-background/80 p-0 opacity-0 backdrop-blur-sm transition-opacity hover:bg-background group-hover:opacity-100 [&>svg]:size-3"
302302
onClick={(e) => {
303303
e.stopPropagation();
304304
onRemove();
@@ -315,7 +315,7 @@ export function MessageAttachment({ data, className, onRemove, ...props }: Messa
315315
<>
316316
<Tooltip>
317317
<TooltipTrigger asChild>
318-
<div className="bg-muted text-muted-foreground flex size-full shrink-0 items-center justify-center rounded-lg">
318+
<div className="flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground">
319319
<PaperclipIcon className="size-4" />
320320
</div>
321321
</TooltipTrigger>
@@ -326,7 +326,7 @@ export function MessageAttachment({ data, className, onRemove, ...props }: Messa
326326
{onRemove && (
327327
<Button
328328
aria-label="Remove attachment"
329-
className="hover:bg-accent size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity group-hover:opacity-100 [&>svg]:size-3"
329+
className="size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3"
330330
onClick={(e) => {
331331
e.stopPropagation();
332332
onRemove();

packages/shadcn/components/ai-elements/shimmer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use client';
22

3-
import { type CSSProperties, type ElementType, type JSX, memo, useMemo } from 'react';
4-
import { motion } from 'motion/react';
53
import { cn } from '@/lib/utils';
4+
import { motion } from 'motion/react';
5+
import { type CSSProperties, type ElementType, type JSX, memo, useMemo } from 'react';
66

77
export type TextShimmerProps = {
88
children: string;
@@ -28,8 +28,8 @@ const ShimmerComponent = ({
2828
animate={{ backgroundPosition: '0% center' }}
2929
className={cn(
3030
'relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent',
31-
'[background-repeat:no-repeat,padding-box] [--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))]',
32-
className
31+
'[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]',
32+
className,
3333
)}
3434
initial={{ backgroundPosition: '100% center' }}
3535
style={

packages/shadcn/components/ui/alert.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import * as React from 'react';
2-
import { type VariantProps, cva } from 'class-variance-authority';
2+
import { cva, type VariantProps } from 'class-variance-authority';
3+
34
import { cn } from '@/lib/utils';
45

56
const alertVariants = cva(
6-
'relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current',
7+
'relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current',
78
{
89
variants: {
910
variant: {
1011
default: 'bg-card text-card-foreground',
1112
destructive:
12-
'text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90',
13+
'bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current',
1314
},
1415
},
1516
defaultVariants: {
1617
variant: 'default',
1718
},
18-
}
19+
},
1920
);
2021

2122
function Alert({
@@ -48,8 +49,8 @@ function AlertDescription({ className, ...props }: React.ComponentProps<'div'>)
4849
<div
4950
data-slot="alert-description"
5051
className={cn(
51-
'text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed',
52-
className
52+
'col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed',
53+
className,
5354
)}
5455
{...props}
5556
/>

packages/shadcn/components/ui/button-group.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { type VariantProps, cva } from 'class-variance-authority';
2-
import { Slot } from '@radix-ui/react-slot';
3-
import { Separator } from '@/components/ui/separator';
1+
import { cva, type VariantProps } from 'class-variance-authority';
2+
import { Slot } from 'radix-ui';
3+
44
import { cn } from '@/lib/utils';
5+
import { Separator } from '@/components/ui/separator';
56

67
const buttonGroupVariants = cva(
7-
"flex w-fit items-stretch [&>*]:focus-visible:z-10 [&>*]:focus-visible:relative [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md has-[>[data-slot=button-group]]:gap-2",
8+
"flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1",
89
{
910
variants: {
1011
orientation: {
@@ -17,7 +18,7 @@ const buttonGroupVariants = cva(
1718
defaultVariants: {
1819
orientation: 'horizontal',
1920
},
20-
}
21+
},
2122
);
2223

2324
function ButtonGroup({
@@ -43,13 +44,13 @@ function ButtonGroupText({
4344
}: React.ComponentProps<'div'> & {
4445
asChild?: boolean;
4546
}) {
46-
const Comp = asChild ? Slot : 'div';
47+
const Comp = asChild ? Slot.Root : 'div';
4748

4849
return (
4950
<Comp
5051
className={cn(
51-
"bg-muted flex items-center gap-2 rounded-md border px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
52-
className
52+
"flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
53+
className,
5354
)}
5455
{...props}
5556
/>
@@ -66,8 +67,8 @@ function ButtonGroupSeparator({
6667
data-slot="button-group-separator"
6768
orientation={orientation}
6869
className={cn(
69-
'bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto',
70-
className
70+
'relative m-0! self-stretch bg-input data-[orientation=vertical]:h-auto',
71+
className,
7172
)}
7273
{...props}
7374
/>

packages/shadcn/components/ui/button.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
import * as React from 'react';
2-
import { type VariantProps, cva } from 'class-variance-authority';
3-
import { Slot } from '@radix-ui/react-slot';
2+
import { cva, type VariantProps } from 'class-variance-authority';
3+
import { Slot } from 'radix-ui';
4+
45
import { cn } from '@/lib/utils';
56

67
const buttonVariants = cva(
7-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
8+
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
89
{
910
variants: {
1011
variant: {
1112
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
1213
destructive:
13-
'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
14+
'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40',
1415
outline:
15-
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
16+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50',
1617
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
1718
ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
1819
link: 'text-primary underline-offset-4 hover:underline',
1920
},
2021
size: {
2122
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
22-
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
23+
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
24+
sm: 'h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5',
2325
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
2426
icon: 'size-9',
27+
'icon-xs': "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
2528
'icon-sm': 'size-8',
2629
'icon-lg': 'size-10',
2730
},
@@ -30,24 +33,26 @@ const buttonVariants = cva(
3033
variant: 'default',
3134
size: 'default',
3235
},
33-
}
36+
},
3437
);
3538

3639
function Button({
3740
className,
38-
variant,
39-
size,
41+
variant = 'default',
42+
size = 'default',
4043
asChild = false,
4144
...props
4245
}: React.ComponentProps<'button'> &
4346
VariantProps<typeof buttonVariants> & {
4447
asChild?: boolean;
4548
}) {
46-
const Comp = asChild ? Slot : 'button';
49+
const Comp = asChild ? Slot.Root : 'button';
4750

4851
return (
4952
<Comp
5053
data-slot="button"
54+
data-variant={variant}
55+
data-size={size}
5156
className={cn(buttonVariants({ variant, size, className }))}
5257
{...props}
5358
/>

0 commit comments

Comments
 (0)