@thecb/components 11.11.0-beta.8 → 11.11.0
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/index.esm.js
CHANGED
|
@@ -51516,7 +51516,13 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51516
51516
|
customTriggerRole = _ref.customTriggerRole,
|
|
51517
51517
|
_ref$backgroundColor = _ref.backgroundColor,
|
|
51518
51518
|
backgroundColor = _ref$backgroundColor === void 0 ? WHITE : _ref$backgroundColor;
|
|
51519
|
+
/**
|
|
51520
|
+
* closeTimeoutRef is used internally to store a timer ID for delaying tooltip close. It will have a `.current` property (the timer ID) when the effect or event handlers set it.
|
|
51521
|
+
*/
|
|
51519
51522
|
var closeTimeoutRef = useRef(null);
|
|
51523
|
+
/**
|
|
51524
|
+
* containerRef is used to store a reference to the container element. It will have a `.current` property (the container element) when the effect or event handlers set it.
|
|
51525
|
+
*/
|
|
51520
51526
|
var containerRef = useRef(null);
|
|
51521
51527
|
var _useState = useState(false),
|
|
51522
51528
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -51544,6 +51550,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51544
51550
|
};
|
|
51545
51551
|
|
|
51546
51552
|
/**
|
|
51553
|
+
* @function renderTrigger
|
|
51547
51554
|
* Renders the tooltip trigger element.
|
|
51548
51555
|
*
|
|
51549
51556
|
* When `hasCustomTrigger` is true, the provided child element is cloned and
|
|
@@ -51568,14 +51575,21 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51568
51575
|
if (hasCustomTrigger && children) {
|
|
51569
51576
|
var _child$props, _child$props$tabIndex, _child$props2, _child$props3, _child$props4;
|
|
51570
51577
|
var child = React__default.Children.only(children);
|
|
51571
|
-
|
|
51578
|
+
/**
|
|
51579
|
+
* Capture the child's existing handlers before overwriting
|
|
51580
|
+
*/
|
|
51572
51581
|
var _ref2 = (_child$props = child.props) !== null && _child$props !== void 0 ? _child$props : {},
|
|
51573
51582
|
childOnFocus = _ref2.onFocus,
|
|
51574
51583
|
childOnBlur = _ref2.onBlur,
|
|
51575
51584
|
childOnKeyDown = _ref2.onKeyDown,
|
|
51576
51585
|
childOnTouchStart = _ref2.onTouchStart;
|
|
51586
|
+
|
|
51587
|
+
/**
|
|
51588
|
+
* Clone the child element and add the necessary event handlers
|
|
51589
|
+
*/
|
|
51577
51590
|
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
51578
51591
|
tabIndex: (_child$props$tabIndex = (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.tabIndex) !== null && _child$props$tabIndex !== void 0 ? _child$props$tabIndex : 0,
|
|
51592
|
+
ariaDescribedby: tooltipID,
|
|
51579
51593
|
style: _objectSpread2({
|
|
51580
51594
|
cursor: "pointer"
|
|
51581
51595
|
}, (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.style),
|
|
@@ -51606,7 +51620,7 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51606
51620
|
variant: triggerButtonVariant,
|
|
51607
51621
|
text: triggerText,
|
|
51608
51622
|
tabIndex: 0,
|
|
51609
|
-
|
|
51623
|
+
"aria-describedby": tooltipID,
|
|
51610
51624
|
onFocus: function onFocus() {
|
|
51611
51625
|
return handleToggleTooltip(true);
|
|
51612
51626
|
},
|
|
@@ -51621,6 +51635,12 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51621
51635
|
});
|
|
51622
51636
|
}
|
|
51623
51637
|
};
|
|
51638
|
+
|
|
51639
|
+
/**
|
|
51640
|
+
* @function handleMouseEnter
|
|
51641
|
+
* Handles the mouse enter event for the tooltip container.
|
|
51642
|
+
* It clears any existing timeout and opens the tooltip.
|
|
51643
|
+
*/
|
|
51624
51644
|
var handleMouseEnter = function handleMouseEnter() {
|
|
51625
51645
|
if (closeTimeoutRef.current) {
|
|
51626
51646
|
clearTimeout(closeTimeoutRef.current);
|
|
@@ -51628,13 +51648,22 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51628
51648
|
}
|
|
51629
51649
|
handleToggleTooltip(true);
|
|
51630
51650
|
};
|
|
51651
|
+
|
|
51652
|
+
/**
|
|
51653
|
+
* @function handleMouseLeave
|
|
51654
|
+
* Handles the mouse leave event for the tooltip container.
|
|
51655
|
+
* It sets a timeout to close the tooltip after 200ms.
|
|
51656
|
+
*/
|
|
51631
51657
|
var handleMouseLeave = function handleMouseLeave() {
|
|
51632
51658
|
closeTimeoutRef.current = setTimeout(function () {
|
|
51633
51659
|
handleToggleTooltip(false);
|
|
51634
|
-
},
|
|
51660
|
+
}, 200);
|
|
51635
51661
|
};
|
|
51636
51662
|
|
|
51637
|
-
|
|
51663
|
+
/**
|
|
51664
|
+
* Handles the touch start event for the tooltip container.
|
|
51665
|
+
* It closes the tooltip if the touch is outside the container.
|
|
51666
|
+
*/
|
|
51638
51667
|
useEffect$1(function () {
|
|
51639
51668
|
if (!tooltipOpen) return;
|
|
51640
51669
|
var handleOutsideTouch = function handleOutsideTouch(e) {
|
|
@@ -51648,10 +51677,12 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51648
51677
|
};
|
|
51649
51678
|
}, [tooltipOpen]);
|
|
51650
51679
|
|
|
51651
|
-
|
|
51680
|
+
/**
|
|
51681
|
+
* Cleans up the timeout when the component unmounts.
|
|
51682
|
+
*/
|
|
51652
51683
|
useEffect$1(function () {
|
|
51653
51684
|
return function () {
|
|
51654
|
-
if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current);
|
|
51685
|
+
if (closeTimeoutRef !== null && closeTimeoutRef !== void 0 && closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current);
|
|
51655
51686
|
};
|
|
51656
51687
|
}, []);
|
|
51657
51688
|
return /*#__PURE__*/React__default.createElement(Box, {
|