UNPKG

@intility/bifrost-react

Version:

React library for Intility's design system, Bifrost.

24 lines (23 loc) 927 B
import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; /** * Wraps a client component as a server component, so that submodules can be assigned to it * @param ClientComponent the component to wrap (function reference) * @param displayName name of the ClientComponent (string) * @returns A Server Component with the same type signature as the input component * @example * Object.assign(wrapClientComponent(Dropdown, "Dropdown"), { * Item: DropdownItem, * }); */ export function wrapClientComponent(ClientComponent, displayName) { const WrappedComponent = /*#__PURE__*/ forwardRef((props, ref)=>{ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return /*#__PURE__*/ _jsx(ClientComponent, { ...props, ref: ref }); }); WrappedComponent.displayName = displayName; return WrappedComponent; }