@homecode/ui 4.24.4 → 4.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +1 -0
- package/dist/esm/src/components/Autocomplete/Autocomplete.js +1 -0
- package/dist/esm/src/components/Icon/icons/index.js +1 -0
- package/dist/esm/src/components/Icon/icons/stopInCircle.svg.js +17 -0
- package/dist/esm/src/components/Input/Input.js +1 -0
- package/dist/esm/src/components/InputFile/InputFile.js +1 -0
- package/dist/esm/src/components/Tooltip/Tooltip.js +72 -0
- package/dist/esm/src/components/Tooltip/Tooltip.styl.js +7 -0
- package/dist/esm/types/src/components/Icon/icons/index.d.ts +1 -0
- package/dist/esm/types/src/components/Tooltip/Tooltip.d.ts +14 -0
- package/dist/esm/types/src/components/Tooltip/TooltipProvider.d.ts +4 -0
- package/dist/esm/types/src/components/Tooltip/index.d.ts +3 -0
- package/dist/esm/types/src/components/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -37,6 +37,7 @@ export { Shimmer } from './src/components/Shimmer/Shimmer.js';
|
|
|
37
37
|
export { Spinner } from './src/components/Spinner/Spinner.js';
|
|
38
38
|
export { Table } from './src/components/Table/Table.js';
|
|
39
39
|
export { Tabs } from './src/components/Tabs/Tabs.js';
|
|
40
|
+
export { Tooltip } from './src/components/Tooltip/Tooltip.js';
|
|
40
41
|
export { H1, H2, H3, H4, H5, H6 } from './src/components/Text/Text.js';
|
|
41
42
|
export { Theme } from './src/components/Theme/Theme.js';
|
|
42
43
|
export { VH } from './src/components/VH/VH.js';
|
|
@@ -54,6 +54,7 @@ import '../ProgressCircular/ProgressCircular.styl.js';
|
|
|
54
54
|
import '../Router/Router.js';
|
|
55
55
|
import '../Table/Table.styl.js';
|
|
56
56
|
import '../Tabs/Tabs.styl.js';
|
|
57
|
+
import '../Tooltip/Tooltip.styl.js';
|
|
57
58
|
import '../Text/Text.js';
|
|
58
59
|
import '../Virtualized/Virtualized.styl.js';
|
|
59
60
|
import '../Virtualized/List/List.styl.js';
|
|
@@ -75,6 +75,7 @@ var ICONS = {
|
|
|
75
75
|
soundWave: () => import('./soundWave.svg.js'),
|
|
76
76
|
sparks: () => import('./sparks.svg.js'),
|
|
77
77
|
star: () => import('./star.svg.js'),
|
|
78
|
+
stopInCircle: () => import('./stopInCircle.svg.js'),
|
|
78
79
|
syncArrows: () => import('./syncArrows.svg.js'),
|
|
79
80
|
table: () => import('./table.svg.js'),
|
|
80
81
|
telegram: () => import('./telegram.svg.js'),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
var SvgStopInCircle = function SvgStopInCircle(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
6
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
7
|
+
fill: "currentColor",
|
|
8
|
+
viewBox: "0 0 24 24"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
d: "M12.119.373a11.746 11.746 0 1 0 11.745 11.746A11.746 11.746 0 0 0 12.12.373m5.034 15.102a1.68 1.68 0 0 1-1.678 1.678H8.763a1.68 1.68 0 0 1-1.678-1.678V8.763a1.68 1.68 0 0 1 1.678-1.678h6.712a1.68 1.68 0 0 1 1.678 1.678z",
|
|
11
|
+
style: {
|
|
12
|
+
strokeWidth: 0.838985
|
|
13
|
+
}
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { SvgStopInCircle as default };
|
|
@@ -52,6 +52,7 @@ import '../ProgressCircular/ProgressCircular.styl.js';
|
|
|
52
52
|
import '../Router/Router.js';
|
|
53
53
|
import '../Table/Table.styl.js';
|
|
54
54
|
import '../Tabs/Tabs.styl.js';
|
|
55
|
+
import '../Tooltip/Tooltip.styl.js';
|
|
55
56
|
import '../Text/Text.js';
|
|
56
57
|
import '../Virtualized/Virtualized.styl.js';
|
|
57
58
|
import '../Virtualized/List/List.styl.js';
|
|
@@ -52,6 +52,7 @@ import '../ProgressCircular/ProgressCircular.styl.js';
|
|
|
52
52
|
import '../Router/Router.js';
|
|
53
53
|
import '../Table/Table.styl.js';
|
|
54
54
|
import '../Tabs/Tabs.styl.js';
|
|
55
|
+
import '../Tooltip/Tooltip.styl.js';
|
|
55
56
|
import '../Text/Text.js';
|
|
56
57
|
import '../Virtualized/Virtualized.styl.js';
|
|
57
58
|
import '../Virtualized/List/List.styl.js';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import S from './Tooltip.styl.js';
|
|
4
|
+
import cn from 'classnames';
|
|
5
|
+
|
|
6
|
+
const Tooltip = ({ children, content, delay = 0, direction = 'top', blur = false, }) => {
|
|
7
|
+
const triggerRef = useRef(null);
|
|
8
|
+
const tooltipRef = useRef(null);
|
|
9
|
+
const timeoutRef = useRef();
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const trigger = triggerRef.current;
|
|
12
|
+
const tooltip = tooltipRef.current;
|
|
13
|
+
if (!trigger || !tooltip)
|
|
14
|
+
return;
|
|
15
|
+
const positionTooltip = () => {
|
|
16
|
+
const rect = trigger.getBoundingClientRect();
|
|
17
|
+
const tooltipRect = tooltip.getBoundingClientRect();
|
|
18
|
+
let top = 0;
|
|
19
|
+
let left = 0;
|
|
20
|
+
switch (direction) {
|
|
21
|
+
case 'top':
|
|
22
|
+
top = rect.top - tooltipRect.height - 8;
|
|
23
|
+
left = rect.left + rect.width / 2 - tooltipRect.width / 2;
|
|
24
|
+
break;
|
|
25
|
+
case 'bottom':
|
|
26
|
+
top = rect.bottom + 8;
|
|
27
|
+
left = rect.left + rect.width / 2 - tooltipRect.width / 2;
|
|
28
|
+
break;
|
|
29
|
+
case 'left':
|
|
30
|
+
top = rect.top + rect.height / 2 - tooltipRect.height / 2;
|
|
31
|
+
left = rect.left - tooltipRect.width - 8;
|
|
32
|
+
break;
|
|
33
|
+
case 'right':
|
|
34
|
+
top = rect.top + rect.height / 2 - tooltipRect.height / 2;
|
|
35
|
+
left = rect.right + 8;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
// Ensure tooltip stays within viewport
|
|
39
|
+
const padding = 10;
|
|
40
|
+
left = Math.max(padding, Math.min(left, window.innerWidth - tooltipRect.width - padding));
|
|
41
|
+
top = Math.max(padding, Math.min(top, window.innerHeight - tooltipRect.height - padding));
|
|
42
|
+
tooltip.style.left = `${left}px`;
|
|
43
|
+
tooltip.style.top = `${top}px`;
|
|
44
|
+
};
|
|
45
|
+
const showTooltip = () => {
|
|
46
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
47
|
+
tooltip.showPopover?.();
|
|
48
|
+
positionTooltip();
|
|
49
|
+
}, delay);
|
|
50
|
+
};
|
|
51
|
+
const hideTooltip = () => {
|
|
52
|
+
clearTimeout(timeoutRef.current);
|
|
53
|
+
tooltip.hidePopover?.();
|
|
54
|
+
};
|
|
55
|
+
trigger.addEventListener('mouseenter', showTooltip);
|
|
56
|
+
trigger.addEventListener('mouseleave', hideTooltip);
|
|
57
|
+
trigger.addEventListener('focus', showTooltip);
|
|
58
|
+
trigger.addEventListener('blur', hideTooltip);
|
|
59
|
+
return () => {
|
|
60
|
+
clearTimeout(timeoutRef.current);
|
|
61
|
+
trigger.removeEventListener('mouseenter', showTooltip);
|
|
62
|
+
trigger.removeEventListener('mouseleave', hideTooltip);
|
|
63
|
+
trigger.removeEventListener('focus', showTooltip);
|
|
64
|
+
trigger.removeEventListener('blur', hideTooltip);
|
|
65
|
+
};
|
|
66
|
+
}, [content, delay, direction]);
|
|
67
|
+
if (!content)
|
|
68
|
+
return jsx(Fragment, { children: children });
|
|
69
|
+
return (jsxs(Fragment, { children: [jsx("div", { ref: triggerRef, className: S.trigger, children: children }), jsx("div", { ref: tooltipRef, popover: "manual", className: cn(S.tooltip, blur && S.blur), "data-direction": direction, children: content })] }));
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { Tooltip };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Tooltip_trigger__9GSNV{display:inline-block}.Tooltip_tooltip__tzL8q{word-wrap:break-word;background:var(--decent-color-alpha-900);border-radius:4px;box-shadow:0 0 0 1px var(--accent-color-alpha-100);color:var(--accent-color);font-size:14px;line-height:1.4;margin:0;max-width:250px;padding:6px 12px;pointer-events:none;position:fixed;z-index:9999}.Tooltip_tooltip__tzL8q.Tooltip_blur__SQYHW{-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:var(--decent-color-alpha-500)}.Tooltip_tooltip__tzL8q:after{content:\"\";position:absolute}.Tooltip_tooltip__tzL8q[data-direction=top]{transform:translateY(0)}.Tooltip_tooltip__tzL8q[data-direction=top]:after{left:50%;top:100%;transform:translateX(-50%)}.Tooltip_tooltip__tzL8q[data-direction=bottom]{transform:translateY(0)}.Tooltip_tooltip__tzL8q[data-direction=bottom]:after{bottom:100%;left:50%;transform:translateX(-50%)}.Tooltip_tooltip__tzL8q[data-direction=left]{transform:translateX(0)}.Tooltip_tooltip__tzL8q[data-direction=left]:after{left:100%;top:50%;transform:translateY(-50%)}.Tooltip_tooltip__tzL8q[data-direction=right]{transform:translateX(0)}.Tooltip_tooltip__tzL8q[data-direction=right]:after{right:100%;top:50%;transform:translateY(-50%)}.Tooltip_tooltip__tzL8q:popover-open{animation:Tooltip_fadeIn__Buhx4 .2s ease-out}@keyframes Tooltip_fadeIn__Buhx4{0%{opacity:0}to{opacity:1}}";
|
|
4
|
+
var S = {"trigger":"Tooltip_trigger__9GSNV","tooltip":"Tooltip_tooltip__tzL8q","blur":"Tooltip_blur__SQYHW","fadeIn":"Tooltip_fadeIn__Buhx4"};
|
|
5
|
+
styleInject(css_248z);
|
|
6
|
+
|
|
7
|
+
export { S as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="uilib/components/tooltip/types" />
|
|
2
|
+
export interface TooltipProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
content?: React.ReactNode;
|
|
5
|
+
delay?: number;
|
|
6
|
+
direction?: 'top' | 'bottom' | 'left' | 'right';
|
|
7
|
+
blur?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare module 'react' {
|
|
10
|
+
interface HTMLAttributes<T> {
|
|
11
|
+
popover?: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const Tooltip: ({ children, content, delay, direction, blur, }: TooltipProps) => JSX.Element;
|
|
@@ -37,6 +37,7 @@ export * from './Shimmer/Shimmer';
|
|
|
37
37
|
export * from './Spinner/Spinner';
|
|
38
38
|
export * from './Table/Table';
|
|
39
39
|
export * from './Tabs/Tabs';
|
|
40
|
+
export * from './Tooltip/Tooltip';
|
|
40
41
|
export * from './Text/Text';
|
|
41
42
|
export * from './Theme/Theme';
|
|
42
43
|
export * from './VH/VH';
|