@loomhq/lens 10.31.0 → 10.32.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.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  declare type PlacementProps = 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight' | 'leftTop' | 'leftCenter' | 'leftBottom' | 'rightTop' | 'rightCenter' | 'rightBottom';
3
- declare const Popover: ({ children, content, offset, boundaryOffset, isOpen, zIndex, placement, rootId, boundaryElement, ...props }: PopoverProps) => JSX.Element;
3
+ declare const Popover: ({ children, content, offset, boundaryOffset, isOpen, zIndex, placement, rootId, boundaryElement, transitionDuration, transitionDelay, ...props }: PopoverProps) => JSX.Element;
4
4
  declare type PopoverProps = {
5
5
  children?: React.ReactNode;
6
6
  content?: React.ReactNode;
@@ -10,6 +10,8 @@ declare type PopoverProps = {
10
10
  isOpen?: boolean;
11
11
  placement?: PlacementProps;
12
12
  rootId?: string;
13
- boundaryElement: 'clippingParents' | Element;
13
+ boundaryElement?: 'body' | Element;
14
+ transitionDuration?: number;
15
+ transitionDelay?: number;
14
16
  };
15
17
  export default Popover;
@@ -14,7 +14,7 @@ import React, { useEffect, useState } from 'react';
14
14
  import ReactDOM from 'react-dom';
15
15
  import styled from '@emotion/styled';
16
16
  import { unit } from '../../variables';
17
- import { CSSTransitionGroup } from 'react-transition-group';
17
+ import { useTransition } from 'transition-hook';
18
18
  const duration = 200;
19
19
  const placements = {
20
20
  topLeft: 'top-start',
@@ -32,39 +32,35 @@ const placements = {
32
32
  };
33
33
  const Wrapper = styled.div `
34
34
  position: relative;
35
-
36
- .Popover-enter {
37
- opacity: 0.01;
38
- }
39
-
40
- .Popover-enter.Popover-enter-active {
41
- opacity: 1;
42
- transition: opacity ${duration}ms;
43
- }
44
-
45
- .Popover-leave {
46
- opacity: 1;
47
- }
48
-
49
- .Popover-leave.Popover-leave-active {
50
- opacity: 0.01;
51
- transition: opacity ${duration}ms;
52
- }
53
35
  `;
54
36
  const ContentWrapper = styled.div `
55
37
  ${props => props.zIndex && `z-index: ${props.zIndex}`};
56
38
  `;
57
39
  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"]);
40
+ var { children, content, offset = 1, boundaryOffset = 1, isOpen, zIndex = 1100, placement = 'topCenter', rootId, boundaryElement = 'body', transitionDuration = 0, transitionDelay = 0 } = _a, props = __rest(_a, ["children", "content", "offset", "boundaryOffset", "isOpen", "zIndex", "placement", "rootId", "boundaryElement", "transitionDuration", "transitionDelay"]);
59
41
  const unitOffset = offset * unit;
60
42
  const unitBoundaryOffset = boundaryOffset * unit;
43
+ const [bodyElement, setBodyElement] = useState(null);
44
+ const { stage, shouldMount } = useTransition(isOpen, transitionDuration);
45
+ useEffect(() => {
46
+ setBodyElement(document === null || document === void 0 ? void 0 : document.querySelector('body'));
47
+ }, []);
48
+ const getBoundaryElement = () => {
49
+ if (boundaryElement) {
50
+ if (boundaryElement === 'body') {
51
+ return bodyElement;
52
+ }
53
+ return boundaryElement;
54
+ }
55
+ return 'clippingParents';
56
+ };
61
57
  const { x, y, reference, floating, strategy, update, refs } = useFloating({
62
58
  placement: placements[placement],
63
59
  middleware: [
64
60
  flip({ fallbackPlacements: ['top', 'bottom'] }),
65
61
  shift({
66
62
  padding: unitBoundaryOffset,
67
- boundary: boundaryElement,
63
+ boundary: getBoundaryElement(),
68
64
  }),
69
65
  floatingUiOffset(unitOffset),
70
66
  ],
@@ -92,7 +88,7 @@ const Popover = (_a) => {
92
88
  const [rootNode, setRootNode] = useState(null);
93
89
  useEffect(() => {
94
90
  if (rootId) {
95
- setRootNode(document.getElementById(rootId));
91
+ setRootNode(document === null || document === void 0 ? void 0 : document.getElementById(rootId));
96
92
  }
97
93
  }, [rootId]);
98
94
  const contentProps = {
@@ -102,13 +98,15 @@ const Popover = (_a) => {
102
98
  position: strategy,
103
99
  top: y !== null && y !== void 0 ? y : '',
104
100
  left: x !== null && x !== void 0 ? x : '',
101
+ transition: `opacity ${transitionDuration}ms ${transitionDelay}ms`,
102
+ opacity: stage === 'enter' ? 1 : 0,
105
103
  },
106
104
  };
107
- return (React.createElement(Wrapper, null,
108
- React.createElement("div", Object.assign({ ref: reference }, props), children),
109
- React.createElement(CSSTransitionGroup, { transitionName: "Popover", transitionEnterTimeout: duration, transitionLeaveTimeout: duration }, isOpen && (React.createElement(React.Fragment, null,
105
+ return (React.createElement(Wrapper, Object.assign({ ref: reference }, props),
106
+ children,
107
+ shouldMount && (React.createElement(React.Fragment, null,
110
108
  !rootNode && (React.createElement(ContentWrapper, Object.assign({}, contentProps), content)),
111
109
  rootNode &&
112
- ReactDOM.createPortal(React.createElement(ContentWrapper, Object.assign({}, contentProps), content), rootNode))))));
110
+ ReactDOM.createPortal(React.createElement(ContentWrapper, Object.assign({}, contentProps), content), rootNode)))));
113
111
  };
114
112
  export default Popover;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.31.0",
3
+ "version": "10.32.0",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",
@@ -28,14 +28,15 @@
28
28
  "react-color": "^2.19.3",
29
29
  "react-laag": "^2.0.3",
30
30
  "react-transition-group": "^1.2.0",
31
- "resize-observer-polyfill": "^1.5.1"
31
+ "resize-observer-polyfill": "^1.5.1",
32
+ "transition-hook": "^1.5.1"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "@emotion/core": "^10.1.1",
35
36
  "@emotion/styled": "^10.0.27",
36
37
  "@types/react": "^17.0.3",
37
- "react": "^16.12.0",
38
- "react-dom": "^16.12.0"
38
+ "react": "^17.0.2",
39
+ "react-dom": "^17.0.2"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@babel/cli": "^7.8.4",
@@ -46,9 +47,9 @@
46
47
  "@babel/register": "^7.8.3",
47
48
  "@emotion/core": "^10.1.1",
48
49
  "@emotion/styled": "^10.0.27",
49
- "@mdx-js/loader": "^1.5.5",
50
- "@mdx-js/react": "^1.5.5",
51
- "@next/mdx": "^10.1.3",
50
+ "@mdx-js/loader": "^2.0.0",
51
+ "@mdx-js/react": "^2.0.0",
52
+ "@next/mdx": "^12.1.0",
52
53
  "@types/react": "^17.0.3",
53
54
  "@typescript-eslint/eslint-plugin": "^4.22.0",
54
55
  "@typescript-eslint/parser": "^4.22.0",
@@ -67,14 +68,13 @@
67
68
  "husky": "^4.2.1",
68
69
  "lint-staged": "^10.0.6",
69
70
  "mousetrap": "^1.6.5",
70
- "next": "^10.1.3",
71
- "next-images": "^1.3.0",
71
+ "next": "12",
72
72
  "prettier": "^1.19.1",
73
73
  "prism-react-renderer": "^1.0.2",
74
- "react": "^16.12.0",
74
+ "react": "^17.0.2",
75
75
  "react-docgen": "^5.4.0",
76
- "react-dom": "^16.12.0",
77
- "react-live": "^2.2.2",
76
+ "react-dom": "^17.0.2",
77
+ "react-live": "^2.4.1",
78
78
  "react-typeform-embed": "^0.2.1",
79
79
  "semantic-release": "^17.0.1",
80
80
  "tinycolor2": "^1.4.1",