@loomhq/lens 10.32.12 → 10.32.13

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.
@@ -9,8 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { flip, offset as floatingUiOffset, getScrollParents, shift, useFloating, } from '@floating-ui/react-dom';
13
- import React, { useEffect, useState } from 'react';
12
+ import { autoUpdate, flip, offset as floatingUiOffset, shift, useFloating, } from '@floating-ui/react-dom';
13
+ import React, { useEffect } from 'react';
14
14
  import ReactDOM from 'react-dom';
15
15
  import styled from '@emotion/styled';
16
16
  import { unit } from '../../variables';
@@ -43,19 +43,14 @@ const Popover = (_a) => {
43
43
  var { children, content, offset = 0.5, boundaryOffset = 0.5, isOpen, zIndex = 500, placement = 'topCenter', rootId, boundaryElement = 'body', transitionDuration = 0, transitionDelay = 0 } = _a, props = __rest(_a, ["children", "content", "offset", "boundaryOffset", "isOpen", "zIndex", "placement", "rootId", "boundaryElement", "transitionDuration", "transitionDelay"]);
44
44
  const unitOffset = offset * unit;
45
45
  const unitBoundaryOffset = boundaryOffset * unit;
46
- const [bodyElement, setBodyElement] = useState(null);
46
+ const isBrowser = typeof window !== 'undefined';
47
+ const rootNode = rootId && isBrowser ? document.getElementById(rootId) : undefined;
47
48
  const { stage, shouldMount } = useTransition(isOpen, transitionDuration + transitionDelay);
48
- useEffect(() => {
49
- setBodyElement(document === null || document === void 0 ? void 0 : document.querySelector('body'));
50
- }, []);
51
49
  const getBoundaryElement = () => {
52
- if (boundaryElement) {
53
- if (boundaryElement === 'body') {
54
- return bodyElement;
55
- }
56
- return boundaryElement;
50
+ if (boundaryElement === 'body' && isBrowser) {
51
+ return document.body;
57
52
  }
58
- return 'clippingParents';
53
+ return boundaryElement;
59
54
  };
60
55
  const { x, y, reference, floating, strategy, update, refs } = useFloating({
61
56
  placement: placements[placement],
@@ -66,7 +61,7 @@ const Popover = (_a) => {
66
61
  }),
67
62
  shift({
68
63
  padding: unitBoundaryOffset,
69
- boundary: getBoundaryElement(),
64
+ boundary: boundaryElement ? getBoundaryElement() : undefined,
70
65
  }),
71
66
  floatingUiOffset(unitOffset),
72
67
  ],
@@ -76,27 +71,9 @@ const Popover = (_a) => {
76
71
  if (!refs.reference.current || !refs.floating.current) {
77
72
  return;
78
73
  }
79
- const parents = [
80
- ...getScrollParents(refs.reference.current),
81
- ...getScrollParents(refs.floating.current),
82
- ];
83
- parents.forEach(parent => {
84
- parent.addEventListener('scroll', update);
85
- parent.addEventListener('resize', update);
86
- });
87
- return () => {
88
- parents.forEach(parent => {
89
- parent.removeEventListener('scroll', update);
90
- parent.removeEventListener('resize', update);
91
- });
92
- };
93
- }, [refs.reference, refs.floating, update, isOpen, shouldMount]);
94
- const [rootNode, setRootNode] = useState(null);
95
- useEffect(() => {
96
- if (rootId) {
97
- setRootNode(document === null || document === void 0 ? void 0 : document.getElementById(rootId));
98
- }
99
- }, [rootId]);
74
+ // Only call this when the floating element is rendered
75
+ return autoUpdate(refs.reference.current, refs.floating.current, update);
76
+ }, [refs.reference, refs.floating, update, shouldMount]);
100
77
  const contentProps = {
101
78
  zIndex,
102
79
  ref: floating,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.32.12",
3
+ "version": "10.32.13",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",
@@ -22,7 +22,7 @@
22
22
  ]
23
23
  },
24
24
  "dependencies": {
25
- "@floating-ui/react-dom": "^0.4.3",
25
+ "@floating-ui/react-dom": "^0.6.0",
26
26
  "downshift": "^5.4.7",
27
27
  "lodash": "^4.17.21",
28
28
  "react-color": "^2.19.3",