@thecb/components 11.11.0-beta.7 → 11.11.0-beta.8
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.cjs.js +100 -48
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +100 -48
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/editable-list/EditableList.js +3 -0
- package/src/components/molecules/tooltip/Tooltip.js +99 -50
- package/src/components/molecules/tooltip/Tooltip.stories.js +20 -9
- package/src/components/molecules/tooltip/index.d.ts +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -40888,6 +40888,7 @@ var EditableList = function EditableList(_ref) {
|
|
|
40888
40888
|
_ref$canAdd = _ref.canAdd,
|
|
40889
40889
|
canAdd = _ref$canAdd === void 0 ? true : _ref$canAdd,
|
|
40890
40890
|
addItem = _ref.addItem,
|
|
40891
|
+
addItemDestination = _ref.addItemDestination,
|
|
40891
40892
|
removeItem = _ref.removeItem,
|
|
40892
40893
|
editItem = _ref.editItem,
|
|
40893
40894
|
itemName = _ref.itemName,
|
|
@@ -40995,6 +40996,8 @@ var EditableList = function EditableList(_ref) {
|
|
|
40995
40996
|
padding: items.length === 0 ? "0" : "1rem 0 0"
|
|
40996
40997
|
}, /*#__PURE__*/React__default.createElement(Placeholder$1, {
|
|
40997
40998
|
text: addText,
|
|
40999
|
+
isLink: !!addItemDestination,
|
|
41000
|
+
destination: addItemDestination,
|
|
40998
41001
|
action: addItem,
|
|
40999
41002
|
dataQa: "Add " + qaPrefix,
|
|
41000
41003
|
"aria-label": addText,
|
|
@@ -51472,6 +51475,7 @@ var fallbackValues$12 = {
|
|
|
51472
51475
|
textColor: textColor$5
|
|
51473
51476
|
};
|
|
51474
51477
|
|
|
51478
|
+
var TOOLTIP_THEME_SOURCE = "Popover";
|
|
51475
51479
|
var Tooltip = function Tooltip(_ref) {
|
|
51476
51480
|
var tooltipID = _ref.tooltipID,
|
|
51477
51481
|
children = _ref.children,
|
|
@@ -51509,15 +51513,17 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51509
51513
|
arrowBottom: "-8px",
|
|
51510
51514
|
arrowLeft: "auto"
|
|
51511
51515
|
} : _ref$arrowPosition,
|
|
51516
|
+
customTriggerRole = _ref.customTriggerRole,
|
|
51512
51517
|
_ref$backgroundColor = _ref.backgroundColor,
|
|
51513
51518
|
backgroundColor = _ref$backgroundColor === void 0 ? WHITE : _ref$backgroundColor;
|
|
51514
51519
|
var closeTimeoutRef = useRef(null);
|
|
51520
|
+
var containerRef = useRef(null);
|
|
51515
51521
|
var _useState = useState(false),
|
|
51516
51522
|
_useState2 = _slicedToArray(_useState, 2),
|
|
51517
51523
|
tooltipOpen = _useState2[0],
|
|
51518
51524
|
setTooltipOpen = _useState2[1];
|
|
51519
51525
|
var themeContext = useContext(ThemeContext);
|
|
51520
|
-
var themeValues = createThemeValues(themeContext, fallbackValues$12,
|
|
51526
|
+
var themeValues = createThemeValues(themeContext, fallbackValues$12, TOOLTIP_THEME_SOURCE);
|
|
51521
51527
|
var top = contentPosition.top,
|
|
51522
51528
|
right = contentPosition.right,
|
|
51523
51529
|
bottom = contentPosition.bottom,
|
|
@@ -51536,35 +51542,43 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51536
51542
|
handleToggleTooltip(false);
|
|
51537
51543
|
}
|
|
51538
51544
|
};
|
|
51539
|
-
|
|
51540
|
-
|
|
51541
|
-
|
|
51542
|
-
|
|
51543
|
-
|
|
51544
|
-
|
|
51545
|
-
|
|
51546
|
-
|
|
51547
|
-
|
|
51548
|
-
|
|
51549
|
-
|
|
51550
|
-
|
|
51551
|
-
|
|
51552
|
-
|
|
51553
|
-
|
|
51554
|
-
|
|
51555
|
-
|
|
51556
|
-
|
|
51557
|
-
|
|
51545
|
+
|
|
51546
|
+
/**
|
|
51547
|
+
* Renders the tooltip trigger element.
|
|
51548
|
+
*
|
|
51549
|
+
* When `hasCustomTrigger` is true, the provided child element is cloned and
|
|
51550
|
+
* injected with the event handlers needed to control tooltip visibility:
|
|
51551
|
+
* - onFocus/onBlur: open and close for keyboard users
|
|
51552
|
+
* - onKeyDown: allows Escape to dismiss the tooltip
|
|
51553
|
+
* - onTouchStart: open on tap for touch/mobile users (onFocus is unreliable on touch)
|
|
51554
|
+
*
|
|
51555
|
+
* Mouse interactions (hover) are handled at the container level via
|
|
51556
|
+
* onMouseEnter/onMouseLeave, so they do not need to be injected here.
|
|
51557
|
+
*
|
|
51558
|
+
* Any existing event handlers on the child are preserved and called first,
|
|
51559
|
+
* so the child's own behavior is not overridden.
|
|
51560
|
+
*
|
|
51561
|
+
* When no custom trigger is provided, a default ButtonWithAction is rendered
|
|
51562
|
+
* using `triggerText` and `triggerButtonVariant`.
|
|
51563
|
+
*/
|
|
51558
51564
|
var renderTrigger = function renderTrigger() {
|
|
51565
|
+
if (hasCustomTrigger && !children) {
|
|
51566
|
+
console.warn("Tooltip: children prop is required when hasCustomTrigger is true");
|
|
51567
|
+
}
|
|
51559
51568
|
if (hasCustomTrigger && children) {
|
|
51560
|
-
var _child$props, _child$props2;
|
|
51569
|
+
var _child$props, _child$props$tabIndex, _child$props2, _child$props3, _child$props4;
|
|
51561
51570
|
var child = React__default.Children.only(children);
|
|
51571
|
+
// Capture the child's existing handlers before overwriting
|
|
51562
51572
|
var _ref2 = (_child$props = child.props) !== null && _child$props !== void 0 ? _child$props : {},
|
|
51563
51573
|
childOnFocus = _ref2.onFocus,
|
|
51564
51574
|
childOnBlur = _ref2.onBlur,
|
|
51565
|
-
childOnKeyDown = _ref2.onKeyDown
|
|
51575
|
+
childOnKeyDown = _ref2.onKeyDown,
|
|
51576
|
+
childOnTouchStart = _ref2.onTouchStart;
|
|
51566
51577
|
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
51567
|
-
|
|
51578
|
+
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,
|
|
51579
|
+
style: _objectSpread2({
|
|
51580
|
+
cursor: "pointer"
|
|
51581
|
+
}, (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.style),
|
|
51568
51582
|
onFocus: function onFocus(e) {
|
|
51569
51583
|
childOnFocus === null || childOnFocus === void 0 || childOnFocus(e);
|
|
51570
51584
|
handleToggleTooltip(true);
|
|
@@ -51577,33 +51591,71 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51577
51591
|
childOnKeyDown === null || childOnKeyDown === void 0 || childOnKeyDown(e);
|
|
51578
51592
|
handleKeyDown(e);
|
|
51579
51593
|
},
|
|
51580
|
-
|
|
51581
|
-
|
|
51582
|
-
|
|
51583
|
-
}
|
|
51594
|
+
onTouchStart: function onTouchStart(e) {
|
|
51595
|
+
childOnTouchStart === null || childOnTouchStart === void 0 || childOnTouchStart(e);
|
|
51596
|
+
handleToggleTooltip(true);
|
|
51597
|
+
},
|
|
51598
|
+
role: customTriggerRole || ((_child$props4 = child.props) === null || _child$props4 === void 0 ? void 0 : _child$props4.role),
|
|
51599
|
+
"aria-describedby": tooltipID,
|
|
51600
|
+
"data-qa": "tooltip-trigger-".concat(tooltipID)
|
|
51601
|
+
});
|
|
51602
|
+
} else {
|
|
51603
|
+
return /*#__PURE__*/React__default.createElement(ButtonWithAction, {
|
|
51604
|
+
action: noop$1,
|
|
51605
|
+
onKeyDown: handleKeyDown,
|
|
51606
|
+
variant: triggerButtonVariant,
|
|
51607
|
+
text: triggerText,
|
|
51608
|
+
tabIndex: 0,
|
|
51609
|
+
ariaDescribedby: tooltipID,
|
|
51610
|
+
onFocus: function onFocus() {
|
|
51611
|
+
return handleToggleTooltip(true);
|
|
51612
|
+
},
|
|
51613
|
+
onBlur: function onBlur() {
|
|
51614
|
+
return handleToggleTooltip(false);
|
|
51615
|
+
},
|
|
51616
|
+
onTouchStart: function onTouchStart() {
|
|
51617
|
+
return handleToggleTooltip(true);
|
|
51618
|
+
},
|
|
51619
|
+
dataQa: "tooltip-trigger-".concat(tooltipID),
|
|
51620
|
+
extraStyles: "\n color: ".concat(themeValues.linkColor, ";\n &:hover { color: ").concat(themeValues.hoverColor, "; text-decoration: none;}\n &:active, &:focus { color: ").concat(themeValues.activeColor, ";text-decoration: none;}\n button, span, &:hover span { text-decoration: none; }\n ")
|
|
51584
51621
|
});
|
|
51585
51622
|
}
|
|
51586
|
-
return /*#__PURE__*/React__default.createElement(ButtonWithAction, {
|
|
51587
|
-
action: noop$1,
|
|
51588
|
-
"aria-describedby": tooltipID,
|
|
51589
|
-
onKeyDown: handleKeyDown,
|
|
51590
|
-
variant: triggerButtonVariant,
|
|
51591
|
-
onFocus: function onFocus() {
|
|
51592
|
-
return handleToggleTooltip(true);
|
|
51593
|
-
},
|
|
51594
|
-
onBlur: function onBlur() {
|
|
51595
|
-
return handleToggleTooltip(false);
|
|
51596
|
-
},
|
|
51597
|
-
onTouchStart: function onTouchStart() {
|
|
51598
|
-
return handleToggleTooltip(true);
|
|
51599
|
-
},
|
|
51600
|
-
"data-qa": "tooltip-trigger-".concat(tooltipID),
|
|
51601
|
-
text: triggerText,
|
|
51602
|
-
tabIndex: "0",
|
|
51603
|
-
extraStyles: "\n color: ".concat(themeValues.linkColor, ";\n &:hover { color: ").concat(themeValues.hoverColor, "; text-decoration: none;}\n &:active, &:focus { color: ").concat(themeValues.activeColor, ";text-decoration: none;}\n button, span, &:hover span { text-decoration: none; }\n ")
|
|
51604
|
-
});
|
|
51605
51623
|
};
|
|
51624
|
+
var handleMouseEnter = function handleMouseEnter() {
|
|
51625
|
+
if (closeTimeoutRef.current) {
|
|
51626
|
+
clearTimeout(closeTimeoutRef.current);
|
|
51627
|
+
closeTimeoutRef.current = null;
|
|
51628
|
+
}
|
|
51629
|
+
handleToggleTooltip(true);
|
|
51630
|
+
};
|
|
51631
|
+
var handleMouseLeave = function handleMouseLeave() {
|
|
51632
|
+
closeTimeoutRef.current = setTimeout(function () {
|
|
51633
|
+
handleToggleTooltip(false);
|
|
51634
|
+
}, 300);
|
|
51635
|
+
};
|
|
51636
|
+
|
|
51637
|
+
// Touch listener effect
|
|
51638
|
+
useEffect$1(function () {
|
|
51639
|
+
if (!tooltipOpen) return;
|
|
51640
|
+
var handleOutsideTouch = function handleOutsideTouch(e) {
|
|
51641
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
51642
|
+
setTooltipOpen(false);
|
|
51643
|
+
}
|
|
51644
|
+
};
|
|
51645
|
+
document.addEventListener("touchstart", handleOutsideTouch);
|
|
51646
|
+
return function () {
|
|
51647
|
+
return document.removeEventListener("touchstart", handleOutsideTouch);
|
|
51648
|
+
};
|
|
51649
|
+
}, [tooltipOpen]);
|
|
51650
|
+
|
|
51651
|
+
// Unmount cleanup only
|
|
51652
|
+
useEffect$1(function () {
|
|
51653
|
+
return function () {
|
|
51654
|
+
if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current);
|
|
51655
|
+
};
|
|
51656
|
+
}, []);
|
|
51606
51657
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
51658
|
+
ref: containerRef,
|
|
51607
51659
|
padding: "0",
|
|
51608
51660
|
extraStyles: "position: relative; ".concat(containerExtraStyles),
|
|
51609
51661
|
onMouseEnter: handleMouseEnter,
|
|
@@ -51621,9 +51673,9 @@ var Tooltip = function Tooltip(_ref) {
|
|
|
51621
51673
|
borderRadius: "4px",
|
|
51622
51674
|
minWidth: minWidth,
|
|
51623
51675
|
maxWidth: maxWidth
|
|
51624
|
-
}, typeof content === "string" ? /*#__PURE__*/React__default.createElement(Text$1, {
|
|
51676
|
+
}, typeof content === "string" && content !== "" ? /*#__PURE__*/React__default.createElement(Text$1, {
|
|
51625
51677
|
color: themeValues.textColor
|
|
51626
|
-
}, content) : content, /*#__PURE__*/React__default.createElement(Box, {
|
|
51678
|
+
}, content) : content !== undefined && content !== null ? content : null, /*#__PURE__*/React__default.createElement(Box, {
|
|
51627
51679
|
padding: "0",
|
|
51628
51680
|
extraStyles: "\n position: absolute;\n content: \"\";\n width: 0;\n height: 0;\n ".concat(arrowBorder(backgroundColor, arrowDirection, "8px"), ";\n filter: drop-shadow(2px 8px 14px black);\n bottom: ").concat(arrowBottom, ";\n right: ").concat(arrowRight, ";\n top: ").concat(arrowTop, ";\n left: ").concat(arrowLeft, ";\n ")
|
|
51629
51681
|
})));
|