diff --git a/apps/design-system/content/docs/components/scroll-area.mdx b/apps/design-system/content/docs/components/scroll-area.mdx index 55d039eec5a..e7dd5236b6b 100644 --- a/apps/design-system/content/docs/components/scroll-area.mdx +++ b/apps/design-system/content/docs/components/scroll-area.mdx @@ -3,10 +3,9 @@ title: Scroll-area description: Augments native scroll functionality for custom, cross-browser styling. component: true links: - doc: https://www.radix-ui.com/docs/primitives/components/scroll-area - api: https://www.radix-ui.com/docs/primitives/components/scroll-area#api-reference + doc: https://base-ui.com/react/components/scroll-area + api: https://base-ui.com/react/components/scroll-area#api-reference source: - radix: true shadcn: true --- @@ -35,7 +34,7 @@ npx shadcn-ui@latest add scroll-area Install the following dependencies: ```bash -npm install @radix-ui/react-scroll-area +npm install @base-ui/react ``` Copy and paste the following code into your project. diff --git a/apps/docs/features/SearchV2/SearchV2.telemetry.test.tsx b/apps/docs/features/SearchV2/SearchV2.telemetry.test.tsx index cc5d0570da2..b66bbbc3647 100644 --- a/apps/docs/features/SearchV2/SearchV2.telemetry.test.tsx +++ b/apps/docs/features/SearchV2/SearchV2.telemetry.test.tsx @@ -57,14 +57,14 @@ const resultsState: DocsSearchV2State = { query: 'auth', } -// cmdk and Radix lean on browser APIs jsdom doesn't ship +// cmdk and Base UI lean on browser APIs jsdom doesn't ship beforeEach(() => { globalThis.ResizeObserver ??= class { observe() {} unobserve() {} disconnect() {} } - Element.prototype.scrollIntoView ??= () => {} + Element.prototype.getAnimations ??= () => [] searchState = { status: 'initial', key: 0 } aiMessages.length = 0 }) diff --git a/apps/docs/features/ui/CurvedScrollArea.tsx b/apps/docs/features/ui/CurvedScrollArea.tsx index 12130dc9649..95053d938c6 100644 --- a/apps/docs/features/ui/CurvedScrollArea.tsx +++ b/apps/docs/features/ui/CurvedScrollArea.tsx @@ -1,6 +1,5 @@ 'use client' -import { ScrollArea as ScrollAreaPrimitive } from 'radix-ui' import { useCallback, useId, @@ -11,7 +10,7 @@ import { type Ref, type UIEvent, } from 'react' -import { cn } from 'ui' +import { cn, ScrollBar, ScrollRoot, ScrollViewport } from 'ui' interface CurvedScrollAreaProps { children: ReactNode @@ -88,24 +87,19 @@ export function CurvedScrollArea({ } return ( - - {children} - - - - + + @@ -139,6 +133,6 @@ export function CurvedScrollArea({ - + ) } diff --git a/apps/docs/styles/curved-scroll-area.css b/apps/docs/styles/curved-scroll-area.css index 85431de1ab5..85b5653c81c 100644 --- a/apps/docs/styles/curved-scroll-area.css +++ b/apps/docs/styles/curved-scroll-area.css @@ -1,13 +1,7 @@ -.curved-scroll-area[data-scrolled] [data-radix-scroll-area-viewport] > * { +.curved-scroll-area[data-scrolled] [data-slot='scroll-area-content'] { filter: var(--curved-scroll-filter); } .curved-scroll-area-neutral { flood-color: rgb(128 128 128); } - -/* radix wraps the content in a display table, which grows to its widest line. a block keeps - long lines inside the area. radix sets the table inline, so this needs important */ -.curved-scroll-area [data-radix-scroll-area-viewport] > div { - display: block !important; -} diff --git a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx index eb3ec1291f8..699e40e98d3 100644 --- a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx +++ b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/Form/NewScopedTokenForm.tsx @@ -166,7 +166,7 @@ export const NewScopedTokenForm = forwardRef< return ( <> - + {step === 'form' ? (
diff --git a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsx b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsx index 8efd10283e5..d74b0410f17 100644 --- a/apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsx +++ b/apps/studio/components/interfaces/Account/AccessTokens/Scoped/ViewTokenSheet.tsx @@ -150,10 +150,7 @@ export function ViewTokenSheet({ visible, tokenId, onClose }: ViewTokenSheetProp

- {/* Radix wraps viewport children in an inline-styled display:table div that grows to fit - the widest child, which would let one long endpoint path expand the sheet instead of - clipping — force it back to block so widths are bounded and rows can truncate. */} - +
{isTokenLoading && (
diff --git a/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx b/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx index 9e37ae5b7b6..5a61c1357f5 100644 --- a/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx +++ b/apps/studio/components/interfaces/ConnectSheet/ConnectSheet.tsx @@ -180,7 +180,7 @@ export const ConnectSheet = () => { - +
[] diff --git a/packages/docs-search/src/components/SearchPanel.tsx b/packages/docs-search/src/components/SearchPanel.tsx index cd60495d6cb..19f7819cc1e 100644 --- a/packages/docs-search/src/components/SearchPanel.tsx +++ b/packages/docs-search/src/components/SearchPanel.tsx @@ -155,7 +155,7 @@ export function SearchPanel({ {getStatusMessage()}
- + [] + afterEach(() => { cleanup() }) diff --git a/packages/ui/package.json b/packages/ui/package.json index 1c65b347fb7..7d1cff6c6f6 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -15,7 +15,7 @@ "test:report": "open coverage/lcov-report/index.html" }, "dependencies": { - "@base-ui/react": "^1.9.0", + "@base-ui/react": "catalog:", "@tailwindcss/forms": "^0.5.11", "@tailwindcss/typography": "^0.5.19", "class-variance-authority": "^0.7.1", diff --git a/packages/ui/src/components/shadcn/ui/scroll-area.test.tsx b/packages/ui/src/components/shadcn/ui/scroll-area.test.tsx index 1fd3d3f9ab9..49d7be1bcdc 100644 --- a/packages/ui/src/components/shadcn/ui/scroll-area.test.tsx +++ b/packages/ui/src/components/shadcn/ui/scroll-area.test.tsx @@ -1,15 +1,6 @@ import { act, render, screen } from '@testing-library/react' -import type { ComponentProps } from 'react' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -vi.mock('radix-ui', async (importOriginal) => { - const actual = await importOriginal() - const Root = ({ type }: ComponentProps) => ( -
- ) - return { ...actual, ScrollArea: { ...actual.ScrollArea, Root } } -}) - const resizeCallbacks: Array<() => void> = [] // a detached element has no layout, so the browser reports zero for both widths @@ -29,7 +20,7 @@ const mockScrollBarWidth = (width: number) => { const renderScrollType = async () => { // the scroll type lives in module state, so each test needs a fresh module const { ScrollRoot } = await import('./scroll-area') - render() + render() return screen.getByTestId('scroll-root') } @@ -57,13 +48,13 @@ describe('ScrollRoot', () => { it('always shows the bar when the os uses classic scroll bars', async () => { mockScrollBarWidth(15) - expect(await renderScrollType()).toHaveAttribute('data-type', 'auto') + expect(await renderScrollType()).toHaveAttribute('data-scroll-type', 'classic') }) it('shows the bar while scrolling when the os uses overlay scroll bars', async () => { mockScrollBarWidth(0) - expect(await renderScrollType()).toHaveAttribute('data-type', 'scroll') + expect(await renderScrollType()).toHaveAttribute('data-scroll-type', 'overlay') }) it('measures again when the os scroll bar setting changes', async () => { @@ -73,13 +64,13 @@ describe('ScrollRoot', () => { mockScrollBarWidth(15) act(() => resizeCallbacks.forEach((callback) => callback())) - expect(root).toHaveAttribute('data-type', 'auto') + expect(root).toHaveAttribute('data-scroll-type', 'classic') }) - it('falls back to scroll without resizeobserver', async () => { + it('falls back to overlay without resizeobserver', async () => { vi.stubGlobal('ResizeObserver', undefined) mockScrollBarWidth(15) - expect(await renderScrollType()).toHaveAttribute('data-type', 'scroll') + expect(await renderScrollType()).toHaveAttribute('data-scroll-type', 'overlay') }) }) diff --git a/packages/ui/src/components/shadcn/ui/scroll-area.tsx b/packages/ui/src/components/shadcn/ui/scroll-area.tsx index c8352a29342..5616853cc19 100644 --- a/packages/ui/src/components/shadcn/ui/scroll-area.tsx +++ b/packages/ui/src/components/shadcn/ui/scroll-area.tsx @@ -1,12 +1,23 @@ 'use client' -import { ScrollArea as ScrollAreaPrimitive } from 'radix-ui' -import { useSyncExternalStore, type ComponentProps } from 'react' +import { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area' +import { useSyncExternalStore } from 'react' import { cn } from '../../../lib/utils/cn' -type ScrollType = NonNullable -type ScrollRootProps = Omit, 'type'> +type ScrollType = 'classic' | 'overlay' + +interface ScrollRootProps extends Omit { + className?: string +} + +interface ScrollViewportProps extends Omit { + className?: string +} + +interface ScrollBarProps extends Omit { + className?: string +} let scrollType: ScrollType | undefined let probe: HTMLDivElement | undefined @@ -15,7 +26,7 @@ const listeners = new Set<() => void>() const getScrollType = (): ScrollType => { if (scrollType) return scrollType // jsdom has no resizeobserver. there is no cache here, so a test that adds a mock later still measures - if (typeof ResizeObserver === 'undefined') return 'scroll' + if (typeof ResizeObserver === 'undefined') return 'overlay' // the os sends no event for its scroll bar setting. a change resizes this probe's content box, so the observer sees it if (!probe) { @@ -33,7 +44,7 @@ const getScrollType = (): ScrollType => { if (!probe.isConnected) document.body.append(probe) // classic scroll bars take layout width, overlay ones take none - scrollType = probe.offsetWidth > probe.clientWidth ? 'auto' : 'scroll' + scrollType = probe.offsetWidth > probe.clientWidth ? 'classic' : 'overlay' return scrollType } @@ -46,12 +57,12 @@ const ScrollRoot = ({ className, ...props }: ScrollRootProps) => { const type = useSyncExternalStore( subscribeToScrollType, getScrollType, - () => 'scroll' + () => 'overlay' ) return ( @@ -66,27 +77,25 @@ const ScrollArea = ({ children, ...props }: ScrollRootProps) => ( ) -const ScrollViewport = ({ - className, - children, - ...props -}: ComponentProps) => ( - - {children} +const ScrollViewport = ({ className, children, ...props }: ScrollViewportProps) => ( + + + {children} + ) -const ScrollBar = ({ - className, - orientation = 'vertical', - ...props -}: ComponentProps) => ( - // radix hover mode ignores scroll. forcemount keeps the bar mounted, so css shows it on hover and scroll mode shows it on scroll - ( + - - + + ) export { ScrollArea, ScrollBar, ScrollRoot, ScrollViewport } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec7dbacca00..c0b56fc7b80 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -199,6 +199,9 @@ settings: catalogs: default: + '@base-ui/react': + specifier: ^1.9.0 + version: 1.9.0 '@monaco-editor/react': specifier: 4.8.0-rc.3 version: 4.8.0-rc.3 @@ -3001,7 +3004,7 @@ importers: packages/ui: dependencies: '@base-ui/react': - specifier: ^1.9.0 + specifier: 'catalog:' version: 1.9.0(@date-fns/tz@1.4.1)(@types/react@19.2.14)(date-fns@2.30.0)(react-dom@19.2.6(react@19.2.6))(react@19.2.6) '@tailwindcss/forms': specifier: ^0.5.11 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 7fdd45f0930..dc4722730dd 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -11,6 +11,7 @@ updateNotifier: false enableGlobalVirtualStore: false catalog: + '@base-ui/react': ^1.9.0 '@monaco-editor/react': 4.8.0-rc.3 '@sentry/nextjs': ^10.75.2 '@sentry/node': ^10.75.2