@pingux/astro 2.1.0-alpha.0 → 2.1.0-alpha.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.
- package/lib/cjs/components/CollapsiblePanel/CollapsiblePanel.stories.js +2 -1
- package/lib/cjs/components/OverlayPanel/OverlayPanel.js +14 -3
- package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +9 -5
- package/lib/cjs/components/OverlayPanel/OverlayPanel.styles.js +7 -5
- package/lib/cjs/hooks/index.js +7 -0
- package/lib/cjs/hooks/useMountTransition/index.js +14 -0
- package/lib/cjs/hooks/useMountTransition/useMountTransition.js +44 -0
- package/lib/cjs/hooks/useMountTransition/useMountTransition.test.js +68 -0
- package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.js +24 -3
- package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.test.js +3 -1
- package/lib/cjs/recipes/LinkedListView.stories.js +5 -27
- package/lib/components/CollapsiblePanel/CollapsiblePanel.stories.js +2 -1
- package/lib/components/OverlayPanel/OverlayPanel.js +14 -3
- package/lib/components/OverlayPanel/OverlayPanel.stories.js +9 -5
- package/lib/components/OverlayPanel/OverlayPanel.styles.js +7 -5
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useMountTransition/index.js +1 -0
- package/lib/hooks/useMountTransition/useMountTransition.js +36 -0
- package/lib/hooks/useMountTransition/useMountTransition.test.js +59 -0
- package/lib/hooks/useOverlayPanelState/useOverlayPanelState.js +24 -3
- package/lib/hooks/useOverlayPanelState/useOverlayPanelState.test.js +3 -1
- package/lib/recipes/LinkedListView.stories.js +5 -27
- package/package.json +1 -1
@@ -177,8 +177,9 @@ var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args) {
|
|
177
177
|
return (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.Button, {
|
178
178
|
ref: triggerRef,
|
179
179
|
onPress: state.open
|
180
|
-
}, "Open Panel"), (0, _react2.jsx)(_index.OverlayPanel, {
|
180
|
+
}, "Open Panel"), (state.isOpen || state.isTransitioning) && (0, _react2.jsx)(_index.OverlayPanel, {
|
181
181
|
isOpen: state.isOpen,
|
182
|
+
isTransitioning: state.isTransitioning,
|
182
183
|
size: "large",
|
183
184
|
p: "0"
|
184
185
|
}, (0, _react2.jsx)(_index.Box, {
|
@@ -20,7 +20,7 @@ var _ = require("../..");
|
|
20
20
|
var _hooks = require("../../hooks");
|
21
21
|
var _panelSizes = require("../../utils/devUtils/constants/panelSizes");
|
22
22
|
var _react2 = require("@emotion/react");
|
23
|
-
var _excluded = ["children", "isOpen", "onClose", "className", "state", "size", "triggerRef"];
|
23
|
+
var _excluded = ["children", "isOpen", "isTransitioning", "onClose", "className", "state", "size", "triggerRef"];
|
24
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
25
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
26
26
|
/**
|
@@ -35,6 +35,7 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
35
35
|
var _props$sx;
|
36
36
|
var children = props.children,
|
37
37
|
isOpen = props.isOpen,
|
38
|
+
isTransitioning = props.isTransitioning,
|
38
39
|
onCloseProp = props.onClose,
|
39
40
|
className = props.className,
|
40
41
|
state = props.state,
|
@@ -48,8 +49,15 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
48
49
|
(0, _react.useImperativeHandle)(ref, function () {
|
49
50
|
return overlayPanelRef.current;
|
50
51
|
});
|
52
|
+
|
53
|
+
// this is code to avoid regressions -- implementations that do not use the
|
54
|
+
// useMountTransition hook will not break, because this className gives the
|
55
|
+
// component the styling properties that it needs.
|
56
|
+
var isOpenNoTransition = isTransitioning === undefined && isOpen === true;
|
51
57
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, (0, _defineProperty2["default"])({
|
52
|
-
isOpen: isOpen
|
58
|
+
isOpen: isOpen,
|
59
|
+
isTransitioning: isTransitioning,
|
60
|
+
isOpenNoTransition: isOpenNoTransition
|
53
61
|
}, "is-".concat(props !== null && props !== void 0 && (_props$sx = props.sx) !== null && _props$sx !== void 0 && _props$sx.width ? 'custom' : size), size)),
|
54
62
|
classNames = _useStatusClasses.classNames;
|
55
63
|
var handleClose = function handleClose(e) {
|
@@ -65,7 +73,8 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
65
73
|
ref: overlayPanelRef
|
66
74
|
}, others, {
|
67
75
|
className: classNames,
|
68
|
-
onKeyUp: handleClose
|
76
|
+
onKeyUp: handleClose,
|
77
|
+
"aria-hidden": !isOpen
|
69
78
|
}), (0, _react2.jsx)(_.Box, {
|
70
79
|
variant: "overlayPanel.body",
|
71
80
|
className: classNames
|
@@ -86,6 +95,8 @@ OverlayPanel.propTypes = {
|
|
86
95
|
}),
|
87
96
|
/** Callback function that runs when the esc key is used to close the OverlayPanel. */
|
88
97
|
onClose: _propTypes["default"].func,
|
98
|
+
/** Boolean that determines whether or not the css transition is occuring. */
|
99
|
+
isTransitioning: _propTypes["default"].bool,
|
89
100
|
/** Ref that is connected to the button that triggers the overlay state.
|
90
101
|
Focus will return to this ref when the keyboard is used to close the OverlayPanel. */
|
91
102
|
triggerRef: _propTypes["default"].shape({})
|
@@ -68,8 +68,9 @@ var Default = function Default(_ref) {
|
|
68
68
|
ref: triggerRef,
|
69
69
|
onPress: state.open,
|
70
70
|
"aria-expanded": state.isOpen
|
71
|
-
}, "Open Panel"), state.isOpen && (0, _react2.jsx)(_index.OverlayPanel, (0, _extends2["default"])({
|
71
|
+
}, "Open Panel"), (state.isOpen || state.isTransitioning) && (0, _react2.jsx)(_index.OverlayPanel, (0, _extends2["default"])({
|
72
72
|
isOpen: state.isOpen,
|
73
|
+
isTransitioning: state.isTransitioning,
|
73
74
|
state: state
|
74
75
|
}, args, {
|
75
76
|
triggerRef: triggerRef
|
@@ -111,7 +112,7 @@ var InnerPanel = function InnerPanel(_ref2) {
|
|
111
112
|
onCloseInner(innerState, innerTriggerRef);
|
112
113
|
};
|
113
114
|
var inner = innerState.isOpen && (0, _react2.jsx)(_index.OverlayPanel, (0, _extends2["default"])({
|
114
|
-
variant: "overlayPanel.
|
115
|
+
variant: "overlayPanel.innerPanel" // applies higher z-index
|
115
116
|
,
|
116
117
|
isOpen: innerState.isOpen
|
117
118
|
}, args, {
|
@@ -131,8 +132,9 @@ var InnerPanel = function InnerPanel(_ref2) {
|
|
131
132
|
}];
|
132
133
|
var outer =
|
133
134
|
// should have higher z-index applied
|
134
|
-
state.isOpen && (0, _react2.jsx)(_index.OverlayPanel, (0, _extends2["default"])({
|
135
|
+
(state.isOpen || state.isTransitioning) && (0, _react2.jsx)(_index.OverlayPanel, (0, _extends2["default"])({
|
135
136
|
isOpen: state.isOpen,
|
137
|
+
isTransitioning: state.isTransitioning,
|
136
138
|
sx: {
|
137
139
|
p: '0px'
|
138
140
|
}
|
@@ -197,7 +199,8 @@ var CustomWidth = function CustomWidth() {
|
|
197
199
|
ref: triggerRef,
|
198
200
|
onPress: state.open,
|
199
201
|
"aria-expanded": state.isOpen
|
200
|
-
}, "Open Panel"), state.isOpen && (0, _react2.jsx)(_index.OverlayPanel, {
|
202
|
+
}, "Open Panel"), (state.isOpen || state.isTransitioning) && (0, _react2.jsx)(_index.OverlayPanel, {
|
203
|
+
isTransitioning: state.isTransitioning,
|
201
204
|
isOpen: state.isOpen,
|
202
205
|
state: state,
|
203
206
|
triggerRef: triggerRef,
|
@@ -457,7 +460,8 @@ var Expandable = function Expandable() {
|
|
457
460
|
ref: triggerRef,
|
458
461
|
onPress: state.open,
|
459
462
|
"aria-expanded": state.isOpen
|
460
|
-
}, "Open Panel"), state.isOpen && (0, _react2.jsx)(_index.OverlayPanel, {
|
463
|
+
}, "Open Panel"), (state.isOpen || state.isTransitioning) && (0, _react2.jsx)(_index.OverlayPanel, {
|
464
|
+
isTransitioning: state.isTransitioning,
|
461
465
|
isOpen: state.isOpen,
|
462
466
|
state: state,
|
463
467
|
triggerRef: triggerRef,
|
@@ -18,7 +18,7 @@ var container = {
|
|
18
18
|
borderLeft: '1px solid',
|
19
19
|
borderLeftColor: 'neutral.80',
|
20
20
|
boxShadow: '-2px 0px 2px 1px rgba(37, 55, 70, 0.15)',
|
21
|
-
display: '
|
21
|
+
display: 'flex !important',
|
22
22
|
p: '25px',
|
23
23
|
transition: 'right 500ms',
|
24
24
|
maxWidth: '100%',
|
@@ -34,8 +34,10 @@ var container = {
|
|
34
34
|
'&.is-full': {
|
35
35
|
width: 'container.full'
|
36
36
|
},
|
37
|
-
'&.is-open': {
|
38
|
-
|
37
|
+
'&.is-open.is-transitioning': {
|
38
|
+
right: 0
|
39
|
+
},
|
40
|
+
'&.is-open-no-transition': {
|
39
41
|
right: 0
|
40
42
|
}
|
41
43
|
};
|
@@ -57,11 +59,11 @@ var innerPanel = {
|
|
57
59
|
backgroundColor: 'accent.99'
|
58
60
|
};
|
59
61
|
var body = {
|
60
|
-
display: 'none',
|
62
|
+
display: 'none !important',
|
61
63
|
height: '100%',
|
62
64
|
width: '100%',
|
63
65
|
'&.is-open': {
|
64
|
-
display: 'flex'
|
66
|
+
display: 'flex !important'
|
65
67
|
}
|
66
68
|
};
|
67
69
|
var _default = {
|
package/lib/cjs/hooks/index.js
CHANGED
@@ -65,6 +65,12 @@ _Object$defineProperty(exports, "useModalState", {
|
|
65
65
|
return _useModalState["default"];
|
66
66
|
}
|
67
67
|
});
|
68
|
+
_Object$defineProperty(exports, "useMountTransition", {
|
69
|
+
enumerable: true,
|
70
|
+
get: function get() {
|
71
|
+
return _useMountTransition["default"];
|
72
|
+
}
|
73
|
+
});
|
68
74
|
_Object$defineProperty(exports, "useNavBarPress", {
|
69
75
|
enumerable: true,
|
70
76
|
get: function get() {
|
@@ -129,6 +135,7 @@ var _useFallbackImage = _interopRequireDefault(require("./useFallbackImage"));
|
|
129
135
|
var _useField = _interopRequireDefault(require("./useField"));
|
130
136
|
var _useLabelHeight = _interopRequireDefault(require("./useLabelHeight"));
|
131
137
|
var _useModalState = _interopRequireDefault(require("./useModalState"));
|
138
|
+
var _useMountTransition = _interopRequireDefault(require("./useMountTransition"));
|
132
139
|
var _useNavBarPress = _interopRequireDefault(require("./useNavBarPress"));
|
133
140
|
var _useOverlappingMenuHoverState = _interopRequireDefault(require("./useOverlappingMenuHoverState"));
|
134
141
|
var _useOverlayPanelState = _interopRequireDefault(require("./useOverlayPanelState"));
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
_Object$defineProperty(exports, "default", {
|
9
|
+
enumerable: true,
|
10
|
+
get: function get() {
|
11
|
+
return _useMountTransition["default"];
|
12
|
+
}
|
13
|
+
});
|
14
|
+
var _useMountTransition = _interopRequireDefault(require("./useMountTransition"));
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports["default"] = void 0;
|
9
|
+
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
11
|
+
var _react = require("react");
|
12
|
+
/**
|
13
|
+
* Allows for css transitions to be applied to components, while mounting or unmounting.
|
14
|
+
* @param {Object} [props] Properties provided to the state
|
15
|
+
* @param {Boolean} [props.isMounted] Whether the component has been mounted.
|
16
|
+
* @param {Number} [props.unmountDelay] Number value of the length of the transition in ms.
|
17
|
+
* `(isOpen: boolean) => void`
|
18
|
+
* @returns {Boolean} `isTransitioning`
|
19
|
+
*/
|
20
|
+
|
21
|
+
var useMountTransition = function useMountTransition(isMounted, unmountDelay) {
|
22
|
+
var _useState = (0, _react.useState)(false),
|
23
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
24
|
+
isTransitioning = _useState2[0],
|
25
|
+
setIsTransitioning = _useState2[1];
|
26
|
+
(0, _react.useEffect)(function () {
|
27
|
+
var timeoutId;
|
28
|
+
if (isMounted && !isTransitioning) {
|
29
|
+
setIsTransitioning(true);
|
30
|
+
} else if ( /* istanbul ignore next */
|
31
|
+
!isMounted && isTransitioning) {
|
32
|
+
/* istanbul ignore next */
|
33
|
+
timeoutId = (0, _setTimeout2["default"])(function () {
|
34
|
+
return setIsTransitioning(false);
|
35
|
+
}, unmountDelay);
|
36
|
+
}
|
37
|
+
return function () {
|
38
|
+
clearTimeout(timeoutId);
|
39
|
+
};
|
40
|
+
}, [unmountDelay, isMounted, isTransitioning]);
|
41
|
+
return isTransitioning;
|
42
|
+
};
|
43
|
+
var _default = useMountTransition;
|
44
|
+
exports["default"] = _default;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
4
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
8
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
9
|
+
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
12
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
13
|
+
var _ = require("../..");
|
14
|
+
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
15
|
+
var _useOverlayPanelState2 = _interopRequireDefault(require("../useOverlayPanelState/useOverlayPanelState"));
|
16
|
+
var _react2 = require("@emotion/react");
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
19
|
+
var overlayTestId = 'overlay-test';
|
20
|
+
var buttonTestId = 'button-test';
|
21
|
+
var closeButtonTestId = 'close-button-test';
|
22
|
+
var defaultOverlayProps = {
|
23
|
+
'data-testid': overlayTestId
|
24
|
+
};
|
25
|
+
var defaultButtonProps = {
|
26
|
+
'data-testid': buttonTestId
|
27
|
+
};
|
28
|
+
var defaultCloseButtonProps = {
|
29
|
+
'data-testid': closeButtonTestId
|
30
|
+
};
|
31
|
+
var ControlledWithTransition = function ControlledWithTransition() {
|
32
|
+
var _useOverlayPanelState = (0, _useOverlayPanelState2["default"])(),
|
33
|
+
state = _useOverlayPanelState.state,
|
34
|
+
onClose = _useOverlayPanelState.onClose;
|
35
|
+
var triggerRef = (0, _react.useRef)();
|
36
|
+
return (
|
37
|
+
// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
38
|
+
// readers when an overlay is open.
|
39
|
+
(0, _react2.jsx)(_.OverlayProvider, null, (0, _react2.jsx)(_.Button, (0, _extends2["default"])({
|
40
|
+
ref: triggerRef,
|
41
|
+
onPress: state.open,
|
42
|
+
"aria-expanded": state.isOpen
|
43
|
+
}, defaultButtonProps), "Open Panel"), (state.isOpen || state.isTransitioning) && (0, _react2.jsx)(_.OverlayPanel, (0, _extends2["default"])({
|
44
|
+
isOpen: state.isOpen,
|
45
|
+
isTransitioning: state.isTransitioning,
|
46
|
+
state: state,
|
47
|
+
triggerRef: triggerRef
|
48
|
+
}, defaultOverlayProps), (0, _react2.jsx)("div", null, (0, _react2.jsx)(_.Button, (0, _extends2["default"])({
|
49
|
+
onPress: function onPress() {
|
50
|
+
onClose(state, triggerRef);
|
51
|
+
},
|
52
|
+
"aria-expanded": state.isOpen
|
53
|
+
}, defaultCloseButtonProps), "Close Panel"), (0, _react2.jsx)("p", {
|
54
|
+
pt: "md"
|
55
|
+
}, (0, _stringify["default"])(state.isOpen)))))
|
56
|
+
);
|
57
|
+
};
|
58
|
+
test('default return', function () {
|
59
|
+
(0, _testWrapper.render)((0, _react2.jsx)(ControlledWithTransition, null));
|
60
|
+
var button = _testWrapper.screen.getByTestId(buttonTestId);
|
61
|
+
_userEvent["default"].click(button);
|
62
|
+
expect(_testWrapper.screen.getByTestId(overlayTestId)).toHaveClass('is-transitioning');
|
63
|
+
_userEvent["default"].click(button);
|
64
|
+
expect(_testWrapper.screen.getByTestId(overlayTestId)).toHaveClass('is-transitioning');
|
65
|
+
(0, _setTimeout2["default"])(function () {
|
66
|
+
expect(_testWrapper.screen.getByTestId(overlayTestId)).not.toHaveClass('is-transitioning');
|
67
|
+
}, 501);
|
68
|
+
});
|
@@ -1,17 +1,30 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
5
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
7
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
3
10
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
11
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
4
12
|
_Object$defineProperty(exports, "__esModule", {
|
5
13
|
value: true
|
6
14
|
});
|
7
15
|
exports["default"] = void 0;
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
8
17
|
var _reactStately = require("react-stately");
|
18
|
+
var _useMountTransition = _interopRequireDefault(require("../useMountTransition"));
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
9
21
|
/**
|
10
22
|
* Returns state-related data and functions for use with a Modal component.
|
11
23
|
* @param {Object} [props] Properties provided to the state
|
12
24
|
* @param {Boolean} [props.isDefaultOpen] Whether the modal is open by default (uncontrolled).
|
13
25
|
* @param {Boolean} [props.isOpen] Whether the modal is currently open (controlled).
|
14
26
|
* @param {Function} [props.onOpenChange] Handler that is called when the open state changes.
|
27
|
+
* @param {Number} [props.transitionDuration] Number value of the length of the transition in ms.
|
15
28
|
* `(isOpen: boolean) => void`
|
16
29
|
* @returns {Object} `{ isOpen: Boolean, open: Function, close: Function, toggle: Function }`
|
17
30
|
*/
|
@@ -19,12 +32,16 @@ var useOverlayPanelState = function useOverlayPanelState() {
|
|
19
32
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
20
33
|
var isDefaultOpen = props.isDefaultOpen,
|
21
34
|
isOpen = props.isOpen,
|
22
|
-
onOpenChange = props.onOpenChange
|
35
|
+
onOpenChange = props.onOpenChange,
|
36
|
+
_props$transitionDura = props.transitionDuration,
|
37
|
+
transitionDuration = _props$transitionDura === void 0 ? 500 : _props$transitionDura;
|
23
38
|
var state = (0, _reactStately.useOverlayTriggerState)({
|
24
39
|
defaultOpen: isDefaultOpen,
|
25
40
|
isOpen: isOpen,
|
26
41
|
onOpenChange: onOpenChange
|
27
42
|
});
|
43
|
+
var panelOpen = state.isOpen;
|
44
|
+
var isTransitioning = (0, _useMountTransition["default"])(panelOpen, transitionDuration);
|
28
45
|
var onClose = function onClose(stateProp, triggerRef, onCloseProp) {
|
29
46
|
if (stateProp) {
|
30
47
|
stateProp.close();
|
@@ -36,9 +53,13 @@ var useOverlayPanelState = function useOverlayPanelState() {
|
|
36
53
|
onCloseProp();
|
37
54
|
}
|
38
55
|
};
|
56
|
+
var thisState = _objectSpread(_objectSpread({}, state), {}, {
|
57
|
+
isTransitioning: isTransitioning
|
58
|
+
});
|
39
59
|
return {
|
40
|
-
state:
|
41
|
-
onClose: onClose
|
60
|
+
state: thisState,
|
61
|
+
onClose: onClose,
|
62
|
+
isTransitioning: isTransitioning
|
42
63
|
};
|
43
64
|
};
|
44
65
|
var _default = useOverlayPanelState;
|
@@ -14,9 +14,11 @@ test('default useOverlayPanelState', function () {
|
|
14
14
|
close: expect.any(Function),
|
15
15
|
toggle: expect.any(Function),
|
16
16
|
isOpen: expect.any(Boolean),
|
17
|
+
isTransitioning: expect.any(Boolean),
|
17
18
|
setOpen: expect.any(Function)
|
18
19
|
},
|
19
|
-
onClose: expect.any(Function)
|
20
|
+
onClose: expect.any(Function),
|
21
|
+
isTransitioning: expect.any(Boolean)
|
20
22
|
};
|
21
23
|
expect(result.current).toEqual(obj);
|
22
24
|
});
|
@@ -170,35 +170,10 @@ var sx = {
|
|
170
170
|
marginRight: 'auto'
|
171
171
|
}
|
172
172
|
},
|
173
|
-
listViewItem: {
|
174
|
-
minHeight: '75px',
|
175
|
-
padding: 1,
|
176
|
-
'&.has-inset-separator': {
|
177
|
-
'&:before': {
|
178
|
-
borderBottom: '1px solid',
|
179
|
-
borderBottomColor: 'line.light',
|
180
|
-
bottom: 0,
|
181
|
-
content: '""',
|
182
|
-
position: 'absolute',
|
183
|
-
right: 0,
|
184
|
-
width: 'calc(100% - 43px)'
|
185
|
-
}
|
186
|
-
},
|
187
|
-
'&.is-focused': {
|
188
|
-
'&:after': {
|
189
|
-
borderBottomColor: 'focus',
|
190
|
-
bottom: 0,
|
191
|
-
content: '""',
|
192
|
-
position: 'absolute',
|
193
|
-
right: 0,
|
194
|
-
width: 'calc(100% - 43px)'
|
195
|
-
}
|
196
|
-
}
|
197
|
-
},
|
198
173
|
topBracket: {
|
199
174
|
top: 50,
|
200
175
|
left: 12,
|
201
|
-
bottom:
|
176
|
+
bottom: -1,
|
202
177
|
position: 'absolute'
|
203
178
|
}
|
204
179
|
};
|
@@ -446,7 +421,10 @@ var Default = function Default(_ref) {
|
|
446
421
|
textValue: item.name,
|
447
422
|
"data-id": item.key,
|
448
423
|
listItemProps: {
|
449
|
-
|
424
|
+
variant: 'listViewItem.linkedViewContainer',
|
425
|
+
sx: {
|
426
|
+
padding: 1
|
427
|
+
}
|
450
428
|
}
|
451
429
|
}), (0, _react2.jsx)(ListElement, (0, _extends2["default"])({
|
452
430
|
isParent: item.childrenObjects,
|
@@ -163,8 +163,9 @@ export var CollapsiblePanelWithBadge = function CollapsiblePanelWithBadge(args)
|
|
163
163
|
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
164
164
|
ref: triggerRef,
|
165
165
|
onPress: state.open
|
166
|
-
}, "Open Panel"), ___EmotionJSX(OverlayPanel, {
|
166
|
+
}, "Open Panel"), (state.isOpen || state.isTransitioning) && ___EmotionJSX(OverlayPanel, {
|
167
167
|
isOpen: state.isOpen,
|
168
|
+
isTransitioning: state.isTransitioning,
|
168
169
|
size: "large",
|
169
170
|
p: "0"
|
170
171
|
}, ___EmotionJSX(Box, {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
4
|
-
var _excluded = ["children", "isOpen", "onClose", "className", "state", "size", "triggerRef"];
|
4
|
+
var _excluded = ["children", "isOpen", "isTransitioning", "onClose", "className", "state", "size", "triggerRef"];
|
5
5
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
6
6
|
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
7
7
|
import { FocusScope } from 'react-aria';
|
@@ -22,6 +22,7 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
22
22
|
var _props$sx;
|
23
23
|
var children = props.children,
|
24
24
|
isOpen = props.isOpen,
|
25
|
+
isTransitioning = props.isTransitioning,
|
25
26
|
onCloseProp = props.onClose,
|
26
27
|
className = props.className,
|
27
28
|
state = props.state,
|
@@ -35,8 +36,15 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
35
36
|
useImperativeHandle(ref, function () {
|
36
37
|
return overlayPanelRef.current;
|
37
38
|
});
|
39
|
+
|
40
|
+
// this is code to avoid regressions -- implementations that do not use the
|
41
|
+
// useMountTransition hook will not break, because this className gives the
|
42
|
+
// component the styling properties that it needs.
|
43
|
+
var isOpenNoTransition = isTransitioning === undefined && isOpen === true;
|
38
44
|
var _useStatusClasses = useStatusClasses(className, _defineProperty({
|
39
|
-
isOpen: isOpen
|
45
|
+
isOpen: isOpen,
|
46
|
+
isTransitioning: isTransitioning,
|
47
|
+
isOpenNoTransition: isOpenNoTransition
|
40
48
|
}, "is-".concat(props !== null && props !== void 0 && (_props$sx = props.sx) !== null && _props$sx !== void 0 && _props$sx.width ? 'custom' : size), size)),
|
41
49
|
classNames = _useStatusClasses.classNames;
|
42
50
|
var handleClose = function handleClose(e) {
|
@@ -52,7 +60,8 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
52
60
|
ref: overlayPanelRef
|
53
61
|
}, others, {
|
54
62
|
className: classNames,
|
55
|
-
onKeyUp: handleClose
|
63
|
+
onKeyUp: handleClose,
|
64
|
+
"aria-hidden": !isOpen
|
56
65
|
}), ___EmotionJSX(Box, {
|
57
66
|
variant: "overlayPanel.body",
|
58
67
|
className: classNames
|
@@ -73,6 +82,8 @@ OverlayPanel.propTypes = {
|
|
73
82
|
}),
|
74
83
|
/** Callback function that runs when the esc key is used to close the OverlayPanel. */
|
75
84
|
onClose: PropTypes.func,
|
85
|
+
/** Boolean that determines whether or not the css transition is occuring. */
|
86
|
+
isTransitioning: PropTypes.bool,
|
76
87
|
/** Ref that is connected to the button that triggers the overlay state.
|
77
88
|
Focus will return to this ref when the keyboard is used to close the OverlayPanel. */
|
78
89
|
triggerRef: PropTypes.shape({})
|
@@ -54,8 +54,9 @@ export var Default = function Default(_ref) {
|
|
54
54
|
ref: triggerRef,
|
55
55
|
onPress: state.open,
|
56
56
|
"aria-expanded": state.isOpen
|
57
|
-
}, "Open Panel"), state.isOpen && ___EmotionJSX(OverlayPanel, _extends({
|
57
|
+
}, "Open Panel"), (state.isOpen || state.isTransitioning) && ___EmotionJSX(OverlayPanel, _extends({
|
58
58
|
isOpen: state.isOpen,
|
59
|
+
isTransitioning: state.isTransitioning,
|
59
60
|
state: state
|
60
61
|
}, args, {
|
61
62
|
triggerRef: triggerRef
|
@@ -96,7 +97,7 @@ export var InnerPanel = function InnerPanel(_ref2) {
|
|
96
97
|
onCloseInner(innerState, innerTriggerRef);
|
97
98
|
};
|
98
99
|
var inner = innerState.isOpen && ___EmotionJSX(OverlayPanel, _extends({
|
99
|
-
variant: "overlayPanel.
|
100
|
+
variant: "overlayPanel.innerPanel" // applies higher z-index
|
100
101
|
,
|
101
102
|
isOpen: innerState.isOpen
|
102
103
|
}, args, {
|
@@ -116,8 +117,9 @@ export var InnerPanel = function InnerPanel(_ref2) {
|
|
116
117
|
}];
|
117
118
|
var outer =
|
118
119
|
// should have higher z-index applied
|
119
|
-
state.isOpen && ___EmotionJSX(OverlayPanel, _extends({
|
120
|
+
(state.isOpen || state.isTransitioning) && ___EmotionJSX(OverlayPanel, _extends({
|
120
121
|
isOpen: state.isOpen,
|
122
|
+
isTransitioning: state.isTransitioning,
|
121
123
|
sx: {
|
122
124
|
p: '0px'
|
123
125
|
}
|
@@ -181,7 +183,8 @@ export var CustomWidth = function CustomWidth() {
|
|
181
183
|
ref: triggerRef,
|
182
184
|
onPress: state.open,
|
183
185
|
"aria-expanded": state.isOpen
|
184
|
-
}, "Open Panel"), state.isOpen && ___EmotionJSX(OverlayPanel, {
|
186
|
+
}, "Open Panel"), (state.isOpen || state.isTransitioning) && ___EmotionJSX(OverlayPanel, {
|
187
|
+
isTransitioning: state.isTransitioning,
|
185
188
|
isOpen: state.isOpen,
|
186
189
|
state: state,
|
187
190
|
triggerRef: triggerRef,
|
@@ -440,7 +443,8 @@ export var Expandable = function Expandable() {
|
|
440
443
|
ref: triggerRef,
|
441
444
|
onPress: state.open,
|
442
445
|
"aria-expanded": state.isOpen
|
443
|
-
}, "Open Panel"), state.isOpen && ___EmotionJSX(OverlayPanel, {
|
446
|
+
}, "Open Panel"), (state.isOpen || state.isTransitioning) && ___EmotionJSX(OverlayPanel, {
|
447
|
+
isTransitioning: state.isTransitioning,
|
444
448
|
isOpen: state.isOpen,
|
445
449
|
state: state,
|
446
450
|
triggerRef: triggerRef,
|
@@ -11,7 +11,7 @@ var container = {
|
|
11
11
|
borderLeft: '1px solid',
|
12
12
|
borderLeftColor: 'neutral.80',
|
13
13
|
boxShadow: '-2px 0px 2px 1px rgba(37, 55, 70, 0.15)',
|
14
|
-
display: '
|
14
|
+
display: 'flex !important',
|
15
15
|
p: '25px',
|
16
16
|
transition: 'right 500ms',
|
17
17
|
maxWidth: '100%',
|
@@ -27,8 +27,10 @@ var container = {
|
|
27
27
|
'&.is-full': {
|
28
28
|
width: 'container.full'
|
29
29
|
},
|
30
|
-
'&.is-open': {
|
31
|
-
|
30
|
+
'&.is-open.is-transitioning': {
|
31
|
+
right: 0
|
32
|
+
},
|
33
|
+
'&.is-open-no-transition': {
|
32
34
|
right: 0
|
33
35
|
}
|
34
36
|
};
|
@@ -50,11 +52,11 @@ var innerPanel = {
|
|
50
52
|
backgroundColor: 'accent.99'
|
51
53
|
};
|
52
54
|
var body = {
|
53
|
-
display: 'none',
|
55
|
+
display: 'none !important',
|
54
56
|
height: '100%',
|
55
57
|
width: '100%',
|
56
58
|
'&.is-open': {
|
57
|
-
display: 'flex'
|
59
|
+
display: 'flex !important'
|
58
60
|
}
|
59
61
|
};
|
60
62
|
export default {
|
package/lib/hooks/index.js
CHANGED
@@ -8,6 +8,7 @@ export { default as useFallbackImage } from './useFallbackImage';
|
|
8
8
|
export { default as useField } from './useField';
|
9
9
|
export { default as useLabelHeight } from './useLabelHeight';
|
10
10
|
export { default as useModalState } from './useModalState';
|
11
|
+
export { default as useMountTransition } from './useMountTransition';
|
11
12
|
export { default as useNavBarPress } from './useNavBarPress';
|
12
13
|
export { default as useOverlappingMenuHoverState } from './useOverlappingMenuHoverState';
|
13
14
|
export { default as useOverlayPanelState } from './useOverlayPanelState';
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useMountTransition';
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
3
|
+
import { useEffect, useState } from 'react';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Allows for css transitions to be applied to components, while mounting or unmounting.
|
7
|
+
* @param {Object} [props] Properties provided to the state
|
8
|
+
* @param {Boolean} [props.isMounted] Whether the component has been mounted.
|
9
|
+
* @param {Number} [props.unmountDelay] Number value of the length of the transition in ms.
|
10
|
+
* `(isOpen: boolean) => void`
|
11
|
+
* @returns {Boolean} `isTransitioning`
|
12
|
+
*/
|
13
|
+
|
14
|
+
var useMountTransition = function useMountTransition(isMounted, unmountDelay) {
|
15
|
+
var _useState = useState(false),
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
17
|
+
isTransitioning = _useState2[0],
|
18
|
+
setIsTransitioning = _useState2[1];
|
19
|
+
useEffect(function () {
|
20
|
+
var timeoutId;
|
21
|
+
if (isMounted && !isTransitioning) {
|
22
|
+
setIsTransitioning(true);
|
23
|
+
} else if ( /* istanbul ignore next */
|
24
|
+
!isMounted && isTransitioning) {
|
25
|
+
/* istanbul ignore next */
|
26
|
+
timeoutId = _setTimeout(function () {
|
27
|
+
return setIsTransitioning(false);
|
28
|
+
}, unmountDelay);
|
29
|
+
}
|
30
|
+
return function () {
|
31
|
+
clearTimeout(timeoutId);
|
32
|
+
};
|
33
|
+
}, [unmountDelay, isMounted, isTransitioning]);
|
34
|
+
return isTransitioning;
|
35
|
+
};
|
36
|
+
export default useMountTransition;
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
3
|
+
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
4
|
+
import React, { useRef } from 'react';
|
5
|
+
import userEvent from '@testing-library/user-event';
|
6
|
+
import { Button, OverlayPanel, OverlayProvider } from '../..';
|
7
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
8
|
+
import useOverlayPanelState from '../useOverlayPanelState/useOverlayPanelState';
|
9
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
|
+
var overlayTestId = 'overlay-test';
|
11
|
+
var buttonTestId = 'button-test';
|
12
|
+
var closeButtonTestId = 'close-button-test';
|
13
|
+
var defaultOverlayProps = {
|
14
|
+
'data-testid': overlayTestId
|
15
|
+
};
|
16
|
+
var defaultButtonProps = {
|
17
|
+
'data-testid': buttonTestId
|
18
|
+
};
|
19
|
+
var defaultCloseButtonProps = {
|
20
|
+
'data-testid': closeButtonTestId
|
21
|
+
};
|
22
|
+
var ControlledWithTransition = function ControlledWithTransition() {
|
23
|
+
var _useOverlayPanelState = useOverlayPanelState(),
|
24
|
+
state = _useOverlayPanelState.state,
|
25
|
+
onClose = _useOverlayPanelState.onClose;
|
26
|
+
var triggerRef = useRef();
|
27
|
+
return (
|
28
|
+
// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
29
|
+
// readers when an overlay is open.
|
30
|
+
___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, _extends({
|
31
|
+
ref: triggerRef,
|
32
|
+
onPress: state.open,
|
33
|
+
"aria-expanded": state.isOpen
|
34
|
+
}, defaultButtonProps), "Open Panel"), (state.isOpen || state.isTransitioning) && ___EmotionJSX(OverlayPanel, _extends({
|
35
|
+
isOpen: state.isOpen,
|
36
|
+
isTransitioning: state.isTransitioning,
|
37
|
+
state: state,
|
38
|
+
triggerRef: triggerRef
|
39
|
+
}, defaultOverlayProps), ___EmotionJSX("div", null, ___EmotionJSX(Button, _extends({
|
40
|
+
onPress: function onPress() {
|
41
|
+
onClose(state, triggerRef);
|
42
|
+
},
|
43
|
+
"aria-expanded": state.isOpen
|
44
|
+
}, defaultCloseButtonProps), "Close Panel"), ___EmotionJSX("p", {
|
45
|
+
pt: "md"
|
46
|
+
}, _JSON$stringify(state.isOpen)))))
|
47
|
+
);
|
48
|
+
};
|
49
|
+
test('default return', function () {
|
50
|
+
render(___EmotionJSX(ControlledWithTransition, null));
|
51
|
+
var button = screen.getByTestId(buttonTestId);
|
52
|
+
userEvent.click(button);
|
53
|
+
expect(screen.getByTestId(overlayTestId)).toHaveClass('is-transitioning');
|
54
|
+
userEvent.click(button);
|
55
|
+
expect(screen.getByTestId(overlayTestId)).toHaveClass('is-transitioning');
|
56
|
+
_setTimeout(function () {
|
57
|
+
expect(screen.getByTestId(overlayTestId)).not.toHaveClass('is-transitioning');
|
58
|
+
}, 501);
|
59
|
+
});
|
@@ -1,4 +1,16 @@
|
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
1
12
|
import { useOverlayTriggerState } from 'react-stately';
|
13
|
+
import useMountTransition from '../useMountTransition';
|
2
14
|
|
3
15
|
/**
|
4
16
|
* Returns state-related data and functions for use with a Modal component.
|
@@ -6,6 +18,7 @@ import { useOverlayTriggerState } from 'react-stately';
|
|
6
18
|
* @param {Boolean} [props.isDefaultOpen] Whether the modal is open by default (uncontrolled).
|
7
19
|
* @param {Boolean} [props.isOpen] Whether the modal is currently open (controlled).
|
8
20
|
* @param {Function} [props.onOpenChange] Handler that is called when the open state changes.
|
21
|
+
* @param {Number} [props.transitionDuration] Number value of the length of the transition in ms.
|
9
22
|
* `(isOpen: boolean) => void`
|
10
23
|
* @returns {Object} `{ isOpen: Boolean, open: Function, close: Function, toggle: Function }`
|
11
24
|
*/
|
@@ -13,12 +26,16 @@ var useOverlayPanelState = function useOverlayPanelState() {
|
|
13
26
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
14
27
|
var isDefaultOpen = props.isDefaultOpen,
|
15
28
|
isOpen = props.isOpen,
|
16
|
-
onOpenChange = props.onOpenChange
|
29
|
+
onOpenChange = props.onOpenChange,
|
30
|
+
_props$transitionDura = props.transitionDuration,
|
31
|
+
transitionDuration = _props$transitionDura === void 0 ? 500 : _props$transitionDura;
|
17
32
|
var state = useOverlayTriggerState({
|
18
33
|
defaultOpen: isDefaultOpen,
|
19
34
|
isOpen: isOpen,
|
20
35
|
onOpenChange: onOpenChange
|
21
36
|
});
|
37
|
+
var panelOpen = state.isOpen;
|
38
|
+
var isTransitioning = useMountTransition(panelOpen, transitionDuration);
|
22
39
|
var onClose = function onClose(stateProp, triggerRef, onCloseProp) {
|
23
40
|
if (stateProp) {
|
24
41
|
stateProp.close();
|
@@ -30,9 +47,13 @@ var useOverlayPanelState = function useOverlayPanelState() {
|
|
30
47
|
onCloseProp();
|
31
48
|
}
|
32
49
|
};
|
50
|
+
var thisState = _objectSpread(_objectSpread({}, state), {}, {
|
51
|
+
isTransitioning: isTransitioning
|
52
|
+
});
|
33
53
|
return {
|
34
|
-
state:
|
35
|
-
onClose: onClose
|
54
|
+
state: thisState,
|
55
|
+
onClose: onClose,
|
56
|
+
isTransitioning: isTransitioning
|
36
57
|
};
|
37
58
|
};
|
38
59
|
export default useOverlayPanelState;
|
@@ -11,9 +11,11 @@ test('default useOverlayPanelState', function () {
|
|
11
11
|
close: expect.any(Function),
|
12
12
|
toggle: expect.any(Function),
|
13
13
|
isOpen: expect.any(Boolean),
|
14
|
+
isTransitioning: expect.any(Boolean),
|
14
15
|
setOpen: expect.any(Function)
|
15
16
|
},
|
16
|
-
onClose: expect.any(Function)
|
17
|
+
onClose: expect.any(Function),
|
18
|
+
isTransitioning: expect.any(Boolean)
|
17
19
|
};
|
18
20
|
expect(result.current).toEqual(obj);
|
19
21
|
});
|
@@ -156,35 +156,10 @@ var sx = {
|
|
156
156
|
marginRight: 'auto'
|
157
157
|
}
|
158
158
|
},
|
159
|
-
listViewItem: {
|
160
|
-
minHeight: '75px',
|
161
|
-
padding: 1,
|
162
|
-
'&.has-inset-separator': {
|
163
|
-
'&:before': {
|
164
|
-
borderBottom: '1px solid',
|
165
|
-
borderBottomColor: 'line.light',
|
166
|
-
bottom: 0,
|
167
|
-
content: '""',
|
168
|
-
position: 'absolute',
|
169
|
-
right: 0,
|
170
|
-
width: 'calc(100% - 43px)'
|
171
|
-
}
|
172
|
-
},
|
173
|
-
'&.is-focused': {
|
174
|
-
'&:after': {
|
175
|
-
borderBottomColor: 'focus',
|
176
|
-
bottom: 0,
|
177
|
-
content: '""',
|
178
|
-
position: 'absolute',
|
179
|
-
right: 0,
|
180
|
-
width: 'calc(100% - 43px)'
|
181
|
-
}
|
182
|
-
}
|
183
|
-
},
|
184
159
|
topBracket: {
|
185
160
|
top: 50,
|
186
161
|
left: 12,
|
187
|
-
bottom:
|
162
|
+
bottom: -1,
|
188
163
|
position: 'absolute'
|
189
164
|
}
|
190
165
|
};
|
@@ -432,7 +407,10 @@ export var Default = function Default(_ref) {
|
|
432
407
|
textValue: item.name,
|
433
408
|
"data-id": item.key,
|
434
409
|
listItemProps: {
|
435
|
-
|
410
|
+
variant: 'listViewItem.linkedViewContainer',
|
411
|
+
sx: {
|
412
|
+
padding: 1
|
413
|
+
}
|
436
414
|
}
|
437
415
|
}), ___EmotionJSX(ListElement, _extends({
|
438
416
|
isParent: item.childrenObjects,
|