UNPKG

@codeworker.br/govbr-tw-react

Version:

Biblioteca de componentes React usando Tailwind CSS que implementa o Padrão Digital de Governo.

28 lines (27 loc) 1.65 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useRef } from "react"; import tooltipVariants from "./variants"; import React from "react"; import BASE_CLASSNAMES from "../../config/baseClassNames"; import { cn, getUIDClassName } from "../../libs/utils"; const Tooltip = (_a) => { var { className, children, variant = "default", position = "bottom" } = _a, props = __rest(_a, ["className", "children", "variant", "position"]); const tooltipRef = useRef(null); const containerRef = useRef(null); const [tipTrigger, tipContent] = React.Children.toArray(children); const suffixCn = getUIDClassName(); const tooltipId = `${BASE_CLASSNAMES.tooltip.content}-${suffixCn}`; return (_jsxs("span", Object.assign({ ref: containerRef, className: cn("group relative flex justify-center align-center", BASE_CLASSNAMES.tooltip.root) }, props, { "aria-describedby": tooltipId, children: [tipTrigger, _jsx("span", { ref: tooltipRef, className: cn(tooltipVariants({ variant, position }), className, BASE_CLASSNAMES.tooltip.content), id: tooltipId, role: "tooltip", children: tipContent })] }))); }; export default Tooltip;