@lumx/react 3.9.2-alpha.0 → 3.9.2-alpha.2
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 +49 -42
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/popover/usePopoverStyle.tsx +1 -10
- package/src/components/tooltip/Tooltip.test.tsx +15 -19
- package/src/components/tooltip/Tooltip.tsx +6 -5
- package/src/components/tooltip/useTooltipOpen.tsx +6 -3
- package/src/constants.ts +5 -0
- package/src/hooks/usePopper.ts +9 -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 a true browser
|
|
388
|
+
*/
|
|
389
|
+
const IS_BROWSER = typeof navigator !== 'undefined' && !navigator.userAgent.includes('jsdom');
|
|
390
|
+
|
|
386
391
|
const _excluded = ["prefix"];
|
|
387
392
|
|
|
388
393
|
/**
|
|
@@ -4259,24 +4264,6 @@ function useRestoreFocusOnClose(_ref, popoverElement) {
|
|
|
4259
4264
|
});
|
|
4260
4265
|
}
|
|
4261
4266
|
|
|
4262
|
-
/**
|
|
4263
|
-
* Simple ponyfill for Object.fromEntries
|
|
4264
|
-
*/
|
|
4265
|
-
|
|
4266
|
-
var fromEntries = function fromEntries(entries) {
|
|
4267
|
-
return entries.reduce(function (acc, _ref) {
|
|
4268
|
-
var key = _ref[0],
|
|
4269
|
-
value = _ref[1];
|
|
4270
|
-
acc[key] = value;
|
|
4271
|
-
return acc;
|
|
4272
|
-
}, {});
|
|
4273
|
-
};
|
|
4274
|
-
/**
|
|
4275
|
-
* Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
|
|
4276
|
-
*/
|
|
4277
|
-
|
|
4278
|
-
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? useLayoutEffect : useEffect;
|
|
4279
|
-
|
|
4280
4267
|
var top = 'top';
|
|
4281
4268
|
var bottom = 'bottom';
|
|
4282
4269
|
var right = 'right';
|
|
@@ -6115,6 +6102,24 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
6115
6102
|
defaultModifiers: defaultModifiers
|
|
6116
6103
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
6117
6104
|
|
|
6105
|
+
/**
|
|
6106
|
+
* Simple ponyfill for Object.fromEntries
|
|
6107
|
+
*/
|
|
6108
|
+
|
|
6109
|
+
var fromEntries = function fromEntries(entries) {
|
|
6110
|
+
return entries.reduce(function (acc, _ref) {
|
|
6111
|
+
var key = _ref[0],
|
|
6112
|
+
value = _ref[1];
|
|
6113
|
+
acc[key] = value;
|
|
6114
|
+
return acc;
|
|
6115
|
+
}, {});
|
|
6116
|
+
};
|
|
6117
|
+
/**
|
|
6118
|
+
* Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
|
|
6119
|
+
*/
|
|
6120
|
+
|
|
6121
|
+
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? useLayoutEffect : useEffect;
|
|
6122
|
+
|
|
6118
6123
|
/* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
|
|
6119
6124
|
|
|
6120
6125
|
var hasElementType = typeof Element !== 'undefined';
|
|
@@ -6343,6 +6348,22 @@ var usePopper = function usePopper(referenceElement, popperElement, options) {
|
|
|
6343
6348
|
};
|
|
6344
6349
|
};
|
|
6345
6350
|
|
|
6351
|
+
/** Stub usePopper for use outside of browsers */
|
|
6352
|
+
const useStubPopper = (_a, _p, _ref) => {
|
|
6353
|
+
let {
|
|
6354
|
+
placement
|
|
6355
|
+
} = _ref;
|
|
6356
|
+
return {
|
|
6357
|
+
attributes: {
|
|
6358
|
+
'data-popper-placement': placement
|
|
6359
|
+
},
|
|
6360
|
+
styles: {}
|
|
6361
|
+
};
|
|
6362
|
+
};
|
|
6363
|
+
|
|
6364
|
+
/** Switch hook implementation between environment */
|
|
6365
|
+
const usePopper$1 = IS_BROWSER ? usePopper : useStubPopper;
|
|
6366
|
+
|
|
6346
6367
|
/**
|
|
6347
6368
|
* Different possible placements for the popover.
|
|
6348
6369
|
*/
|
|
@@ -6477,18 +6498,6 @@ function usePopoverStyle(_ref5) {
|
|
|
6477
6498
|
zIndex
|
|
6478
6499
|
} = _ref5;
|
|
6479
6500
|
const [popperElement, setPopperElement] = useState(null);
|
|
6480
|
-
if (navigator.userAgent.includes('jsdom')) {
|
|
6481
|
-
// Skip all logic; we don't need popover positioning in jsdom.
|
|
6482
|
-
return {
|
|
6483
|
-
styles: {},
|
|
6484
|
-
attributes: {},
|
|
6485
|
-
isPositioned: true,
|
|
6486
|
-
popperElement,
|
|
6487
|
-
setPopperElement
|
|
6488
|
-
};
|
|
6489
|
-
}
|
|
6490
|
-
|
|
6491
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6492
6501
|
const [arrowElement, setArrowElement] = useState(null);
|
|
6493
6502
|
const actualOffset = [(_offset$along = offset === null || offset === void 0 ? void 0 : offset.along) !== null && _offset$along !== void 0 ? _offset$along : 0, ((_offset$away = offset === null || offset === void 0 ? void 0 : offset.away) !== null && _offset$away !== void 0 ? _offset$away : 0) + (hasArrow ? ARROW_SIZE : 0)];
|
|
6494
6503
|
const modifiers = [{
|
|
@@ -6530,24 +6539,19 @@ function usePopoverStyle(_ref5) {
|
|
|
6530
6539
|
}
|
|
6531
6540
|
});
|
|
6532
6541
|
}
|
|
6533
|
-
|
|
6534
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6535
6542
|
const {
|
|
6536
6543
|
styles,
|
|
6537
6544
|
attributes,
|
|
6538
6545
|
state,
|
|
6539
6546
|
update
|
|
6540
|
-
} = usePopper(anchorRef.current, popperElement, {
|
|
6547
|
+
} = usePopper$1(anchorRef.current, popperElement, {
|
|
6541
6548
|
placement,
|
|
6542
6549
|
modifiers
|
|
6543
6550
|
});
|
|
6544
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6545
6551
|
useEffect(() => {
|
|
6546
6552
|
update === null || update === void 0 ? void 0 : update();
|
|
6547
6553
|
}, [children, update]);
|
|
6548
6554
|
const position = (_state$placement = state === null || state === void 0 ? void 0 : state.placement) !== null && _state$placement !== void 0 ? _state$placement : placement;
|
|
6549
|
-
|
|
6550
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6551
6555
|
const popoverStyle = useMemo(() => {
|
|
6552
6556
|
const newStyles = _objectSpread2(_objectSpread2(_objectSpread2({}, style), styles.popper), {}, {
|
|
6553
6557
|
zIndex
|
|
@@ -13984,9 +13988,11 @@ function useTooltipOpen(delay, anchorElement) {
|
|
|
13984
13988
|
// Run timer to defer updating the isOpen state.
|
|
13985
13989
|
const deferUpdate = duration => {
|
|
13986
13990
|
if (timer) clearTimeout(timer);
|
|
13987
|
-
|
|
13991
|
+
const update = () => {
|
|
13988
13992
|
setIsOpen(!!shouldOpen);
|
|
13989
|
-
}
|
|
13993
|
+
};
|
|
13994
|
+
// Skip timeout in fake browsers
|
|
13995
|
+
if (!IS_BROWSER) update();else timer = setTimeout(update, duration);
|
|
13990
13996
|
};
|
|
13991
13997
|
const hoverNotSupported = browserDoesNotSupportHover();
|
|
13992
13998
|
const hasTouch = ('ontouchstart' in window);
|
|
@@ -14103,7 +14109,7 @@ const CLASSNAME$1h = getRootClassName(COMPONENT_NAME$1k);
|
|
|
14103
14109
|
*/
|
|
14104
14110
|
const DEFAULT_PROPS$11 = {
|
|
14105
14111
|
placement: Placement.BOTTOM,
|
|
14106
|
-
closeMode: '
|
|
14112
|
+
closeMode: 'unmount'
|
|
14107
14113
|
};
|
|
14108
14114
|
|
|
14109
14115
|
/**
|
|
@@ -14131,7 +14137,7 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14131
14137
|
} = props,
|
|
14132
14138
|
forwardedProps = _objectWithoutProperties(props, _excluded$1q);
|
|
14133
14139
|
// Disable in SSR.
|
|
14134
|
-
if (!DOCUMENT
|
|
14140
|
+
if (!DOCUMENT) {
|
|
14135
14141
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
14136
14142
|
}
|
|
14137
14143
|
const id = useId();
|
|
@@ -14140,7 +14146,7 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14140
14146
|
const {
|
|
14141
14147
|
styles,
|
|
14142
14148
|
attributes
|
|
14143
|
-
} = usePopper(anchorElement, popperElement, {
|
|
14149
|
+
} = usePopper$1(anchorElement, popperElement, {
|
|
14144
14150
|
placement,
|
|
14145
14151
|
modifiers: [{
|
|
14146
14152
|
name: 'offset',
|
|
@@ -14158,8 +14164,9 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14158
14164
|
const isMounted = isOpen || closeMode === 'hide';
|
|
14159
14165
|
const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isMounted, id, label);
|
|
14160
14166
|
const labelLines = label ? label.split('\n') : [];
|
|
14167
|
+
const tooltipRef = useMergeRefs(ref, setPopperElement, onPopperMount);
|
|
14161
14168
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TooltipContextProvider, null, wrappedChildren), isMounted && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
|
|
14162
|
-
ref:
|
|
14169
|
+
ref: tooltipRef
|
|
14163
14170
|
}, forwardedProps, {
|
|
14164
14171
|
id: id,
|
|
14165
14172
|
role: "tooltip",
|