@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/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^3.6.
|
|
11
|
-
"@lumx/icons": "^3.6.
|
|
10
|
+
"@lumx/core": "^3.6.2-alpha.0",
|
|
11
|
+
"@lumx/icons": "^3.6.2-alpha.0",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.3.2",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"build:storybook": "storybook build"
|
|
114
114
|
},
|
|
115
115
|
"sideEffects": false,
|
|
116
|
-
"version": "3.6.
|
|
116
|
+
"version": "3.6.2-alpha.0"
|
|
117
117
|
}
|
|
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
|
|
6
6
|
import { Progress, ProgressVariant, Size } from '@lumx/react';
|
|
7
7
|
|
|
8
|
-
import { DOCUMENT } from '@lumx/react/constants';
|
|
8
|
+
import { DIALOG_TRANSITION_DURATION, DOCUMENT } from '@lumx/react/constants';
|
|
9
9
|
import { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';
|
|
10
10
|
import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
|
|
11
11
|
import { useIntersectionObserver } from '@lumx/react/hooks/useIntersectionObserver';
|
|
@@ -185,7 +185,7 @@ export const Dialog: Comp<DialogProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
185
185
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
186
186
|
|
|
187
187
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
188
|
-
const isVisible = useTransitionVisibility(rootRef, Boolean(isOpen), onVisibilityChange);
|
|
188
|
+
const isVisible = useTransitionVisibility(rootRef, Boolean(isOpen), DIALOG_TRANSITION_DURATION, onVisibilityChange);
|
|
189
189
|
|
|
190
190
|
const shouldPreventCloseOnClickAway = preventAutoClose || preventCloseOnClick;
|
|
191
191
|
|
|
@@ -5,7 +5,7 @@ import { createPortal } from 'react-dom';
|
|
|
5
5
|
|
|
6
6
|
import { mdiClose } from '@lumx/icons';
|
|
7
7
|
import { ColorPalette, Emphasis, IconButton, IconButtonProps } from '@lumx/react';
|
|
8
|
-
import { DOCUMENT } from '@lumx/react/constants';
|
|
8
|
+
import { DIALOG_TRANSITION_DURATION, DOCUMENT } from '@lumx/react/constants';
|
|
9
9
|
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
10
10
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
11
11
|
|
|
@@ -88,7 +88,7 @@ export const Lightbox: Comp<LightboxProps, HTMLDivElement> = forwardRef((props,
|
|
|
88
88
|
useDisableBodyScroll(isOpen && wrapperRef.current);
|
|
89
89
|
|
|
90
90
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
91
|
-
const isVisible = useTransitionVisibility(wrapperRef, !!isOpen);
|
|
91
|
+
const isVisible = useTransitionVisibility(wrapperRef, !!isOpen, DIALOG_TRANSITION_DURATION);
|
|
92
92
|
|
|
93
93
|
// Handle focus trap.
|
|
94
94
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -7,7 +7,7 @@ import isFunction from 'lodash/isFunction';
|
|
|
7
7
|
|
|
8
8
|
import { Button, Emphasis, Icon, Kind, Size, Theme } from '@lumx/react';
|
|
9
9
|
|
|
10
|
-
import { DOCUMENT } from '@lumx/react/constants';
|
|
10
|
+
import { DOCUMENT, NOTIFICATION_TRANSITION_DURATION } from '@lumx/react/constants';
|
|
11
11
|
import { NOTIFICATION_CONFIGURATION } from '@lumx/react/components/notification/constants';
|
|
12
12
|
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
13
13
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
@@ -80,7 +80,7 @@ export const Notification: Comp<NotificationProps, HTMLDivElement> = forwardRef(
|
|
|
80
80
|
}
|
|
81
81
|
const { color, icon } = NOTIFICATION_CONFIGURATION[type as Kind] || {};
|
|
82
82
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
83
|
-
const isVisible = useTransitionVisibility(rootRef, !!isOpen);
|
|
83
|
+
const isVisible = useTransitionVisibility(rootRef, !!isOpen, NOTIFICATION_TRANSITION_DURATION);
|
|
84
84
|
const hasAction: boolean = Boolean(onActionClick) && Boolean(actionLabel);
|
|
85
85
|
|
|
86
86
|
const handleCallback = (evt: React.MouseEvent) => {
|
|
@@ -12,6 +12,7 @@ import { userHasReducedMotion } from '@lumx/react/utils/userHasReducedMotion';
|
|
|
12
12
|
export const useTransitionVisibility = (
|
|
13
13
|
ref: RefObject<HTMLElement>,
|
|
14
14
|
isComponentVisible: boolean,
|
|
15
|
+
timeout: number,
|
|
15
16
|
onVisibilityChange?: (isVisible: boolean) => void,
|
|
16
17
|
) => {
|
|
17
18
|
const [isVisible, setVisible] = useState(isComponentVisible);
|
|
@@ -26,22 +27,15 @@ export const useTransitionVisibility = (
|
|
|
26
27
|
const { current: element } = ref;
|
|
27
28
|
|
|
28
29
|
// Transition event is not supported or the user prefers reduced motion.
|
|
29
|
-
// => Skip
|
|
30
|
+
// => Skip and set visibility to false directly.
|
|
30
31
|
if (!element || !window.TransitionEvent || userHasReducedMotion()) {
|
|
31
32
|
setVisible(false);
|
|
32
33
|
return undefined;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setVisible((wasVisible) => !wasVisible);
|
|
39
|
-
};
|
|
40
|
-
element.addEventListener('transitionend', onTransitionEnd);
|
|
41
|
-
return () => {
|
|
42
|
-
element.removeEventListener('transitionend', onTransitionEnd);
|
|
43
|
-
};
|
|
44
|
-
}, [isComponentVisible, ref]);
|
|
36
|
+
const timer = setTimeout(() => setVisible(false), timeout);
|
|
37
|
+
return () => clearTimeout(timer);
|
|
38
|
+
}, [isComponentVisible, ref, timeout]);
|
|
45
39
|
|
|
46
40
|
useEffect(() => {
|
|
47
41
|
if (onVisibilityChange && previousVisibility.current !== isVisible) {
|