Migrate UI primitives from Radix to Base UI.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
simoleo89
2026-07-17 18:31:07 +02:00
co-authored by Cursor
parent 90cff7e5d5
commit 25f01b61b3
18 changed files with 510 additions and 846 deletions
+22
View File
@@ -0,0 +1,22 @@
import { isValidElement, type ReactNode } from "react";
/**
* Map Radix-style `asChild` onto Base UI's `render` prop.
*/
export function resolveAsChild(
asChild: boolean | undefined,
children: ReactNode,
render?: any,
): {
render?: any;
children: ReactNode;
} {
if (render != null) return { render, children };
if (asChild && isValidElement(children)) {
return {
render: children,
children: (children.props as { children?: ReactNode }).children,
};
}
return { children };
}