@gympass/yoga 7.73.1 → 7.74.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.
- package/cjs/Dialog/web/Dialog.js +11 -6
- package/esm/Dialog/web/Dialog.js +14 -11
- package/esm/Dialog/web/Dialog.test.js +10 -0
- package/package.json +2 -2
package/cjs/Dialog/web/Dialog.js
CHANGED
|
@@ -17,7 +17,7 @@ var _hooks = require("../../hooks");
|
|
|
17
17
|
|
|
18
18
|
var _ = require("../..");
|
|
19
19
|
|
|
20
|
-
var _excluded = ["isOpen", "hideCloseButton", "children", "onClose", "zIndex"];
|
|
20
|
+
var _excluded = ["isOpen", "hideCloseButton", "children", "dialogId", "onClose", "zIndex"];
|
|
21
21
|
|
|
22
22
|
var _templateObject, _templateObject2;
|
|
23
23
|
|
|
@@ -46,16 +46,17 @@ var Overlay = _styledComponents["default"].div(_templateObject2 || (_templateObj
|
|
|
46
46
|
return "\n display: flex;\n z-index: " + zIndex + ";\n justify-content: center;\n align-items: center;\n\n position: fixed;\n top: " + dialog.position["default"] + ";\n right: " + dialog.position["default"] + ";\n left: " + dialog.position["default"] + ";\n bottom: " + dialog.position["default"] + ";\n\n background-color: rgba(35, 27, 34, 0.48);\n ";
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
var Dialog = /*#__PURE__*/_react["default"].forwardRef(function (_ref3, forwardedRef) {
|
|
50
50
|
var isOpen = _ref3.isOpen,
|
|
51
51
|
hideCloseButton = _ref3.hideCloseButton,
|
|
52
52
|
children = _ref3.children,
|
|
53
|
+
dialogId = _ref3.dialogId,
|
|
53
54
|
onClose = _ref3.onClose,
|
|
54
55
|
zIndex = _ref3.zIndex,
|
|
55
56
|
props = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
56
57
|
|
|
57
|
-
var dialogRef = (0,
|
|
58
|
-
var dialogElement = (0, _hooks.usePortal)('dialog');
|
|
58
|
+
var dialogRef = (0, _hooks.useCombinedRefs)(forwardedRef);
|
|
59
|
+
var dialogElement = (0, _hooks.usePortal)(dialogId != null ? dialogId : 'dialog');
|
|
59
60
|
var isCloseButtonVisible = onClose && !hideCloseButton;
|
|
60
61
|
var closeDialog = (0, _react.useCallback)(function (e) {
|
|
61
62
|
if (dialogRef.current === e.target && isOpen && onClose) {
|
|
@@ -93,9 +94,12 @@ function Dialog(_ref3) {
|
|
|
93
94
|
inverted: true,
|
|
94
95
|
onClick: onClose
|
|
95
96
|
})), children)), dialogElement) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
|
|
96
|
-
}
|
|
97
|
+
});
|
|
97
98
|
|
|
98
99
|
Dialog.propTypes = {
|
|
100
|
+
/** Custom id to allow creating isolated portal nodes */
|
|
101
|
+
dialogId: _propTypes.string,
|
|
102
|
+
|
|
99
103
|
/** Control the dialog visibility. */
|
|
100
104
|
isOpen: _propTypes.bool,
|
|
101
105
|
|
|
@@ -111,7 +115,8 @@ Dialog.defaultProps = {
|
|
|
111
115
|
isOpen: false,
|
|
112
116
|
hideCloseButton: false,
|
|
113
117
|
onClose: undefined,
|
|
114
|
-
zIndex: 3
|
|
118
|
+
zIndex: 3,
|
|
119
|
+
dialogId: undefined
|
|
115
120
|
};
|
|
116
121
|
Dialog.displayName = 'Dialog';
|
|
117
122
|
var _default = Dialog;
|
package/esm/Dialog/web/Dialog.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["isOpen", "hideCloseButton", "children", "onClose", "zIndex"];
|
|
1
|
+
var _excluded = ["isOpen", "hideCloseButton", "children", "dialogId", "onClose", "zIndex"];
|
|
2
2
|
|
|
3
3
|
var _templateObject, _templateObject2;
|
|
4
4
|
|
|
@@ -8,12 +8,12 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
8
8
|
|
|
9
9
|
function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; }
|
|
10
10
|
|
|
11
|
-
import React, { useEffect,
|
|
11
|
+
import React, { useEffect, useCallback } from 'react';
|
|
12
12
|
import { createPortal } from 'react-dom';
|
|
13
13
|
import styled from 'styled-components';
|
|
14
|
-
import { func, bool, node, number } from 'prop-types';
|
|
14
|
+
import { func, bool, node, number, string } from 'prop-types';
|
|
15
15
|
import { Close } from '@gympass/yoga-icons';
|
|
16
|
-
import { usePortal } from '../../hooks';
|
|
16
|
+
import { usePortal, useCombinedRefs } from '../../hooks';
|
|
17
17
|
import { Button, Card, Box } from '../..';
|
|
18
18
|
export var StyledDialog = styled(Card)(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n ", "\n display: flex;\n align-items: center;\n flex-direction: column;\n"])), function (_ref) {
|
|
19
19
|
var onClose = _ref.onClose,
|
|
@@ -25,17 +25,17 @@ var Overlay = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplate
|
|
|
25
25
|
dialog = _ref2.theme.yoga.components.dialog;
|
|
26
26
|
return "\n display: flex;\n z-index: " + zIndex + ";\n justify-content: center;\n align-items: center;\n\n position: fixed;\n top: " + dialog.position["default"] + ";\n right: " + dialog.position["default"] + ";\n left: " + dialog.position["default"] + ";\n bottom: " + dialog.position["default"] + ";\n\n background-color: rgba(35, 27, 34, 0.48);\n ";
|
|
27
27
|
});
|
|
28
|
-
|
|
29
|
-
function Dialog(_ref3) {
|
|
28
|
+
var Dialog = /*#__PURE__*/React.forwardRef(function (_ref3, forwardedRef) {
|
|
30
29
|
var isOpen = _ref3.isOpen,
|
|
31
30
|
hideCloseButton = _ref3.hideCloseButton,
|
|
32
31
|
children = _ref3.children,
|
|
32
|
+
dialogId = _ref3.dialogId,
|
|
33
33
|
onClose = _ref3.onClose,
|
|
34
34
|
zIndex = _ref3.zIndex,
|
|
35
35
|
props = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
36
36
|
|
|
37
|
-
var dialogRef =
|
|
38
|
-
var dialogElement = usePortal('dialog');
|
|
37
|
+
var dialogRef = useCombinedRefs(forwardedRef);
|
|
38
|
+
var dialogElement = usePortal(dialogId != null ? dialogId : 'dialog');
|
|
39
39
|
var isCloseButtonVisible = onClose && !hideCloseButton;
|
|
40
40
|
var closeDialog = useCallback(function (e) {
|
|
41
41
|
if (dialogRef.current === e.target && isOpen && onClose) {
|
|
@@ -73,9 +73,11 @@ function Dialog(_ref3) {
|
|
|
73
73
|
inverted: true,
|
|
74
74
|
onClick: onClose
|
|
75
75
|
})), children)), dialogElement) : /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
76
|
-
}
|
|
77
|
-
|
|
76
|
+
});
|
|
78
77
|
Dialog.propTypes = {
|
|
78
|
+
/** Custom id to allow creating isolated portal nodes */
|
|
79
|
+
dialogId: string,
|
|
80
|
+
|
|
79
81
|
/** Control the dialog visibility. */
|
|
80
82
|
isOpen: bool,
|
|
81
83
|
|
|
@@ -91,7 +93,8 @@ Dialog.defaultProps = {
|
|
|
91
93
|
isOpen: false,
|
|
92
94
|
hideCloseButton: false,
|
|
93
95
|
onClose: undefined,
|
|
94
|
-
zIndex: 3
|
|
96
|
+
zIndex: 3,
|
|
97
|
+
dialogId: undefined
|
|
95
98
|
};
|
|
96
99
|
Dialog.displayName = 'Dialog';
|
|
97
100
|
export default Dialog;
|
|
@@ -59,4 +59,14 @@ describe('<Dialog />', function () {
|
|
|
59
59
|
}, /*#__PURE__*/React.createElement(Dialog.Header, null, "Title"))));
|
|
60
60
|
expect(screen.queryByRole('button')).toBeNull();
|
|
61
61
|
});
|
|
62
|
+
it('should render content isolated by dialog id', function () {
|
|
63
|
+
render( /*#__PURE__*/React.createElement(ThemeProvider, null, /*#__PURE__*/React.createElement(Dialog, {
|
|
64
|
+
isOpen: true
|
|
65
|
+
}, /*#__PURE__*/React.createElement(Dialog.Header, null, "Title")), /*#__PURE__*/React.createElement(Dialog, {
|
|
66
|
+
isOpen: true,
|
|
67
|
+
dialogId: "custom-id"
|
|
68
|
+
}, /*#__PURE__*/React.createElement(Dialog.Header, null, "Second Title"))));
|
|
69
|
+
expect(screen.getByText('Title')).toBeInTheDocument();
|
|
70
|
+
expect(screen.getByText('Second Title')).toBeInTheDocument();
|
|
71
|
+
});
|
|
62
72
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gympass/yoga",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.74.0",
|
|
4
4
|
"description": "Gympass component library",
|
|
5
5
|
"main": "./cjs",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"react": ">=16",
|
|
54
54
|
"styled-components": "^4.4.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "21322a4a3a083f86796151e7687dd2b257fe445e",
|
|
57
57
|
"module": "./esm",
|
|
58
58
|
"private": false,
|
|
59
59
|
"react-native": "./cjs/index.native.js"
|