@adamjanicki/ui-extended 1.0.6 → 1.0.7
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/components/Popover.js +5 -4
- package/components/Tooltip.js +6 -4
- package/package.json +1 -1
package/components/Popover.js
CHANGED
|
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { useFloating, autoUpdate, offset, useDismiss, } from "@floating-ui/react";
|
|
13
|
+
import { useFloating, autoUpdate, offset, useDismiss, useTransitionStyles, } from "@floating-ui/react";
|
|
14
14
|
var Popover = function (props) {
|
|
15
15
|
var triggerRef = props.triggerRef, open = props.open, _a = props.placement, placement = _a === void 0 ? "bottom" : _a, style = props.style, _b = props.offset, placementOffset = _b === void 0 ? 0 : _b, className = props.className, children = props.children, onClose = props.onClose, _c = props.returnFocusOnEscape, returnFocusOnEscape = _c === void 0 ? true : _c;
|
|
16
16
|
var handleOnClose = function () {
|
|
@@ -31,9 +31,10 @@ var Popover = function (props) {
|
|
|
31
31
|
whileElementsMounted: autoUpdate,
|
|
32
32
|
middleware: middleware,
|
|
33
33
|
}), floatingStyles = _d.floatingStyles, context = _d.context, refs = _d.refs;
|
|
34
|
+
var _e = useTransitionStyles(context, {
|
|
35
|
+
duration: { open: 0, close: 250 }, // default ajui-transition value
|
|
36
|
+
}), isMounted = _e.isMounted, transitionStyles = _e.styles;
|
|
34
37
|
useDismiss(context);
|
|
35
|
-
|
|
36
|
-
return null;
|
|
37
|
-
return (_jsx("div", { ref: refs.setFloating, style: __assign(__assign(__assign({}, (style || {})), floatingStyles), { outline: "none" }), className: className, children: children }));
|
|
38
|
+
return isMounted ? (_jsx("div", { ref: refs.setFloating, style: __assign(__assign(__assign(__assign({}, (style || {})), floatingStyles), transitionStyles), { outline: "none" }), className: className, children: children })) : null;
|
|
38
39
|
};
|
|
39
40
|
export default Popover;
|
package/components/Tooltip.js
CHANGED
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { cloneElement, useState } from "react";
|
|
14
|
-
import { useFloating, useHover, useInteractions, flip, safePolygon, autoUpdate, offset, } from "@floating-ui/react";
|
|
14
|
+
import { useFloating, useHover, useInteractions, flip, safePolygon, autoUpdate, offset, useTransitionStyles, } from "@floating-ui/react";
|
|
15
15
|
var Tooltip = function (props) {
|
|
16
16
|
var children = props.children, content = props.tooltipContent, _a = props.placement, placement = _a === void 0 ? "bottom" : _a, style = props.style, _b = props.offset, placementOffset = _b === void 0 ? 0 : _b, className = props.className, _c = props.disableFlip, disableFlip = _c === void 0 ? false : _c;
|
|
17
17
|
var _d = useState(false), open = _d[0], setOpen = _d[1];
|
|
@@ -27,11 +27,13 @@ var Tooltip = function (props) {
|
|
|
27
27
|
placement: placement,
|
|
28
28
|
}), refs = _e.refs, floatingStyles = _e.floatingStyles, context = _e.context;
|
|
29
29
|
var hover = useHover(context, {
|
|
30
|
-
delay: { open: 200, close: 100 },
|
|
31
30
|
handleClose: safePolygon(),
|
|
32
31
|
mouseOnly: true,
|
|
33
32
|
});
|
|
34
|
-
var _f =
|
|
35
|
-
|
|
33
|
+
var _f = useTransitionStyles(context, {
|
|
34
|
+
duration: 250, // default ajui-transition value
|
|
35
|
+
}), isMounted = _f.isMounted, transitionStyles = _f.styles;
|
|
36
|
+
var _g = useInteractions([hover]), getReferenceProps = _g.getReferenceProps, getFloatingProps = _g.getFloatingProps;
|
|
37
|
+
return (_jsxs(_Fragment, { children: [cloneElement(children, __assign({ ref: refs.setReference }, getReferenceProps())), isMounted && (_jsx("div", __assign({ ref: refs.setFloating, style: __assign(__assign(__assign({}, (style || {})), floatingStyles), transitionStyles) }, getFloatingProps(), { className: className, children: content })))] }));
|
|
36
38
|
};
|
|
37
39
|
export default Tooltip;
|