@lumx/react 3.9.2-alpha.1 → 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 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 the simulated DOM jsdom environment
387
+ * Check if we are running in a true browser
388
388
  */
389
- const IS_JSDOM_ENV = typeof navigator !== 'undefined' && navigator.userAgent.includes('jsdom');
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,22 @@ 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
+ '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
+
6351
6367
  /**
6352
6368
  * Different possible placements for the popover.
6353
6369
  */
@@ -6482,18 +6498,6 @@ function usePopoverStyle(_ref5) {
6482
6498
  zIndex
6483
6499
  } = _ref5;
6484
6500
  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
6501
  const [arrowElement, setArrowElement] = useState(null);
6498
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)];
6499
6503
  const modifiers = [{
@@ -6535,24 +6539,19 @@ function usePopoverStyle(_ref5) {
6535
6539
  }
6536
6540
  });
6537
6541
  }
6538
-
6539
- // eslint-disable-next-line react-hooks/rules-of-hooks
6540
6542
  const {
6541
6543
  styles,
6542
6544
  attributes,
6543
6545
  state,
6544
6546
  update
6545
- } = usePopper(anchorRef.current, popperElement, {
6547
+ } = usePopper$1(anchorRef.current, popperElement, {
6546
6548
  placement,
6547
6549
  modifiers
6548
6550
  });
6549
- // eslint-disable-next-line react-hooks/rules-of-hooks
6550
6551
  useEffect(() => {
6551
6552
  update === null || update === void 0 ? void 0 : update();
6552
6553
  }, [children, update]);
6553
6554
  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
6555
  const popoverStyle = useMemo(() => {
6557
6556
  const newStyles = _objectSpread2(_objectSpread2(_objectSpread2({}, style), styles.popper), {}, {
6558
6557
  zIndex
@@ -13992,8 +13991,8 @@ function useTooltipOpen(delay, anchorElement) {
13992
13991
  const update = () => {
13993
13992
  setIsOpen(!!shouldOpen);
13994
13993
  };
13995
- // Skip timeout in jsdom env
13996
- if (IS_JSDOM_ENV) update();else timer = setTimeout(update, duration);
13994
+ // Skip timeout in fake browsers
13995
+ if (!IS_BROWSER) update();else timer = setTimeout(update, duration);
13997
13996
  };
13998
13997
  const hoverNotSupported = browserDoesNotSupportHover();
13999
13998
  const hasTouch = ('ontouchstart' in window);
@@ -14118,9 +14117,6 @@ const DEFAULT_PROPS$11 = {
14118
14117
  */
14119
14118
  const ARROW_SIZE$1 = 8;
14120
14119
 
14121
- // Skip popper logic in jsdom env
14122
- const usePopperHook = IS_JSDOM_ENV ? () => ({}) : usePopper;
14123
-
14124
14120
  /**
14125
14121
  * Tooltip component.
14126
14122
  *
@@ -14141,16 +14137,16 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
14141
14137
  } = props,
14142
14138
  forwardedProps = _objectWithoutProperties(props, _excluded$1q);
14143
14139
  // Disable in SSR.
14144
- if (!DOCUMENT && closeMode === 'unmount') {
14140
+ if (!DOCUMENT) {
14145
14141
  return /*#__PURE__*/React.createElement(React.Fragment, null, children);
14146
14142
  }
14147
14143
  const id = useId();
14148
14144
  const [popperElement, setPopperElement] = useState(null);
14149
14145
  const [anchorElement, setAnchorElement] = useState(null);
14150
14146
  const {
14151
- styles = {},
14152
- attributes = {}
14153
- } = usePopperHook(anchorElement, popperElement, {
14147
+ styles,
14148
+ attributes
14149
+ } = usePopper$1(anchorElement, popperElement, {
14154
14150
  placement,
14155
14151
  modifiers: [{
14156
14152
  name: 'offset',