@loomhq/lens 10.32.12 → 10.33.0

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, limitShift, 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,31 +43,27 @@ 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],
62
57
  middleware: [
58
+ shift({
59
+ padding: unitBoundaryOffset,
60
+ boundary: boundaryElement ? getBoundaryElement() : undefined,
61
+ limiter: limitShift(),
62
+ }),
63
63
  flip({
64
64
  fallbackPlacements: ['top', 'bottom'],
65
65
  fallbackStrategy: 'initialPlacement',
66
66
  }),
67
- shift({
68
- padding: unitBoundaryOffset,
69
- boundary: getBoundaryElement(),
70
- }),
71
67
  floatingUiOffset(unitOffset),
72
68
  ],
73
69
  strategy: 'fixed',
@@ -76,27 +72,9 @@ const Popover = (_a) => {
76
72
  if (!refs.reference.current || !refs.floating.current) {
77
73
  return;
78
74
  }
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]);
75
+ // Only call this when the floating element is rendered
76
+ return autoUpdate(refs.reference.current, refs.floating.current, update);
77
+ }, [refs.reference, refs.floating, update, shouldMount]);
100
78
  const contentProps = {
101
79
  zIndex,
102
80
  ref: floating,
@@ -99,11 +99,13 @@ export const getThemeStylesString = (customRootElement = ':root') => {
99
99
  const rootElement = customRootElement || ':root';
100
100
  return `
101
101
  ${rootElement},
102
- .theme-light {
102
+ .theme-light,
103
+ [data-lensTheme="light"] {
103
104
  ${assignLightThemeColors().join('')}
104
105
  }
105
106
 
106
- .theme-dark {
107
+ .theme-dark,
108
+ [data-lensTheme="dark"] {
107
109
  ${assignDarkThemeColors().join('')}
108
110
  }
109
111
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.32.12",
3
+ "version": "10.33.0",
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",