@smart-react-components/ui 2.0.0-alpha-41 → 2.0.0-alpha-42
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/Tooltip/index.d.ts +1 -1
- package/Tooltip/index.js +4 -4
- package/package.json +1 -1
package/Tooltip/index.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export interface Props extends Partial<ResponsiveProp<'size', SizeProp>> {
|
|
|
23
23
|
transitionDuration?: number;
|
|
24
24
|
triggerInteraction?: TriggerInteraction;
|
|
25
25
|
}
|
|
26
|
-
declare const Tooltip: React.
|
|
26
|
+
declare const Tooltip: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLElement>>;
|
|
27
27
|
export default Tooltip;
|
package/Tooltip/index.js
CHANGED
|
@@ -17,13 +17,13 @@ const popover_1 = require("../util/popover");
|
|
|
17
17
|
var types_2 = require("../types");
|
|
18
18
|
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_2.Position; } });
|
|
19
19
|
Object.defineProperty(exports, "TriggerInteraction", { enumerable: true, get: function () { return types_2.TriggerInteraction; } });
|
|
20
|
-
const Tooltip = ({ afterHide, afterShow, beforeHide, beforeShow, children, hasHideAnimation = true, hasShowAnimation = true, hoverDelay, isDismissible, isSoft, palette = '!dynamic', position = types_1.Position.TOP, setStatus, size = 'medium', sizeSm, sizeMd, sizeLg, sizeXl, space = 0, status, transitionClassName, transitionDuration, triggerInteraction = types_1.TriggerInteraction.CLICK | types_1.TriggerInteraction.HOVER }) => {
|
|
20
|
+
const Tooltip = react_1.default.forwardRef(({ afterHide, afterShow, beforeHide, beforeShow, children, hasHideAnimation = true, hasShowAnimation = true, hoverDelay, isDismissible, isSoft, palette = '!dynamic', position = types_1.Position.TOP, setStatus, size = 'medium', sizeSm, sizeMd, sizeLg, sizeXl, space = 0, status, transitionClassName, transitionDuration, triggerInteraction = types_1.TriggerInteraction.CLICK | types_1.TriggerInteraction.HOVER }, forwardRef) => {
|
|
21
21
|
var _a;
|
|
22
22
|
const theme = react_1.default.useContext(styled_components_1.ThemeContext);
|
|
23
23
|
const triggerEl = react_1.default.useRef(null);
|
|
24
24
|
const boxEl = react_1.default.useRef(null);
|
|
25
25
|
const arrowEl = react_1.default.useRef(null);
|
|
26
|
-
const getTriggerEl = () => { var _a; return ((_a = children[0].ref) !== null && _a !== void 0 ? _a : triggerEl).current; };
|
|
26
|
+
const getTriggerEl = () => { var _a; return ((_a = forwardRef !== null && forwardRef !== void 0 ? forwardRef : children[0].ref) !== null && _a !== void 0 ? _a : triggerEl).current; };
|
|
27
27
|
const getTransitionDuration = () => transitionDuration !== null && transitionDuration !== void 0 ? transitionDuration : theme.$.transition.tooltipDuration;
|
|
28
28
|
const handlePosition = () => (0, popover_1.calculatePosition)(getTriggerEl(), boxEl.current, null, arrowEl.current, position, space);
|
|
29
29
|
const { getStatus, handleBeforeShow, } = (0, useFixedBoxMethods_1.default)({ beforeShow, boxEl, getTriggerEl, handlePosition, hoverDelay, isDismissible, key: 'tooltip', setStatus, status, triggerInteraction });
|
|
@@ -32,7 +32,7 @@ const Tooltip = ({ afterHide, afterShow, beforeHide, beforeShow, children, hasHi
|
|
|
32
32
|
children[1],
|
|
33
33
|
react_1.default.createElement(PopoverArrow_1.default, { ref: arrowEl }))));
|
|
34
34
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
35
|
-
react_1.default.cloneElement(children[0], { ref: (_a = children[0].ref) !== null && _a !== void 0 ? _a : triggerEl }),
|
|
35
|
+
react_1.default.cloneElement(children[0], { ref: (_a = forwardRef !== null && forwardRef !== void 0 ? forwardRef : children[0].ref) !== null && _a !== void 0 ? _a : triggerEl }),
|
|
36
36
|
(0, dom_1.canBeRenderedInPortal)() ? (0, react_dom_1.createPortal)(content, document.body) : content));
|
|
37
|
-
};
|
|
37
|
+
});
|
|
38
38
|
exports.default = Tooltip;
|