@lumx/react 3.9.2-alpha.7 → 3.9.2-alpha.9

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
@@ -6,8 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/core": "^3.9.2-alpha.7",
10
- "@lumx/icons": "^3.9.2-alpha.7",
9
+ "@lumx/core": "^3.9.2-alpha.9",
10
+ "@lumx/icons": "^3.9.2-alpha.9",
11
11
  "@popperjs/core": "^2.5.4",
12
12
  "body-scroll-lock": "^3.1.5",
13
13
  "classnames": "^2.3.2",
@@ -110,5 +110,5 @@
110
110
  "build:storybook": "storybook build"
111
111
  },
112
112
  "sideEffects": false,
113
- "version": "3.9.2-alpha.7"
113
+ "version": "3.9.2-alpha.9"
114
114
  }
@@ -15,7 +15,7 @@ import { skipRender } from '@lumx/react/utils/skipRender';
15
15
 
16
16
  import { useRestoreFocusOnClose } from './useRestoreFocusOnClose';
17
17
  import { usePopoverStyle } from './usePopoverStyle';
18
- import { Elevation, FitAnchorWidth, Offset, Placement } from './constants';
18
+ import { Elevation, FitAnchorWidth, Offset, Placement, POPOVER_ZINDEX } from './constants';
19
19
 
20
20
  /**
21
21
  * Defines the props of the component.
@@ -88,7 +88,7 @@ const DEFAULT_PROPS: Partial<PopoverProps> = {
88
88
  placement: Placement.AUTO,
89
89
  focusAnchorOnClose: true,
90
90
  usePortal: true,
91
- zIndex: 9999,
91
+ zIndex: POPOVER_ZINDEX,
92
92
  };
93
93
 
94
94
  /** Method to render the popover inside a portal if usePortal is true */
@@ -55,3 +55,8 @@ export type FitAnchorWidth = ValueOf<typeof FitAnchorWidth>;
55
55
  * Arrow size (in pixel).
56
56
  */
57
57
  export const ARROW_SIZE = 14;
58
+
59
+ /**
60
+ * Popover default z-index
61
+ */
62
+ export const POPOVER_ZINDEX = 9999;
@@ -13,7 +13,7 @@ import { TooltipContextProvider } from '@lumx/react/components/tooltip/context';
13
13
  import { useId } from '@lumx/react/hooks/useId';
14
14
  import { usePopper } from '@lumx/react/hooks/usePopper';
15
15
 
16
- import { ARIA_LINK_MODES } from '@lumx/react/components/tooltip/constants';
16
+ import { ARIA_LINK_MODES, TOOLTIP_ZINDEX } from '@lumx/react/components/tooltip/constants';
17
17
  import { useInjectTooltipRef } from './useInjectTooltipRef';
18
18
  import { useTooltipOpen } from './useTooltipOpen';
19
19
 
@@ -55,6 +55,7 @@ const DEFAULT_PROPS: Partial<TooltipProps> = {
55
55
  placement: Placement.BOTTOM,
56
56
  closeMode: 'unmount',
57
57
  ariaLinkMode: 'aria-describedby',
58
+ zIndex: TOOLTIP_ZINDEX,
58
59
  };
59
60
 
60
61
  /**
@@ -70,8 +71,18 @@ const ARROW_SIZE = 8;
70
71
  * @return React element.
71
72
  */
72
73
  export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, ref) => {
73
- const { label, children, className, delay, placement, forceOpen, closeMode, ariaLinkMode, ...forwardedProps } =
74
- props;
74
+ const {
75
+ label,
76
+ children,
77
+ className,
78
+ delay,
79
+ placement,
80
+ forceOpen,
81
+ closeMode,
82
+ ariaLinkMode,
83
+ zIndex,
84
+ ...forwardedProps
85
+ } = props;
75
86
  // Disable in SSR.
76
87
  if (!DOCUMENT) {
77
88
  return <>{children}</>;
@@ -81,7 +92,7 @@ export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, re
81
92
 
82
93
  const [popperElement, setPopperElement] = useState<null | HTMLElement>(null);
83
94
  const [anchorElement, setAnchorElement] = useState<null | HTMLElement>(null);
84
- const { styles, attributes } = usePopper(anchorElement, popperElement, {
95
+ const { styles, attributes, update } = usePopper(anchorElement, popperElement, {
85
96
  placement,
86
97
  modifiers: [
87
98
  {
@@ -104,6 +115,11 @@ export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, re
104
115
  ariaLinkMode: ariaLinkMode as any,
105
116
  });
106
117
 
118
+ // Update on open
119
+ React.useEffect(() => {
120
+ if (isOpen) update?.();
121
+ }, [isOpen, update]);
122
+
107
123
  const labelLines = label ? label.split('\n') : [];
108
124
 
109
125
  const tooltipRef = useMergeRefs(ref, setPopperElement, onPopperMount);
@@ -126,7 +142,7 @@ export const Tooltip: Comp<TooltipProps, HTMLDivElement> = forwardRef((props, re
126
142
  hidden: !isOpen && closeMode === 'hide',
127
143
  }),
128
144
  )}
129
- style={styles.popper}
145
+ style={{ ...styles.popper, zIndex }}
130
146
  {...attributes.popper}
131
147
  >
132
148
  <div className={`${CLASSNAME}__arrow`} />
@@ -1 +1,8 @@
1
+ import { POPOVER_ZINDEX } from '../popover/constants';
2
+
1
3
  export const ARIA_LINK_MODES = ['aria-describedby', 'aria-labelledby'] as const;
4
+
5
+ /**
6
+ * Make sure tooltip appear above popovers.
7
+ */
8
+ export const TOOLTIP_ZINDEX = POPOVER_ZINDEX + 1;
@@ -10,6 +10,7 @@ export { App as Disabled } from './disabled';
10
10
  export { App as Helper } from './helper';
11
11
  export { App as Icon } from './icon';
12
12
  export { App as Invalid } from './invalid';
13
+ export { App as Number } from './number';
13
14
  export { App as Placeholder } from './placeholder';
14
15
  export { App as Required } from './required';
15
16
  export { App as TextAreaInvalid } from './text-area-invalid';