Migrate UI primitives from Radix to Base UI.
Local Build and Deploy / deploy (push) Successful in 54s
Local Build and Deploy / deploy (push) Successful in 54s
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
90cff7e5d5
commit
25f01b61b3
18 files changed
+510
-846
No files matched your search
@@ -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 };
|
||||
}
|
||||
Reference in new issue
Block a user