@loomhq/lens 10.31.2 → 10.32.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.
|
@@ -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;
|
|
@@ -11,5 +11,7 @@ declare type PopoverProps = {
|
|
|
11
11
|
placement?: PlacementProps;
|
|
12
12
|
rootId?: string;
|
|
13
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 {
|
|
17
|
+
import { useTransition } from 'transition-hook';
|
|
18
18
|
const duration = 200;
|
|
19
19
|
const placements = {
|
|
20
20
|
topLeft: 'top-start',
|
|
@@ -32,33 +32,16 @@ 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 = 'body' } = _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;
|
|
61
43
|
const [bodyElement, setBodyElement] = useState(null);
|
|
44
|
+
const { stage, shouldMount } = useTransition(isOpen, transitionDuration);
|
|
62
45
|
useEffect(() => {
|
|
63
46
|
setBodyElement(document === null || document === void 0 ? void 0 : document.querySelector('body'));
|
|
64
47
|
}, []);
|
|
@@ -115,13 +98,15 @@ const Popover = (_a) => {
|
|
|
115
98
|
position: strategy,
|
|
116
99
|
top: y !== null && y !== void 0 ? y : '',
|
|
117
100
|
left: x !== null && x !== void 0 ? x : '',
|
|
101
|
+
transition: `opacity ${transitionDuration}ms ${transitionDelay}ms`,
|
|
102
|
+
opacity: stage === 'enter' ? 1 : 0,
|
|
118
103
|
},
|
|
119
104
|
};
|
|
120
105
|
return (React.createElement(Wrapper, Object.assign({ ref: reference }, props),
|
|
121
106
|
children,
|
|
122
|
-
|
|
107
|
+
shouldMount && (React.createElement(React.Fragment, null,
|
|
123
108
|
!rootNode && (React.createElement(ContentWrapper, Object.assign({}, contentProps), content)),
|
|
124
109
|
rootNode &&
|
|
125
|
-
ReactDOM.createPortal(React.createElement(ContentWrapper, Object.assign({}, contentProps), content), rootNode)))))
|
|
110
|
+
ReactDOM.createPortal(React.createElement(ContentWrapper, Object.assign({}, contentProps), content), rootNode)))));
|
|
126
111
|
};
|
|
127
112
|
export default Popover;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomhq/lens",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.32.2",
|
|
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": "^
|
|
38
|
-
"react-dom": "^
|
|
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": "^
|
|
50
|
-
"@mdx-js/react": "^
|
|
51
|
-
"@next/mdx": "^
|
|
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": "
|
|
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": "^
|
|
74
|
+
"react": "^17.0.2",
|
|
75
75
|
"react-docgen": "^5.4.0",
|
|
76
|
-
"react-dom": "^
|
|
77
|
-
"react-live": "^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",
|