pixelize-design-library 2.2.40 → 2.2.41
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.
|
@@ -33,6 +33,23 @@ function ButtonGroupIcon(_a) {
|
|
|
33
33
|
rightIconDropdown = _a.rightIconDropdown, menulistStyle = _a.menulistStyle, menuItemStyle = _a.menuItemStyle, isLoading = _a.isLoading, _d = _a.divider, divider = _d === void 0 ? true : _d;
|
|
34
34
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
35
35
|
var _e = (0, react_1.useState)(false), isDropdownOpen = _e[0], setIsDropdownOpen = _e[1];
|
|
36
|
+
var textRef = (0, react_1.useRef)(null);
|
|
37
|
+
var _f = (0, react_1.useState)(false), isTextTruncated = _f[0], setIsTextTruncated = _f[1];
|
|
38
|
+
(0, react_1.useEffect)(function () {
|
|
39
|
+
var checkTruncation = function () {
|
|
40
|
+
if (textRef.current) {
|
|
41
|
+
var isTruncated = textRef.current.scrollWidth > textRef.current.clientWidth;
|
|
42
|
+
setIsTextTruncated(isTruncated);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
// Use setTimeout to ensure DOM is fully rendered
|
|
46
|
+
var timeoutId = setTimeout(checkTruncation, 0);
|
|
47
|
+
window.addEventListener("resize", checkTruncation);
|
|
48
|
+
return function () {
|
|
49
|
+
clearTimeout(timeoutId);
|
|
50
|
+
window.removeEventListener("resize", checkTruncation);
|
|
51
|
+
};
|
|
52
|
+
}, [buttonText]);
|
|
36
53
|
var handleRightIconClick = function () {
|
|
37
54
|
setIsDropdownOpen(!isDropdownOpen);
|
|
38
55
|
if (onRightIconClick) {
|
|
@@ -53,12 +70,14 @@ function ButtonGroupIcon(_a) {
|
|
|
53
70
|
backgroundColor: theme.colors.primary[400],
|
|
54
71
|
},
|
|
55
72
|
} })),
|
|
56
|
-
react_1.default.createElement(react_2.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
react_1.default.createElement(react_2.Tooltip, { label: buttonText, isDisabled: !buttonText || !isTextTruncated },
|
|
74
|
+
react_1.default.createElement(react_2.Button, { onClick: onButtonClick, style: buttonStyle, isLoading: isLoading, sx: {
|
|
75
|
+
backgroundColor: theme.colors.primary[500],
|
|
76
|
+
"&:hover": {
|
|
77
|
+
backgroundColor: theme.colors.primary[400],
|
|
78
|
+
},
|
|
79
|
+
}, borderLeft: "1px solid ".concat((_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[300]), borderRight: "1px solid ".concat((_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[300]), maxW: "200px" },
|
|
80
|
+
react_1.default.createElement(react_2.Box, { ref: textRef, as: "span", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", display: "block", width: "100%" }, buttonText))),
|
|
62
81
|
rightIcon && rightIconDropdown ? (react_1.default.createElement(react_2.Menu, { isOpen: isDropdownOpen, onClose: function () { return setIsDropdownOpen(false); } },
|
|
63
82
|
react_1.default.createElement(react_2.MenuButton, { as: react_2.IconButton, "aria-label": "Right icon button", icon: rightIcon, onClick: handleRightIconClick, onBlur: onBlurRightIcon, style: buttonGroupRightIconStyle, sx: {
|
|
64
83
|
backgroundColor: theme.colors.primary[500],
|