@loomhq/lens 10.31.0 → 10.31.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.
@@ -10,6 +10,6 @@ declare type PopoverProps = {
10
10
  isOpen?: boolean;
11
11
  placement?: PlacementProps;
12
12
  rootId?: string;
13
- boundaryElement: 'clippingParents' | Element;
13
+ boundaryElement?: 'body' | Element;
14
14
  };
15
15
  export default Popover;
@@ -55,20 +55,33 @@ const ContentWrapper = styled.div `
55
55
  ${props => props.zIndex && `z-index: ${props.zIndex}`};
56
56
  `;
57
57
  const Popover = (_a) => {
58
- var { children, content, offset = 1, boundaryOffset = 1, isOpen, zIndex = 1100, placement = 'topCenter', rootId, boundaryElement = 'clippingParents' } = _a, props = __rest(_a, ["children", "content", "offset", "boundaryOffset", "isOpen", "zIndex", "placement", "rootId", "boundaryElement"]);
58
+ var { children, content, offset = 1, boundaryOffset = 1, isOpen, zIndex = 1100, placement = 'topCenter', rootId, boundaryElement = 'body' } = _a, props = __rest(_a, ["children", "content", "offset", "boundaryOffset", "isOpen", "zIndex", "placement", "rootId", "boundaryElement"]);
59
59
  const unitOffset = offset * unit;
60
60
  const unitBoundaryOffset = boundaryOffset * unit;
61
+ const [bodyElement, setBodyElement] = useState(null);
62
+ useEffect(() => {
63
+ setBodyElement(document === null || document === void 0 ? void 0 : document.querySelector('body'));
64
+ }, []);
65
+ const getBoundaryElement = () => {
66
+ if (boundaryElement) {
67
+ if (boundaryElement === 'body') {
68
+ return bodyElement;
69
+ }
70
+ return boundaryElement;
71
+ }
72
+ return 'clippingParents';
73
+ };
61
74
  const { x, y, reference, floating, strategy, update, refs } = useFloating({
62
75
  placement: placements[placement],
63
76
  middleware: [
64
77
  flip({ fallbackPlacements: ['top', 'bottom'] }),
65
78
  shift({
66
79
  padding: unitBoundaryOffset,
67
- boundary: boundaryElement,
80
+ boundary: getBoundaryElement(),
68
81
  }),
69
82
  floatingUiOffset(unitOffset),
70
83
  ],
71
- strategy: 'fixed',
84
+ strategy: rootId ? 'fixed' : 'absolute',
72
85
  });
73
86
  useEffect(() => {
74
87
  if (!refs.reference.current || !refs.floating.current) {
@@ -92,7 +105,7 @@ const Popover = (_a) => {
92
105
  const [rootNode, setRootNode] = useState(null);
93
106
  useEffect(() => {
94
107
  if (rootId) {
95
- setRootNode(document.getElementById(rootId));
108
+ setRootNode(document === null || document === void 0 ? void 0 : document.getElementById(rootId));
96
109
  }
97
110
  }, [rootId]);
98
111
  const contentProps = {
@@ -104,8 +117,8 @@ const Popover = (_a) => {
104
117
  left: x !== null && x !== void 0 ? x : '',
105
118
  },
106
119
  };
107
- return (React.createElement(Wrapper, null,
108
- React.createElement("div", Object.assign({ ref: reference }, props), children),
120
+ return (React.createElement(Wrapper, Object.assign({ ref: reference }, props),
121
+ children,
109
122
  React.createElement(CSSTransitionGroup, { transitionName: "Popover", transitionEnterTimeout: duration, transitionLeaveTimeout: duration }, isOpen && (React.createElement(React.Fragment, null,
110
123
  !rootNode && (React.createElement(ContentWrapper, Object.assign({}, contentProps), content)),
111
124
  rootNode &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.31.0",
3
+ "version": "10.31.1",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",