@lumx/react 3.9.2-alpha.0 → 3.9.2-alpha.1
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 +19 -8
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/popover/usePopoverStyle.tsx +2 -2
- package/src/components/tooltip/Tooltip.test.tsx +15 -19
- package/src/components/tooltip/Tooltip.tsx +9 -5
- package/src/components/tooltip/useTooltipOpen.tsx +6 -3
- package/src/constants.ts +5 -0
package/index.js
CHANGED
|
@@ -383,6 +383,11 @@ const WINDOW = typeof window !== 'undefined' ? window : undefined;
|
|
|
383
383
|
*/
|
|
384
384
|
const DOCUMENT = typeof document !== 'undefined' ? document : undefined;
|
|
385
385
|
|
|
386
|
+
/**
|
|
387
|
+
* Check if we are running in the simulated DOM jsdom environment
|
|
388
|
+
*/
|
|
389
|
+
const IS_JSDOM_ENV = typeof navigator !== 'undefined' && navigator.userAgent.includes('jsdom');
|
|
390
|
+
|
|
386
391
|
const _excluded = ["prefix"];
|
|
387
392
|
|
|
388
393
|
/**
|
|
@@ -6477,7 +6482,7 @@ function usePopoverStyle(_ref5) {
|
|
|
6477
6482
|
zIndex
|
|
6478
6483
|
} = _ref5;
|
|
6479
6484
|
const [popperElement, setPopperElement] = useState(null);
|
|
6480
|
-
if (
|
|
6485
|
+
if (IS_JSDOM_ENV) {
|
|
6481
6486
|
// Skip all logic; we don't need popover positioning in jsdom.
|
|
6482
6487
|
return {
|
|
6483
6488
|
styles: {},
|
|
@@ -13984,9 +13989,11 @@ function useTooltipOpen(delay, anchorElement) {
|
|
|
13984
13989
|
// Run timer to defer updating the isOpen state.
|
|
13985
13990
|
const deferUpdate = duration => {
|
|
13986
13991
|
if (timer) clearTimeout(timer);
|
|
13987
|
-
|
|
13992
|
+
const update = () => {
|
|
13988
13993
|
setIsOpen(!!shouldOpen);
|
|
13989
|
-
}
|
|
13994
|
+
};
|
|
13995
|
+
// Skip timeout in jsdom env
|
|
13996
|
+
if (IS_JSDOM_ENV) update();else timer = setTimeout(update, duration);
|
|
13990
13997
|
};
|
|
13991
13998
|
const hoverNotSupported = browserDoesNotSupportHover();
|
|
13992
13999
|
const hasTouch = ('ontouchstart' in window);
|
|
@@ -14103,7 +14110,7 @@ const CLASSNAME$1h = getRootClassName(COMPONENT_NAME$1k);
|
|
|
14103
14110
|
*/
|
|
14104
14111
|
const DEFAULT_PROPS$11 = {
|
|
14105
14112
|
placement: Placement.BOTTOM,
|
|
14106
|
-
closeMode: '
|
|
14113
|
+
closeMode: 'unmount'
|
|
14107
14114
|
};
|
|
14108
14115
|
|
|
14109
14116
|
/**
|
|
@@ -14111,6 +14118,9 @@ const DEFAULT_PROPS$11 = {
|
|
|
14111
14118
|
*/
|
|
14112
14119
|
const ARROW_SIZE$1 = 8;
|
|
14113
14120
|
|
|
14121
|
+
// Skip popper logic in jsdom env
|
|
14122
|
+
const usePopperHook = IS_JSDOM_ENV ? () => ({}) : usePopper;
|
|
14123
|
+
|
|
14114
14124
|
/**
|
|
14115
14125
|
* Tooltip component.
|
|
14116
14126
|
*
|
|
@@ -14138,9 +14148,9 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14138
14148
|
const [popperElement, setPopperElement] = useState(null);
|
|
14139
14149
|
const [anchorElement, setAnchorElement] = useState(null);
|
|
14140
14150
|
const {
|
|
14141
|
-
styles,
|
|
14142
|
-
attributes
|
|
14143
|
-
} =
|
|
14151
|
+
styles = {},
|
|
14152
|
+
attributes = {}
|
|
14153
|
+
} = usePopperHook(anchorElement, popperElement, {
|
|
14144
14154
|
placement,
|
|
14145
14155
|
modifiers: [{
|
|
14146
14156
|
name: 'offset',
|
|
@@ -14158,8 +14168,9 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14158
14168
|
const isMounted = isOpen || closeMode === 'hide';
|
|
14159
14169
|
const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isMounted, id, label);
|
|
14160
14170
|
const labelLines = label ? label.split('\n') : [];
|
|
14171
|
+
const tooltipRef = useMergeRefs(ref, setPopperElement, onPopperMount);
|
|
14161
14172
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TooltipContextProvider, null, wrappedChildren), isMounted && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
|
|
14162
|
-
ref:
|
|
14173
|
+
ref: tooltipRef
|
|
14163
14174
|
}, forwardedProps, {
|
|
14164
14175
|
id: id,
|
|
14165
14176
|
role: "tooltip",
|