@gravity-ui/uikit
Version:
Gravity UI base styling and components
18 lines (17 loc) • 1.18 kB
JavaScript
'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import { Hotkey } from "../Hotkey/index.js";
import { Tooltip } from "../Tooltip/index.js";
import { block } from "../utils/cn.js";
import "./ActionTooltip.css";
const b = block('action-tooltip');
const DEFAULT_OPEN_DELAY = 500;
const DEFAULT_CLOSE_DELAY = 0;
export function ActionTooltip({ title, description, hotkey, openDelay = DEFAULT_OPEN_DELAY, closeDelay = DEFAULT_CLOSE_DELAY, className, ...restProps }) {
const content = React.useMemo(() => (_jsxs(React.Fragment, { children: [_jsxs("div", { className: b('heading'), children: [_jsx("div", { className: b('title'), children: title }), hotkey && _jsx(Hotkey, { view: "dark", value: hotkey, className: b('hotkey') })] }), description && _jsx("div", { className: b('description'), children: description })] })), [title, description, hotkey]);
return (_jsx(Tooltip, { ...restProps,
// eslint-disable-next-line jsx-a11y/aria-role
role: "label", content: content, openDelay: openDelay, closeDelay: closeDelay, className: b(null, className) }));
}
//# sourceMappingURL=ActionTooltip.js.map