import React from 'react'; import type { StyleReactProps } from '../interfaces'; export type StencilReactExternalProps = PropType & Omit, 'style'> & StyleReactProps; // This will be replaced with React.ForwardedRef when react-output-target is upgraded to React v17 export type StencilReactForwardedRef = ((instance: T | null) => void) | React.MutableRefObject | null; export const setRef = (ref: StencilReactForwardedRef | React.Ref | undefined, value: any) => { if (typeof ref === 'function') { ref(value); } else if (ref != null) { // Cast as a MutableRef so we can assign current (ref as React.MutableRefObject).current = value; } }; export const mergeRefs = ( ...refs: (StencilReactForwardedRef | React.Ref | undefined)[] ): React.RefCallback => { return (value: any) => { refs.forEach((ref) => { setRef(ref, value); }); }; }; export const createForwardRef = (ReactComponent: any, displayName: string) => { const forwardRef = ( props: StencilReactExternalProps, ref: StencilReactForwardedRef ) => { return ; }; forwardRef.displayName = displayName; return React.forwardRef(forwardRef); }; export const defineCustomElement = (tagName: string, customElement: any) => { if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) { customElements.define(tagName, customElement); } }; export * from './attachProps'; export * from './case';