@ayseaistudio/ui-components 3.2.2 → 3.2.3
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/InfoTooltip/InfoTooltip.d.ts +10 -0
- package/dist/InfoTooltip/InfoTooltip.js +7 -0
- package/dist/InfoTooltip/index.d.ts +1 -0
- package/dist/InfoTooltip/index.js +1 -0
- package/dist/InfoTooltip/style.css +35 -0
- package/dist/Label/Label.d.ts +10 -4
- package/dist/Label/Label.js +56 -13
- package/dist/SecondaryButton/style.css +0 -1
- package/dist/TabButton/style.css +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "./style.css";
|
|
3
|
+
type InfoTooltipProps = {
|
|
4
|
+
text: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
icon?: React.JSX.Element;
|
|
7
|
+
withIcon?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const InfoTooltip: React.FC<InfoTooltipProps>;
|
|
10
|
+
export default InfoTooltip;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "./style.css";
|
|
3
|
+
import { IconInfoCircle } from "@tabler/icons-react";
|
|
4
|
+
export const InfoTooltip = ({ text, className, icon, withIcon = true }) => {
|
|
5
|
+
return (_jsxs("div", { className: `info ${className || ""}`.trim(), children: [withIcon ? (icon || _jsx(IconInfoCircle, { className: "icons", size: 16, color: "#5D5D5D" })) : null, _jsx("p", { className: "text-wrapper", children: text })] }));
|
|
6
|
+
};
|
|
7
|
+
export default InfoTooltip;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InfoTooltip } from "./InfoTooltip";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InfoTooltip } from "./InfoTooltip";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.info {
|
|
2
|
+
align-items: flex-start;
|
|
3
|
+
background-color: #ffffff;
|
|
4
|
+
border-radius: 8px;
|
|
5
|
+
box-shadow: var(--drop-shadow-mid);
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: 6px;
|
|
8
|
+
padding: 6px;
|
|
9
|
+
position: relative;
|
|
10
|
+
width: auto;
|
|
11
|
+
max-width: 276px;
|
|
12
|
+
white-space: normal;
|
|
13
|
+
word-break: break-word;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.info .icons {
|
|
17
|
+
height: 16px !important;
|
|
18
|
+
position: relative !important;
|
|
19
|
+
width: 16px !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.info .text-wrapper {
|
|
23
|
+
color: #5d5d5d;
|
|
24
|
+
flex: 1;
|
|
25
|
+
font-family: var(--b2-medium-font-family);
|
|
26
|
+
font-size: var(--b2-medium-font-size);
|
|
27
|
+
font-style: var(--b2-medium-font-style);
|
|
28
|
+
font-weight: var(--b2-medium-font-weight);
|
|
29
|
+
letter-spacing: var(--b2-medium-letter-spacing);
|
|
30
|
+
line-height: var(--b2-medium-line-height);
|
|
31
|
+
margin-top: -1.00px;
|
|
32
|
+
position: relative;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
package/dist/Label/Label.d.ts
CHANGED
|
@@ -14,15 +14,17 @@ interface Props {
|
|
|
14
14
|
spacing?: "off" | "on";
|
|
15
15
|
className: any;
|
|
16
16
|
divClassName?: string;
|
|
17
|
+
onClick?: () => void;
|
|
18
|
+
hover?: boolean;
|
|
19
|
+
tooltip?: string;
|
|
20
|
+
useInfoTooltip?: boolean;
|
|
21
|
+
tooltipWithIcon?: boolean;
|
|
17
22
|
}
|
|
18
23
|
export declare const Label: {
|
|
19
|
-
({ text, title, leftIcon, rightIcon, size, color, version, stroke, bold, spacing, className, divClassName, }: Props): React.JSX.Element;
|
|
24
|
+
({ text, title, leftIcon, rightIcon, size, color, version, stroke, bold, spacing, className, divClassName, onClick, hover, tooltip, useInfoTooltip, tooltipWithIcon, }: Props): React.JSX.Element;
|
|
20
25
|
propTypes: {
|
|
21
26
|
text: PropTypes.Requireable<string>;
|
|
22
27
|
title: PropTypes.Requireable<string>;
|
|
23
|
-
withLeftIcon: PropTypes.Requireable<boolean>;
|
|
24
|
-
withRightIcon: PropTypes.Requireable<boolean>;
|
|
25
|
-
withText: PropTypes.Requireable<boolean>;
|
|
26
28
|
size: PropTypes.Requireable<string>;
|
|
27
29
|
color: PropTypes.Requireable<string>;
|
|
28
30
|
version: PropTypes.Requireable<string>;
|
|
@@ -30,6 +32,10 @@ export declare const Label: {
|
|
|
30
32
|
bold: PropTypes.Requireable<string>;
|
|
31
33
|
spacing: PropTypes.Requireable<string>;
|
|
32
34
|
divClassName: PropTypes.Requireable<string>;
|
|
35
|
+
hover: PropTypes.Requireable<boolean>;
|
|
36
|
+
tooltip: PropTypes.Requireable<string>;
|
|
37
|
+
useInfoTooltip: PropTypes.Requireable<boolean>;
|
|
38
|
+
tooltipWithIcon: PropTypes.Requireable<boolean>;
|
|
33
39
|
};
|
|
34
40
|
};
|
|
35
41
|
export {};
|
package/dist/Label/Label.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
4
5
|
import "./style.css";
|
|
6
|
+
import { InfoTooltip } from "../InfoTooltip";
|
|
5
7
|
const getIconColor = (version, color) => {
|
|
6
8
|
if (version === "primary" && color === "black") {
|
|
7
9
|
return "#5D5D5D";
|
|
@@ -32,21 +34,58 @@ const getIconClassName = (size) => {
|
|
|
32
34
|
};
|
|
33
35
|
return sizeClassMap[size] || "";
|
|
34
36
|
};
|
|
35
|
-
export const Label = ({ text, title, leftIcon, rightIcon, size, color, version, stroke = "off", bold, spacing, className, divClassName, }) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
export const Label = ({ text, title, leftIcon, rightIcon, size, color, version, stroke = "off", bold, spacing, className, divClassName, onClick, hover = false, tooltip = "", useInfoTooltip = false, tooltipWithIcon = true, }) => {
|
|
38
|
+
const strokeClass = stroke === "on" ? "stroke-on" : "stroke-off";
|
|
39
|
+
const tooltipTimerRef = useRef(undefined);
|
|
40
|
+
const [isTooltipVisible, setIsTooltipVisible] = useState(false);
|
|
41
|
+
const labelRef = useRef(null);
|
|
42
|
+
const [anchorPos, setAnchorPos] = useState({ left: 0, top: 0 });
|
|
43
|
+
const hasLabelText = typeof text === "string" && text.trim().length > 0;
|
|
44
|
+
const tooltipText = hasLabelText ? (tooltip || text || "") : (tooltip || "");
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
return () => {
|
|
47
|
+
if (tooltipTimerRef.current) {
|
|
48
|
+
window.clearTimeout(tooltipTimerRef.current);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
const handleMouseEnter = () => {
|
|
53
|
+
if (!tooltipText)
|
|
54
|
+
return;
|
|
55
|
+
const rect = labelRef.current?.getBoundingClientRect();
|
|
56
|
+
if (rect) {
|
|
57
|
+
setAnchorPos({ left: rect.left, top: rect.bottom });
|
|
58
|
+
}
|
|
59
|
+
tooltipTimerRef.current = window.setTimeout(() => {
|
|
60
|
+
setIsTooltipVisible(true);
|
|
61
|
+
}, 150);
|
|
62
|
+
};
|
|
63
|
+
const handleMouseLeave = () => {
|
|
64
|
+
if (tooltipTimerRef.current) {
|
|
65
|
+
window.clearTimeout(tooltipTimerRef.current);
|
|
66
|
+
tooltipTimerRef.current = undefined;
|
|
67
|
+
}
|
|
68
|
+
setIsTooltipVisible(false);
|
|
69
|
+
};
|
|
70
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: `label ${size} ${strokeClass} ${spacing} ${color} ${className} ${hover ? "hover-move" : ""}`, title: title, onClick: onClick, "data-testid": "label", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: { cursor: hover ? "pointer" : "default" }, ref: labelRef, children: [leftIcon && (React.cloneElement(leftIcon, {
|
|
71
|
+
className: getIconClassName(size),
|
|
72
|
+
color: getIconColor(version, color)
|
|
73
|
+
})), text && (_jsx("div", { className: `text-wrapper ${version} bold-${bold} size-${size} color-${color} ${divClassName || ""}`, children: text })), rightIcon && (React.cloneElement(rightIcon, {
|
|
74
|
+
className: getIconClassName(size),
|
|
75
|
+
color: getIconColor(version, color)
|
|
76
|
+
}))] }), isTooltipVisible && useInfoTooltip
|
|
77
|
+
? createPortal(_jsx("div", { style: {
|
|
78
|
+
position: "fixed",
|
|
79
|
+
top: Math.min(anchorPos.top + 6, (typeof window !== "undefined" ? window.innerHeight : 0) - 100),
|
|
80
|
+
left: Math.max(8, Math.min(anchorPos.left, (typeof window !== "undefined" ? window.innerWidth : 0) - 300)),
|
|
81
|
+
zIndex: 9999,
|
|
82
|
+
pointerEvents: "none",
|
|
83
|
+
}, children: _jsx(InfoTooltip, { text: tooltipText, withIcon: tooltipWithIcon }) }), document.body)
|
|
84
|
+
: null] }));
|
|
43
85
|
};
|
|
44
86
|
Label.propTypes = {
|
|
45
87
|
text: PropTypes.string,
|
|
46
88
|
title: PropTypes.string,
|
|
47
|
-
withLeftIcon: PropTypes.bool,
|
|
48
|
-
withRightIcon: PropTypes.bool,
|
|
49
|
-
withText: PropTypes.bool,
|
|
50
89
|
size: PropTypes.oneOf(["large", "x-large", "medium", "small"]),
|
|
51
90
|
color: PropTypes.oneOf([
|
|
52
91
|
"mauve",
|
|
@@ -65,4 +104,8 @@ Label.propTypes = {
|
|
|
65
104
|
bold: PropTypes.oneOf(["off", "on"]),
|
|
66
105
|
spacing: PropTypes.oneOf(["off", "on"]),
|
|
67
106
|
divClassName: PropTypes.string,
|
|
107
|
+
hover: PropTypes.bool,
|
|
108
|
+
tooltip: PropTypes.string,
|
|
109
|
+
useInfoTooltip: PropTypes.bool,
|
|
110
|
+
tooltipWithIcon: PropTypes.bool,
|
|
68
111
|
};
|
package/dist/TabButton/style.css
CHANGED
|
@@ -70,13 +70,20 @@
|
|
|
70
70
|
display: flex;
|
|
71
71
|
top: 272px;
|
|
72
72
|
width: 107px;
|
|
73
|
+
display: flex;
|
|
74
|
+
justify-content: flex-start;
|
|
75
|
+
align-items: center;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
.tab-button.small.left-align {
|
|
76
79
|
display: flex;
|
|
77
80
|
width: 95px;
|
|
81
|
+
display: flex;
|
|
82
|
+
justify-content: flex-start;
|
|
83
|
+
align-items: center;
|
|
78
84
|
}
|
|
79
85
|
|
|
86
|
+
|
|
80
87
|
.tab-button.large .button {
|
|
81
88
|
font-family: var(--h6-medium-font-family);
|
|
82
89
|
font-size: var(--h6-medium-font-size);
|
|
@@ -125,6 +132,7 @@
|
|
|
125
132
|
width: fit-content;
|
|
126
133
|
display: flex;
|
|
127
134
|
justify-content: flex-start;
|
|
135
|
+
align-items: center;
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
.tab-button.large.selected .button {
|
package/dist/index.d.ts
CHANGED
|
@@ -36,3 +36,4 @@ export { Flag } from "./Flag/Flag";
|
|
|
36
36
|
export { MessageInputField } from "./MessageInputField/MessageInputField";
|
|
37
37
|
export { TimeSelector } from "./TimeSelector/TimeSelector";
|
|
38
38
|
export { TabButtonForSidebar } from "./TabButtonForSidebar/TabButtonForSidebar";
|
|
39
|
+
export { InfoTooltip } from "./InfoTooltip/InfoTooltip";
|
package/dist/index.js
CHANGED
|
@@ -36,3 +36,4 @@ export { Flag } from "./Flag/Flag";
|
|
|
36
36
|
export { MessageInputField } from "./MessageInputField/MessageInputField";
|
|
37
37
|
export { TimeSelector } from "./TimeSelector/TimeSelector";
|
|
38
38
|
export { TabButtonForSidebar } from "./TabButtonForSidebar/TabButtonForSidebar";
|
|
39
|
+
export { InfoTooltip } from "./InfoTooltip/InfoTooltip";
|