@lumx/react 3.6.4 → 3.6.5-alpha.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/index.js +24 -20
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/button/IconButton.tsx +1 -8
- package/src/components/popover-dialog/PopoverDialog.stories.tsx +28 -1
- package/src/components/popover-dialog/PopoverDialog.test.tsx +31 -0
- package/src/components/tooltip/Tooltip.test.tsx +30 -1
- package/src/components/tooltip/Tooltip.tsx +1 -1
- package/src/components/tooltip/useInjectTooltipRef.tsx +18 -22
package/index.js
CHANGED
|
@@ -22,7 +22,6 @@ import take from 'lodash/take';
|
|
|
22
22
|
import uniqueId from 'lodash/uniqueId';
|
|
23
23
|
import range from 'lodash/range';
|
|
24
24
|
import chunk from 'lodash/chunk';
|
|
25
|
-
import isUndefined from 'lodash/isUndefined';
|
|
26
25
|
import set from 'lodash/set';
|
|
27
26
|
|
|
28
27
|
function ownKeys(e, r) {
|
|
@@ -1550,9 +1549,6 @@ const IconButton = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1550
1549
|
}, forwardedProps), {
|
|
1551
1550
|
"aria-label": label,
|
|
1552
1551
|
variant: "icon"
|
|
1553
|
-
// Remove the aria-describedby added by the tooltip when it is the same text as the aria-label
|
|
1554
|
-
,
|
|
1555
|
-
"aria-describedby": (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.label) && (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.label) === label && undefined
|
|
1556
1552
|
}), image ? /*#__PURE__*/React.createElement("img", {
|
|
1557
1553
|
// no need to set alt as an aria-label is already set on the button
|
|
1558
1554
|
alt: "",
|
|
@@ -12861,26 +12857,34 @@ Toolbar.defaultProps = DEFAULT_PROPS$10;
|
|
|
12861
12857
|
* @param setAnchorElement Set tooltip anchor element.
|
|
12862
12858
|
* @param isOpen Whether the tooltip is open or not.
|
|
12863
12859
|
* @param id Tooltip id.
|
|
12860
|
+
* @param label Tooltip label.
|
|
12864
12861
|
* @return tooltip anchor.
|
|
12865
12862
|
*/
|
|
12866
|
-
const useInjectTooltipRef = (children, setAnchorElement, isOpen, id) => {
|
|
12863
|
+
const useInjectTooltipRef = (children, setAnchorElement, isOpen, id, label) => {
|
|
12864
|
+
const element = /*#__PURE__*/React.isValidElement(children) ? children : null;
|
|
12865
|
+
const ref = useMergeRefs(element === null || element === void 0 ? void 0 : element.ref, setAnchorElement);
|
|
12867
12866
|
return useMemo(() => {
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12867
|
+
var _element$props, _element$props2;
|
|
12868
|
+
// Non-disabled element
|
|
12869
|
+
if (element && ((_element$props = element.props) === null || _element$props === void 0 ? void 0 : _element$props.disabled) !== true && ((_element$props2 = element.props) === null || _element$props2 === void 0 ? void 0 : _element$props2.isDisabled) !== true) {
|
|
12870
|
+
const props = _objectSpread2(_objectSpread2({}, element.props), {}, {
|
|
12871
|
+
ref
|
|
12872
|
+
});
|
|
12873
|
+
|
|
12874
|
+
// Add current tooltip to the aria-describedby if the label is not already present
|
|
12875
|
+
if (label !== props['aria-label']) {
|
|
12876
|
+
props['aria-describedby'] = [props['aria-describedby'], id].filter(Boolean).join(' ');
|
|
12877
|
+
}
|
|
12878
|
+
return /*#__PURE__*/cloneElement(element, props);
|
|
12878
12879
|
}
|
|
12879
|
-
|
|
12880
|
+
|
|
12881
|
+
// Else add a wrapper around the children
|
|
12882
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12880
12883
|
className: "lumx-tooltip-anchor-wrapper",
|
|
12881
|
-
ref:
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
+
ref: ref,
|
|
12885
|
+
"aria-describedby": isOpen ? id : undefined
|
|
12886
|
+
}, children);
|
|
12887
|
+
}, [element, children, setAnchorElement, isOpen, id, ref, label]);
|
|
12884
12888
|
};
|
|
12885
12889
|
|
|
12886
12890
|
/** Return true if the browser does not support pointer hover */
|
|
@@ -13089,7 +13093,7 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
13089
13093
|
onPopperMount
|
|
13090
13094
|
} = useTooltipOpen(delay, anchorElement);
|
|
13091
13095
|
const isOpen = isActivated || forceOpen;
|
|
13092
|
-
const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isOpen, id);
|
|
13096
|
+
const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isOpen, id, label);
|
|
13093
13097
|
return /*#__PURE__*/React.createElement(React.Fragment, null, wrappedChildren, isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
|
|
13094
13098
|
ref: mergeRefs(ref, setPopperElement, onPopperMount)
|
|
13095
13099
|
}, forwardedProps, {
|