@lumx/react 3.6.1 → 3.6.2-alpha.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/index.js
CHANGED
|
@@ -383,6 +383,13 @@ function uid(len) {
|
|
|
383
383
|
*/
|
|
384
384
|
const CSS_PREFIX = 'lumx';
|
|
385
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Animation duration constants. Take into consideration that if you change one of these variables,
|
|
388
|
+
* you need to update their scss counterpart as well
|
|
389
|
+
*/
|
|
390
|
+
const DIALOG_TRANSITION_DURATION = 400;
|
|
391
|
+
const NOTIFICATION_TRANSITION_DURATION = 200;
|
|
392
|
+
|
|
386
393
|
/**
|
|
387
394
|
* Delay on hover after which we open or close the tooltip.
|
|
388
395
|
* Only applies to devices supporting pointer hover.
|
|
@@ -2932,7 +2939,7 @@ const userHasReducedMotion = () => {
|
|
|
2932
2939
|
* @param onVisibilityChange Callback called when the visibility changes.
|
|
2933
2940
|
* @return true if the component should be rendered
|
|
2934
2941
|
*/
|
|
2935
|
-
const useTransitionVisibility = (ref, isComponentVisible, onVisibilityChange) => {
|
|
2942
|
+
const useTransitionVisibility = (ref, isComponentVisible, timeout, onVisibilityChange) => {
|
|
2936
2943
|
const [isVisible, setVisible] = useState(isComponentVisible);
|
|
2937
2944
|
const previousVisibility = useRef(isVisible);
|
|
2938
2945
|
|
|
@@ -2947,22 +2954,14 @@ const useTransitionVisibility = (ref, isComponentVisible, onVisibilityChange) =>
|
|
|
2947
2954
|
} = ref;
|
|
2948
2955
|
|
|
2949
2956
|
// Transition event is not supported or the user prefers reduced motion.
|
|
2950
|
-
// => Skip
|
|
2957
|
+
// => Skip and set visibility to false directly.
|
|
2951
2958
|
if (!element || !window.TransitionEvent || userHasReducedMotion()) {
|
|
2952
2959
|
setVisible(false);
|
|
2953
2960
|
return undefined;
|
|
2954
2961
|
}
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
if (e.target !== ref.current || e.propertyName !== 'opacity') return;
|
|
2959
|
-
setVisible(wasVisible => !wasVisible);
|
|
2960
|
-
};
|
|
2961
|
-
element.addEventListener('transitionend', onTransitionEnd);
|
|
2962
|
-
return () => {
|
|
2963
|
-
element.removeEventListener('transitionend', onTransitionEnd);
|
|
2964
|
-
};
|
|
2965
|
-
}, [isComponentVisible, ref]);
|
|
2962
|
+
const timer = setTimeout(() => setVisible(false), timeout);
|
|
2963
|
+
return () => clearTimeout(timer);
|
|
2964
|
+
}, [isComponentVisible, ref, timeout]);
|
|
2966
2965
|
useEffect(() => {
|
|
2967
2966
|
if (onVisibilityChange && previousVisibility.current !== isVisible) {
|
|
2968
2967
|
onVisibilityChange(isVisible);
|
|
@@ -3095,7 +3094,7 @@ const Dialog = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
3095
3094
|
const rootRef = useRef(null);
|
|
3096
3095
|
|
|
3097
3096
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
3098
|
-
const isVisible = useTransitionVisibility(rootRef, Boolean(isOpen), onVisibilityChange);
|
|
3097
|
+
const isVisible = useTransitionVisibility(rootRef, Boolean(isOpen), DIALOG_TRANSITION_DURATION, onVisibilityChange);
|
|
3099
3098
|
const shouldPreventCloseOnClickAway = preventAutoClose || preventCloseOnClick;
|
|
3100
3099
|
return isOpen || isVisible ? /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
|
|
3101
3100
|
ref: mergeRefs(rootRef, ref)
|
|
@@ -7818,7 +7817,7 @@ const Lightbox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
7818
7817
|
useDisableBodyScroll(isOpen && wrapperRef.current);
|
|
7819
7818
|
|
|
7820
7819
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
7821
|
-
const isVisible = useTransitionVisibility(wrapperRef, !!isOpen);
|
|
7820
|
+
const isVisible = useTransitionVisibility(wrapperRef, !!isOpen, DIALOG_TRANSITION_DURATION);
|
|
7822
7821
|
|
|
7823
7822
|
// Handle focus trap.
|
|
7824
7823
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -8625,7 +8624,7 @@ const Notification = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
8625
8624
|
icon
|
|
8626
8625
|
} = NOTIFICATION_CONFIGURATION[type] || {};
|
|
8627
8626
|
const rootRef = useRef(null);
|
|
8628
|
-
const isVisible = useTransitionVisibility(rootRef, !!isOpen);
|
|
8627
|
+
const isVisible = useTransitionVisibility(rootRef, !!isOpen, NOTIFICATION_TRANSITION_DURATION);
|
|
8629
8628
|
const hasAction = Boolean(onActionClick) && Boolean(actionLabel);
|
|
8630
8629
|
const handleCallback = evt => {
|
|
8631
8630
|
if (isFunction(onActionClick)) {
|