UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

36 lines 2.83 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TooltipControlled = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = __importDefault(require("react")); const stylesName_1 = require("../../constants/stylesName/stylesName"); const useMediaDevice_1 = require("../../hooks/useMediaDevice/useMediaDevice"); const useScrollDetectionWithAutoFocus_1 = require("../../hooks/useScrollDetectionWithAutoFocus/useScrollDetectionWithAutoFocus"); const useStyles_1 = require("../../hooks/useStyles/useStyles"); const errorBoundary_1 = require("../../provider/errorBoundary/errorBoundary"); const fallbackComponent_1 = require("../../provider/errorBoundary/fallbackComponent"); const useTooltipAsModal_1 = require("./hooks/useTooltipAsModal"); const useTooltipAsModalAriaLabel_1 = require("./hooks/useTooltipAsModalAriaLabel"); const tooltipStandAlone_1 = require("./tooltipStandAlone"); const TooltipControlledComponent = ({ tooltipAsModal: propTooltipAsModal, ctv, tooltipRef, tooltipAriaLabel, ...props }) => { const styles = (0, useStyles_1.useStyles)(stylesName_1.STYLES_NAME.TOOLTIP, props.variant, ctv); const mediaDevice = (0, useMediaDevice_1.useMediaDevice)(); const innerTooltipRef = react_1.default.useRef(null); const helpAriaLabel = (0, useTooltipAsModalAriaLabel_1.useTooltipAsModalAriaLabel)(innerTooltipRef); const tooltipAsModal = (0, useTooltipAsModal_1.useTooltipAsModal)({ propTooltipAsModal: propTooltipAsModal, styleTooltipAsModal: styles.tooltipAsModal, }); const { hasScroll: contentHasScroll, handleScrollDetection: contentRefHandler } = (0, useScrollDetectionWithAutoFocus_1.useScrollDetectionWithAutoFocus)({ parentElementRef: innerTooltipRef }); react_1.default.useImperativeHandle(tooltipRef, () => { return innerTooltipRef.current; }, []); return ((0, jsx_runtime_1.jsx)(tooltipStandAlone_1.TooltipStandAlone, { ...props, contentHasScroll: contentHasScroll, contentRef: contentRefHandler, mediaDevice: mediaDevice, styles: styles, tooltipAriaLabel: tooltipAriaLabel ?? helpAriaLabel, tooltipAsModal: tooltipAsModal, tooltipRef: innerTooltipRef })); }; TooltipControlledComponent.displayName = 'TooltipControlledComponent'; const TooltipControlled = (props) => ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { fallBackComponent: (0, jsx_runtime_1.jsx)(fallbackComponent_1.FallbackComponent, { children: (0, jsx_runtime_1.jsx)(TooltipControlledComponent, { ...props }) }), children: (0, jsx_runtime_1.jsx)(TooltipControlledComponent, { ...props }) })); exports.TooltipControlled = TooltipControlled; //# sourceMappingURL=tooltipControlled.js.map