/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-6b06f3c
 * Released under the MIT license.
 */

/**
 * A helper for creating forwardRef components with generic types.
 * This solves the issue where React's forwardRef doesn't work well with generic components,
 * especially when props include required children from CollectionBase<T> or similar types.
 *
 * @example
 * ```tsx
 * function MySelect<T extends object>(
 *   props: MySelectProps<T>,
 *   ref: DOMRef<HTMLDivElement>
 * ) {
 *   // component implementation
 *   return <div ref={ref}>...</div>;
 * }
 *
 * const MySelectWithRef = forwardRefWithGenerics(MySelect);
 *
 * // Usage:
 * <MySelectWithRef<ItemType> items={items} ref={myRef} />
 * ```
 */
export function forwardRefWithGenerics(component) {
    return function ComponentWithRef(props) {
        const { ref = null, ...otherProps } = props;
        return component(otherProps, ref);
    };
}

        