Compare commits

...

13 Commits

Author SHA1 Message Date
github-actions[bot]
70c684c224 chore(release): version packages (#5687)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-11-03 12:17:58 +04:00
shadcn
4ff64ba818 feat: remove npm flags (#5686)
* docs: update status table and docs

* feat(shadcn): remove react-19 check

* chore: add changeset
2024-11-03 12:12:41 +04:00
shadcn
500a353816 feat: update home page (#5648) 2024-10-30 21:28:58 +04:00
Nicholas Lim
c830780d62 docs(www): fix diff for peerDependencies (#5640)
Co-authored-by: shadcn <m@shadcn.com>
2024-10-30 17:23:06 +04:00
Felix Lu
debd51a854 refactor(sidebar): improve setOpen callback logic (#5593)
* refactor(sidebar): improve setOpen callback logic
- Simplify state handling
- Ensure consistent cookie setting
- Added ability for users to persist sidebar state via cookies
- Update sidebar.mdx doc with SSR persistence instructions
- Run pnpm registry:build to update component

* docs: updates

---------

Co-authored-by: shadcn <m@shadcn.com>
2024-10-30 17:09:09 +04:00
shadcn
78426dd862 docs: fix diff 2024-10-30 16:31:44 +04:00
shadcn
6e47a94a8f chore: format 2024-10-30 15:40:46 +04:00
Barinderpreet Singh
ab6a856930 Docs: update vite installation docs (#4741)
* docs: update vite installation docs

* Update content config

---------

Co-authored-by: shadcn <m@shadcn.com>
2024-10-30 15:37:32 +04:00
shadcn
b33d3868e9 docs(www): update status for radix icons (#5638) 2024-10-30 11:29:48 +04:00
Maou
9e0a86122a fix(docs): resolve link issue in documentation pages (#5633)
Updated broken link in documentation routing file. 
This ensures that the correct content is loaded based on the slug.
2024-10-30 07:10:15 +00:00
github-actions[bot]
2b276de95a chore(release): version packages (#5625)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-10-29 21:39:58 +04:00
shadcn
64739f8399 feat: react 19 (#5621)
* feat(shadcn): add flag prompt for npm

* docs: add docs for react 19

* chore: add changeset

* test: update snapshots

* docs: add notes for recharts

* docs: fix

* fix

* fix: linting
2024-10-29 21:30:05 +04:00
shadcn
f0cff7e0eb fix: gaps in command and dropdown-menu (#5570)
* fix: gaps in command and dropdown-menu

* chore: update snapshots
2024-10-25 18:13:13 +04:00
32 changed files with 438 additions and 69 deletions

View File

@@ -10,8 +10,8 @@ import {
PageHeaderDescription,
PageHeaderHeading,
} from "@/components/page-header"
import CardsNewYork from "@/registry/new-york/example/cards"
import { Button } from "@/registry/new-york/ui/button"
import MailPage from "@/app/(app)/examples/mail/page"
export default function IndexPage() {
return (
@@ -41,24 +41,22 @@ export default function IndexPage() {
<ExamplesNav className="[&>a:first-child]:text-primary" />
<section className="overflow-hidden rounded-lg border bg-background shadow-md md:hidden md:shadow-xl">
<Image
src="/examples/mail-dark.png"
src="/examples/cards-light.png"
width={1280}
height={727}
alt="Mail"
className="hidden dark:block"
/>
<Image
src="/examples/mail-light.png"
width={1280}
height={727}
alt="Mail"
height={1214}
alt="Cards"
className="block dark:hidden"
/>
<Image
src="/examples/cards-dark.png"
width={1280}
height={1214}
alt="Cards"
className="hidden dark:block"
/>
</section>
<section className="hidden md:block">
<div className="overflow-hidden rounded-lg border bg-background shadow">
<MailPage />
</div>
<section className="hidden md:block [&>div]:p-0">
<CardsNewYork />
</section>
</div>
)

View File

@@ -1,18 +1,19 @@
import { cn } from "@/lib/utils"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/registry/new-york/ui/alert"
interface CalloutProps {
icon?: string
title?: string
children?: React.ReactNode
}
export function Callout({ title, children, icon, ...props }: CalloutProps) {
export function Callout({
title,
children,
icon,
className,
...props
}: React.ComponentProps<typeof Alert> & { icon?: string }) {
return (
<Alert {...props}>
<Alert className={cn("bg-muted/50", className)} {...props}>
{icon && <span className="mr-4 text-2xl">{icon}</span>}
{title && <AlertTitle>{title}</AlertTitle>}
<AlertDescription>{children}</AlertDescription>

View File

@@ -8,6 +8,11 @@ import { cn } from "@/lib/utils"
import { ScrollArea, ScrollBar } from "@/registry/new-york/ui/scroll-area"
const examples = [
{
name: "Examples",
href: "/",
code: "https://github.com/shadcn/ui/tree/main/apps/www/app/(app)/examples/mail",
},
{
name: "Mail",
href: "/examples/mail",

View File

@@ -139,10 +139,10 @@ const components = {
<hr className="my-4 md:my-8" {...props} />
),
table: ({ className, ...props }: React.HTMLAttributes<HTMLTableElement>) => (
<div className="my-6 w-full overflow-y-auto rounded-lg">
<div className="my-6 w-full overflow-y-auto">
<table
className={cn(
"relative w-full overflow-hidden text-sm after:absolute after:inset-0 after:rounded-lg after:ring-1 after:ring-border",
"relative w-full overflow-hidden border-none text-sm",
className
)}
{...props}
@@ -150,12 +150,15 @@ const components = {
</div>
),
tr: ({ className, ...props }: React.HTMLAttributes<HTMLTableRowElement>) => (
<tr className={cn("m-0 border-t", className)} {...props} />
<tr
className={cn("last:border-b-none m-0 border-b", className)}
{...props}
/>
),
th: ({ className, ...props }: React.HTMLAttributes<HTMLTableCellElement>) => (
<th
className={cn(
"border px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right",
"px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right",
className
)}
{...props}
@@ -164,7 +167,7 @@ const components = {
td: ({ className, ...props }: React.HTMLAttributes<HTMLTableCellElement>) => (
<td
className={cn(
"border px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right",
"px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right",
className
)}
{...props}

View File

@@ -71,6 +71,11 @@ export const docsConfig: DocsConfig = {
href: "/docs/cli",
items: [],
},
{
title: "Next.js 15 + React 19",
href: "/docs/react-19",
items: [],
},
{
title: "Typography",
href: "/docs/components/typography",

View File

@@ -45,12 +45,6 @@ We do not wrap Recharts. This means you're not locked into an abstraction. When
## Installation
<Callout className="mt-4">
**Note:** If you are trying to use charts with **React 19** or the **Next.js 15**, you will need the [recharts@alpha](https://github.com/recharts/recharts/releases/tag/v2.13.0-alpha.4) release currently.
</Callout>
<Tabs defaultValue="cli">
<TabsList>
@@ -89,6 +83,27 @@ npx shadcn@latest add chart
}
```
<Step>
To use recharts with React 19 and Next.js 15, you will need to override the
`react-is` dependency.{" "}
</Step>
Add the following to your `package.json`
```json title="package.json"
"overrides": {
"react-is": "^19.0.0-rc-69d4b800-20241021"
}
```
Note: the `react-is` version needs to match the version of React 19 you are using. The above is an example.
<Step>Run `npm install`</Step>
```bash
npm install
```
</Steps>
</TabsContent>
@@ -129,6 +144,27 @@ npm install recharts
}
```
<Step>
To use recharts with React 19 and Next.js 15, you will need to override the
`react-is` dependency.{" "}
</Step>
Add the following to your `package.json`
```json title="package.json"
"overrides": {
"react-is": "^19.0.0-rc-69d4b800-20241021"
}
```
Note: the `react-is` version needs to match the version of React 19 you are using. The above is an example.
<Step>Run `npm install`</Step>
```bash
npm install
```
</Steps>
</TabsContent>

View File

@@ -136,3 +136,27 @@ export function CommandMenu() {
### Combobox
You can use the `<Command />` component as a combobox. See the [Combobox](/docs/components/combobox) page for more information.
## Changelog
### 2024-10-25 Classes for icons
Added `gap-2 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0` to the `<CommandItem />` to automatically style icon inside.
Add the following classes to the `cva` call in your `command.tsx` file.
```tsx showLineNumbers title="command.tsx"
const CommandItem = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Item
ref={ref}
className={cn(
"... gap-2 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
className
)}
{...props}
/>
))
```

View File

@@ -120,3 +120,23 @@ const DropdownMenuItem = React.forwardRef<
/>
))
```
### 2024-10-25 Classes for `<DropdownMenuSubTrigger />`
Added `gap-2 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0` to the `<DropdownMenuSubTrigger />` to automatically style icon inside.
Add the following classes to the `cva` call in your `dropdown-menu.tsx` file.
```tsx title="dropdown-menu.tsx"
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
"flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
inset && "pl-8",
className
)}
{...props}
>
{/* ... */}
</DropdownMenuPrimitive.SubTrigger>
```

View File

@@ -406,6 +406,40 @@ You can change the keyboard shortcut by updating the `SIDEBAR_KEYBOARD_SHORTCUT`
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
```
### Persisted State
The `SidebarProvider` supports persisting the sidebar state across page reloads and server-side rendering. It uses cookies to store the current state of the sidebar. When the sidebar state changes, a default cookie named `sidebar:state` is set with the current open/closed state. This cookie is then read on subsequent page loads to restore the sidebar state.
To persist sidebar state in Next.js, set up your `SidebarProvider` in `app/layout.tsx` like this:
```tsx showLineNumbers title="app/layout.tsx"
import { cookies } from "next/headers"
import { SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar"
import { AppSidebar } from "@/components/app-sidebar"
export async function Layout({ children }: { children: React.ReactNode }) {
const cookieStore = await cookies()
const defaultOpen = cookieStore.get("sidebar:state")?.value === "true"
return (
<SidebarProvider defaultOpen={defaultOpen}>
<AppSidebar />
<main>
<SidebarTrigger />
{children}
</main>
</SidebarProvider>
)
}
```
You can change the name of the cookie by updating the `SIDEBAR_COOKIE_NAME` variable in `sidebar.tsx`.
```tsx showLineNumbers title="components/ui/sidebar.tsx"
const SIDEBAR_COOKIE_NAME = "sidebar:state"
```
## Sidebar
The main `Sidebar` component used to render a collapsible sidebar.
@@ -1323,7 +1357,30 @@ You can find more tips on using states for styling in this [Twitter thread](http
## Changelog
### 2024-10-21
### 2024-10-30 Cookie handling in setOpen
- [#5593](https://github.com/shadcn-ui/ui/pull/5593) - Improved setOpen callback logic in `<SidebarProvider>`.
Update the `setOpen` callback in `<SidebarProvider>` as follows:
```tsx showLineNumbers
const setOpen = React.useCallback(
(value: boolean | ((value: boolean) => boolean)) => {
const openState = typeof value === "function" ? value(open) : value
if (setOpenProp) {
setOpenProp(openState)
} else {
_setOpen(openState)
}
// This sets the cookie to keep the sidebar state.
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
},
[setOpenProp, open]
)
```
### 2024-10-21 Fixed `text-sidebar-foreground`
- [#5491](https://github.com/shadcn-ui/ui/pull/5491) - Moved `text-sidebar-foreground` from `<SidebarProvider>` to `<Sidebar>` component.

View File

@@ -3,6 +3,12 @@ title: Next.js
description: Install and configure Next.js.
---
<Callout>
**If you're using Next.js 15, see the [Next.js 15 + React 19](/docs/react-19) guide.**
</Callout>
<Steps>
### Create project

View File

@@ -23,6 +23,29 @@ npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
```
Add this import header in your main css file, `src/index.css` in our case:
```css {1-3} showLineNumbers
@tailwind base;
@tailwind components;
@tailwind utilities;
/* ... */
```
Configure the tailwind template paths in `tailwind.config.js`:
```js {3}
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./index.html", "./src/**/*.{ts,tsx,js,jsx}"],
theme: {
extend: {},
},
plugins: [],
}
```
### Edit tsconfig.json file
The current version of Vite splits TypeScript configuration into three files, two of which need to be edited.

View File

@@ -0,0 +1,170 @@
---
title: Next.js 15 + React 19
description: Using shadcn/ui with Next.js 15 and React 19.
---
**shadcn/ui is now fully compatible with React 19!**
<Callout className="mt-6">
**The following guide applies to any framework that supports React 19**. I
titled this page "Next.js 15 + React 19" to help people upgrading to Next.js
15 find it. We are working with package maintainers to help upgrade to React
19.
</Callout>
## TL;DR
If you're using `npm`, you can install shadcn/ui dependencies with a flag. The `shadcn` CLI will prompt you to select a flag when you run it. No flags required for pnpm, bun, or yarn.
See [Upgrade Status](#upgrade-status) for the status of React 19 support for each package.
## What's happening?
React 19 is now [rc](https://www.npmjs.com/package/react?activeTab=versions) and is [tested and supported in the latest Next.js 15 release](https://nextjs.org/blog/next-15#react-19).
To support React 19, package maintainers will need to test and update their packages to include React 19 as a peer dependency. This is [already](https://github.com/radix-ui/primitives/pull/2952) [in](https://github.com/pacocoursey/cmdk/pull/318) [progress](https://github.com/emilkowalski/vaul/pull/498).
```diff /^19.0/
"peerDependencies": {
- "react": "^16.8 || ^17.0 || ^18.0",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0"
},
```
<Callout>
You can check if a package lists React 19 as a peer dependency by running
`npm info <package> peerDependencies`.
</Callout>
In the meantime, if you are installing a package that **does not** list React 19 as a peer dependency, you will see an error message like this:
```bash
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: my-app@0.1.0
npm error Found: react@19.0.0-rc-69d4b800-20241021
npm error node_modules/react
npm error react@"19.0.0-rc-69d4b800-20241021" from the root project
```
<Callout>
**Note:** This is npm only. PNPM and Bun will only show a silent warning.
</Callout>
## How to fix this
### Solution 1: `--force` or `--legacy-peer-deps`
You can force install a package with the `--force` or the `--legacy-peer-deps` flag.
```bash
npm i <package> --force
npm i <package> --legacy-peer-deps
```
This will install the package and ignore the peer dependency warnings.
<Accordion type="multiple">
<AccordionItem value="flags">
<AccordionTrigger className="font-medium">
What do the `--force` and `--legacy-peer-deps` flag do?
</AccordionTrigger>
<AccordionContent className="[&_ul]:mt-0">
- `--force`: Ignores and overrides any dependency conflicts, forcing the
installation of packages.
- `--legacy-peer-deps`: Skips strict peer dependency checks, allowing
installation of packages with unmet peer dependencies to avoid errors.
</AccordionContent>
</AccordionItem>
</Accordion>
### Solution 2: Use React 18
You can downgrade `react` and `react-dom` to version 18, which is compatible with the package you are installing and upgrade when the dependency is updated.
```bash
npm i react@18 react-dom@18
```
Whichever solution you choose, make sure you test your app thoroughly to ensure
there are no regressions.
## Using shadcn/ui on Next.js 15
### Using pnpm, bun, or yarn
Follow the instructions in the [installation guide](/docs/installation/next) to install shadcn/ui. No flags are needed.
### Using npm
When you run `npx shadcn@latest init -d`, you will be prompted to select an option to resolve the peer dependency issues.
```bash
It looks like you are using React 19.
Some packages may fail to install due to peer dependency issues (see https://ui.shadcn.com/react-19).
? How would you like to proceed? - Use arrow-keys. Return to submit.
Use --force
Use --legacy-peer-deps
```
You can then run the command with the flag you choose.
## Adding components
The process for adding components is the same as above. Select a flag to resolve the peer dependency issues.
**Remember to always test your app after installing new dependencies.**
## Upgrade Status
To make it easy for you track the progress of the upgrade, I've created a table below with React 19 support status for the shadcn/ui dependencies.
- ✅ - Works with React 19 using npm, pnpm, and bun.
- 🚧 - Works with React 19 using pnpm and bun. Requires flag for npm. PR is in progress.
| Package | Status | Note |
| ---------------------------------------------------------------------------------- | ------ | ----------------------------------------------------------- |
| [radix-ui](https://www.npmjs.com/package/@radix-ui/react-icons) | ✅ | |
| [lucide-react](https://www.npmjs.com/package/lucide-react) | ✅ | |
| [class-variance-authority](https://www.npmjs.com/package/class-variance-authority) | ✅ | Does not list React 19 as a peer dependency. |
| [tailwindcss-animate](https://www.npmjs.com/package/tailwindcss-animate) | ✅ | Does not list React 19 as a peer dependency. |
| [embla-carousel-react](https://www.npmjs.com/package/embla-carousel-react) | ✅ | |
| [recharts](https://www.npmjs.com/package/recharts) | ✅ | See note [below](#recharts) |
| [react-hook-form](https://www.npmjs.com/package/react-hook-form) | ✅ | |
| [react-resizable-panels](https://www.npmjs.com/package/react-resizable-panels) | ✅ | |
| [sonner](https://www.npmjs.com/package/sonner) | ✅ | |
| [react-day-picker](https://www.npmjs.com/package/react-day-picker) | ✅ | Works with flag for npm. Work to upgrade to v9 in progress. |
| [input-otp](https://www.npmjs.com/package/input-otp) | ✅ | |
| [vaul](https://www.npmjs.com/package/vaul) | ✅ | |
| [@radix-ui/react-icons](https://www.npmjs.com/package/@radix-ui/react-icons) | ✅ | |
| [cmdk](https://www.npmjs.com/package/cmdk) | ✅ | |
If you have any questions, please [open an issue](https://github.com/shadcn/ui/issues) on GitHub.
## Recharts
To use recharts with React 19, you will need to override the `react-is` dependency.
<Steps>
<Step>Add the following to your `package.json`</Step>
```json title="package.json"
"overrides": {
"react-is": "^19.0.0-rc-69d4b800-20241021"
}
```
Note: the `react-is` version needs to match the version of React 19 you are using. The above is an example.
<Step>Run `npm install --legacy-peer-deps`</Step>
</Steps>

View File

@@ -58,6 +58,11 @@ const nextConfig = {
destination: "/docs/components/sidebar",
permanent: true,
},
{
source: "/react-19",
destination: "/docs/react-19",
permanent: true,
},
]
},
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -117,7 +117,7 @@ const CommandItem = React.forwardRef<
<CommandPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
className
)}
{...props}

View File

@@ -27,14 +27,14 @@ const DropdownMenuSubTrigger = React.forwardRef<
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
"flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
inset && "pl-8",
className
)}
{...props}
>
{children}
<ChevronRight className="ml-auto h-4 w-4" />
<ChevronRight className="ml-auto" />
</DropdownMenuPrimitive.SubTrigger>
))
DropdownMenuSubTrigger.displayName =

View File

@@ -76,16 +76,15 @@ const SidebarProvider = React.forwardRef<
const open = openProp ?? _open
const setOpen = React.useCallback(
(value: boolean | ((value: boolean) => boolean)) => {
const openState = typeof value === "function" ? value(open) : value
if (setOpenProp) {
return setOpenProp?.(
typeof value === "function" ? value(open) : value
)
setOpenProp(openState)
} else {
_setOpen(openState)
}
_setOpen(value)
// This sets the cookie to keep the sidebar state.
document.cookie = `${SIDEBAR_COOKIE_NAME}=${open}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
},
[setOpenProp, open]
)

View File

@@ -1,3 +1,5 @@
"use client"
import * as React from "react"
import { CheckIcon, PaperPlaneIcon, PlusIcon } from "@radix-ui/react-icons"

View File

@@ -1,3 +1,5 @@
"use client"
import { useTheme } from "next-themes"
import { Line, LineChart, ResponsiveContainer, Tooltip } from "recharts"

View File

@@ -1,3 +1,5 @@
"use client"
import { useTheme } from "next-themes"
import { Bar, BarChart, Line, LineChart, ResponsiveContainer } from "recharts"

View File

@@ -117,7 +117,7 @@ const CommandItem = React.forwardRef<
<CommandPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
className
)}
{...props}

View File

@@ -31,14 +31,14 @@ const DropdownMenuSubTrigger = React.forwardRef<
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
"flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
inset && "pl-8",
className
)}
{...props}
>
{children}
<ChevronRightIcon className="ml-auto h-4 w-4" />
<ChevronRightIcon className="ml-auto" />
</DropdownMenuPrimitive.SubTrigger>
))
DropdownMenuSubTrigger.displayName =

View File

@@ -76,16 +76,15 @@ const SidebarProvider = React.forwardRef<
const open = openProp ?? _open
const setOpen = React.useCallback(
(value: boolean | ((value: boolean) => boolean)) => {
const openState = typeof value === "function" ? value(open) : value
if (setOpenProp) {
return setOpenProp?.(
typeof value === "function" ? value(open) : value
)
setOpenProp(openState)
} else {
_setOpen(openState)
}
_setOpen(value)
// This sets the cookie to keep the sidebar state.
document.cookie = `${SIDEBAR_COOKIE_NAME}=${open}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
},
[setOpenProp, open]
)

View File

@@ -1,5 +1,17 @@
# @shadcn/ui
## 2.1.4
### Patch Changes
- [#5686](https://github.com/shadcn-ui/ui/pull/5686) [`4ff64ba`](https://github.com/shadcn-ui/ui/commit/4ff64ba818d15a094547f845ea294c2e1ab208d4) Thanks [@shadcn](https://github.com/shadcn)! - remove flag for npm
## 2.1.3
### Patch Changes
- [#5621](https://github.com/shadcn-ui/ui/pull/5621) [`64739f8`](https://github.com/shadcn-ui/ui/commit/64739f83991205333867000d7813e82b0d98f871) Thanks [@shadcn](https://github.com/shadcn)! - add flag prompt for npm
## 2.1.2
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "shadcn",
"version": "2.1.2",
"version": "2.1.4",
"description": "Add components to your apps.",
"publishConfig": {
"access": "public"

View File

@@ -25,6 +25,7 @@ export async function updateDependencies(
silent: options.silent,
})?.start()
const packageManager = await getPackageManager(config.resolvedPaths.cwd)
await execa(
packageManager,
[packageManager === "npm" ? "install" : "add", ...dependencies],

View File

@@ -28,7 +28,6 @@ export function cn(...inputs: ClassValue[]) {
}
",
"path": "lib/utils.ts",
"target": "lib/utils.ts",
"type": "registry:lib",
},
{
@@ -60,7 +59,7 @@ Label.displayName = LabelPrimitive.Root.displayName
export { Label }
",
"path": "ui/label.tsx",
"target": "components/ui/label.tsx",
"target": "",
"type": "registry:ui",
},
],
@@ -153,7 +152,7 @@ Button.displayName = "Button"
export { Button, buttonVariants }
",
"path": "ui/button.tsx",
"target": "components/ui/button.tsx",
"target": "",
"type": "registry:ui",
},
],
@@ -231,7 +230,7 @@ Button.displayName = "Button"
export { Button, buttonVariants }
",
"path": "ui/button.tsx",
"target": "components/ui/button.tsx",
"target": "",
"type": "registry:ui",
},
{
@@ -262,7 +261,7 @@ Input.displayName = "Input"
export { Input }
",
"path": "ui/input.tsx",
"target": "components/ui/input.tsx",
"target": "",
"type": "registry:ui",
},
{
@@ -274,7 +273,7 @@ import { Command as CommandPrimitive } from "cmdk"
import { Search } from "lucide-react"
import { cn } from "@/lib/utils"
import { Dialog, DialogContent } from "@/components/ui/dialog"
import { Dialog, DialogContent } from "@/registry/default/ui/dialog"
const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
@@ -385,7 +384,7 @@ const CommandItem = React.forwardRef<
<CommandPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",
"relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
className
)}
{...props}
@@ -423,7 +422,7 @@ export {
}
",
"path": "ui/command.tsx",
"target": "components/ui/command.tsx",
"target": "",
"type": "registry:ui",
},
{
@@ -551,7 +550,7 @@ export {
}
",
"path": "ui/dialog.tsx",
"target": "components/ui/dialog.tsx",
"target": "",
"type": "registry:ui",
},
],