@lumx/react 3.9.2-alpha.1 → 3.9.2-alpha.3
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 +45 -47
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/popover/usePopoverStyle.tsx +2 -11
- package/src/components/tooltip/Tooltip.test.tsx +13 -0
- package/src/components/tooltip/Tooltip.tsx +4 -7
- package/src/components/tooltip/useTooltipOpen.tsx +3 -3
- package/src/constants.ts +2 -2
- package/src/hooks/usePopper.ts +9 -0
package/index.js
CHANGED
|
@@ -384,9 +384,9 @@ const WINDOW = typeof window !== 'undefined' ? window : undefined;
|
|
|
384
384
|
const DOCUMENT = typeof document !== 'undefined' ? document : undefined;
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
|
-
* Check if we are running in
|
|
387
|
+
* Check if we are running in a true browser
|
|
388
388
|
*/
|
|
389
|
-
const
|
|
389
|
+
const IS_BROWSER = typeof navigator !== 'undefined' && !navigator.userAgent.includes('jsdom');
|
|
390
390
|
|
|
391
391
|
const _excluded = ["prefix"];
|
|
392
392
|
|
|
@@ -4264,24 +4264,6 @@ function useRestoreFocusOnClose(_ref, popoverElement) {
|
|
|
4264
4264
|
});
|
|
4265
4265
|
}
|
|
4266
4266
|
|
|
4267
|
-
/**
|
|
4268
|
-
* Simple ponyfill for Object.fromEntries
|
|
4269
|
-
*/
|
|
4270
|
-
|
|
4271
|
-
var fromEntries = function fromEntries(entries) {
|
|
4272
|
-
return entries.reduce(function (acc, _ref) {
|
|
4273
|
-
var key = _ref[0],
|
|
4274
|
-
value = _ref[1];
|
|
4275
|
-
acc[key] = value;
|
|
4276
|
-
return acc;
|
|
4277
|
-
}, {});
|
|
4278
|
-
};
|
|
4279
|
-
/**
|
|
4280
|
-
* Small wrapper around `useLayoutEffect` to get rid of the warning on SSR envs
|
|
4281
|
-
*/
|
|
4282
|
-
|
|
4283
|
-
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && window.document && window.document.createElement ? useLayoutEffect : useEffect;
|
|
4284
|
-
|
|
4285
4267
|
var top = 'top';
|
|
4286
4268
|
var bottom = 'bottom';
|
|
4287
4269
|
var right = 'right';
|
|
@@ -6120,6 +6102,24 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
6120
6102
|
defaultModifiers: defaultModifiers
|
|
6121
6103
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
6122
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
|
+
|
|
6123
6123
|
/* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
|
|
6124
6124
|
|
|
6125
6125
|
var hasElementType = typeof Element !== 'undefined';
|
|
@@ -6348,6 +6348,24 @@ var usePopper = function usePopper(referenceElement, popperElement, options) {
|
|
|
6348
6348
|
};
|
|
6349
6349
|
};
|
|
6350
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
|
+
popper: {
|
|
6359
|
+
'data-popper-placement': placement
|
|
6360
|
+
}
|
|
6361
|
+
},
|
|
6362
|
+
styles: {}
|
|
6363
|
+
};
|
|
6364
|
+
};
|
|
6365
|
+
|
|
6366
|
+
/** Switch hook implementation between environment */
|
|
6367
|
+
const usePopper$1 = IS_BROWSER ? usePopper : useStubPopper;
|
|
6368
|
+
|
|
6351
6369
|
/**
|
|
6352
6370
|
* Different possible placements for the popover.
|
|
6353
6371
|
*/
|
|
@@ -6482,18 +6500,6 @@ function usePopoverStyle(_ref5) {
|
|
|
6482
6500
|
zIndex
|
|
6483
6501
|
} = _ref5;
|
|
6484
6502
|
const [popperElement, setPopperElement] = useState(null);
|
|
6485
|
-
if (IS_JSDOM_ENV) {
|
|
6486
|
-
// Skip all logic; we don't need popover positioning in jsdom.
|
|
6487
|
-
return {
|
|
6488
|
-
styles: {},
|
|
6489
|
-
attributes: {},
|
|
6490
|
-
isPositioned: true,
|
|
6491
|
-
popperElement,
|
|
6492
|
-
setPopperElement
|
|
6493
|
-
};
|
|
6494
|
-
}
|
|
6495
|
-
|
|
6496
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6497
6503
|
const [arrowElement, setArrowElement] = useState(null);
|
|
6498
6504
|
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)];
|
|
6499
6505
|
const modifiers = [{
|
|
@@ -6535,24 +6541,19 @@ function usePopoverStyle(_ref5) {
|
|
|
6535
6541
|
}
|
|
6536
6542
|
});
|
|
6537
6543
|
}
|
|
6538
|
-
|
|
6539
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6540
6544
|
const {
|
|
6541
6545
|
styles,
|
|
6542
6546
|
attributes,
|
|
6543
6547
|
state,
|
|
6544
6548
|
update
|
|
6545
|
-
} = usePopper(anchorRef.current, popperElement, {
|
|
6549
|
+
} = usePopper$1(anchorRef.current, popperElement, {
|
|
6546
6550
|
placement,
|
|
6547
6551
|
modifiers
|
|
6548
6552
|
});
|
|
6549
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6550
6553
|
useEffect(() => {
|
|
6551
6554
|
update === null || update === void 0 ? void 0 : update();
|
|
6552
6555
|
}, [children, update]);
|
|
6553
6556
|
const position = (_state$placement = state === null || state === void 0 ? void 0 : state.placement) !== null && _state$placement !== void 0 ? _state$placement : placement;
|
|
6554
|
-
|
|
6555
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
6556
6557
|
const popoverStyle = useMemo(() => {
|
|
6557
6558
|
const newStyles = _objectSpread2(_objectSpread2(_objectSpread2({}, style), styles.popper), {}, {
|
|
6558
6559
|
zIndex
|
|
@@ -13992,8 +13993,8 @@ function useTooltipOpen(delay, anchorElement) {
|
|
|
13992
13993
|
const update = () => {
|
|
13993
13994
|
setIsOpen(!!shouldOpen);
|
|
13994
13995
|
};
|
|
13995
|
-
// Skip timeout in
|
|
13996
|
-
if (
|
|
13996
|
+
// Skip timeout in fake browsers
|
|
13997
|
+
if (!IS_BROWSER) update();else timer = setTimeout(update, duration);
|
|
13997
13998
|
};
|
|
13998
13999
|
const hoverNotSupported = browserDoesNotSupportHover();
|
|
13999
14000
|
const hasTouch = ('ontouchstart' in window);
|
|
@@ -14118,9 +14119,6 @@ const DEFAULT_PROPS$11 = {
|
|
|
14118
14119
|
*/
|
|
14119
14120
|
const ARROW_SIZE$1 = 8;
|
|
14120
14121
|
|
|
14121
|
-
// Skip popper logic in jsdom env
|
|
14122
|
-
const usePopperHook = IS_JSDOM_ENV ? () => ({}) : usePopper;
|
|
14123
|
-
|
|
14124
14122
|
/**
|
|
14125
14123
|
* Tooltip component.
|
|
14126
14124
|
*
|
|
@@ -14141,16 +14139,16 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14141
14139
|
} = props,
|
|
14142
14140
|
forwardedProps = _objectWithoutProperties(props, _excluded$1q);
|
|
14143
14141
|
// Disable in SSR.
|
|
14144
|
-
if (!DOCUMENT
|
|
14142
|
+
if (!DOCUMENT) {
|
|
14145
14143
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
14146
14144
|
}
|
|
14147
14145
|
const id = useId();
|
|
14148
14146
|
const [popperElement, setPopperElement] = useState(null);
|
|
14149
14147
|
const [anchorElement, setAnchorElement] = useState(null);
|
|
14150
14148
|
const {
|
|
14151
|
-
styles
|
|
14152
|
-
attributes
|
|
14153
|
-
} =
|
|
14149
|
+
styles,
|
|
14150
|
+
attributes
|
|
14151
|
+
} = usePopper$1(anchorElement, popperElement, {
|
|
14154
14152
|
placement,
|
|
14155
14153
|
modifiers: [{
|
|
14156
14154
|
name: 'offset',
|