All Downloads are FREE. Search and download functionalities are using the official Maven repository.

components.snippets.Tooltip.TooltipHOC.tsx Maven / Gradle / Ivy

The newest version!
import React, { ComponentType, useContext, forwardRef, cloneElement } from 'react'

import { FactoryContext } from '../../../core/factory/context'
import { FactoryLevels } from '../../../core/factory/factoryLevels'

export interface TooltipHocProps {
    hint?: string | number | React.Component | null
    placement?: string
    tooltipDelay?: number
    className?: string
    trigger?: string
}

// eslint-disable-next-line @typescript-eslint/ban-types
export function TooltipHOC(Component: Function): ComponentType {
    return function WithTooltip(props: TProps) {
        const { getComponent } = useContext(FactoryContext)
        const FactoryTooltip = getComponent('Tooltip', FactoryLevels.SNIPPETS)

        const { hint, className, placement = 'bottom', tooltipDelay = 0, trigger = 'hover' } = props

        if (!hint || !FactoryTooltip) { return  }

        return (
            
                
            
        )
    }
}

const Expandable = forwardRef(
    // @ts-ignore FIXME разобраться
    ({ children, ...rest }, forwardedRef) => cloneElement(children, { ...rest, forwardedRef }),
)

/**
 * Wrapper with TooltipHOC
 * @example
 *  
 
 
 */
export const Tooltip = TooltipHOC(Expandable)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy