@pingux/astro 2.0.6-alpha.2 → 2.1.0-alpha.1
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/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +3 -10
- package/lib/cjs/components/Input/Input.styles.js +13 -17
- 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/components/SearchField/SearchField.js +3 -2
- package/lib/cjs/components/SelectField/Select.styles.js +1 -2
- 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/components/CollapsiblePanel/CollapsiblePanel.stories.js +2 -1
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +3 -10
- package/lib/components/Input/Input.styles.js +11 -16
- 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/components/SearchField/SearchField.js +3 -2
- package/lib/components/SelectField/Select.styles.js +1 -2
- 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/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, {
|
@@ -224,21 +224,14 @@ var EnvironmentBreadcrumb = /*#__PURE__*/(0, _react.forwardRef)(function (props,
|
|
224
224
|
restoreFocus: true,
|
225
225
|
autoFocus: true,
|
226
226
|
contain: true
|
227
|
-
}, (0, _react2.jsx)(_index.ScrollBox, {
|
228
|
-
ref: scrollBoxRef
|
229
227
|
}, (0, _react2.jsx)(_index.SearchField, (0, _extends2["default"])({
|
230
228
|
placeholder: "Search",
|
231
229
|
"aria-label": "Items Search",
|
232
230
|
"data-testid": "Environment-Breadcrumb-Search",
|
233
|
-
containerProps: {
|
234
|
-
// this one is needed to cancel default scrollBox items behavior
|
235
|
-
sx: {
|
236
|
-
overflow: 'visible',
|
237
|
-
padding: '3px'
|
238
|
-
}
|
239
|
-
},
|
240
231
|
onChange: setSearchValue
|
241
|
-
}, searchProps)),
|
232
|
+
}, searchProps)), (0, _react2.jsx)(_index.ScrollBox, {
|
233
|
+
ref: scrollBoxRef
|
234
|
+
}, checkIfListEmpty() ? EmptyListState : (0, _react2.jsx)(_ListBox["default"], {
|
242
235
|
"aria-label": "Items List",
|
243
236
|
"data-id": breadCrumbDataIds.dropdownList,
|
244
237
|
state: listBoxState
|
@@ -12,10 +12,9 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
12
12
|
_Object$defineProperty(exports, "__esModule", {
|
13
13
|
value: true
|
14
14
|
});
|
15
|
-
exports.input = void 0;
|
15
|
+
exports.input = exports.defaultFocus = void 0;
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
17
17
|
var _statuses = _interopRequireDefault(require("../../utils/devUtils/constants/statuses"));
|
18
|
-
var _Buttons = require("../Button/Buttons.styles");
|
19
18
|
var _Text = require("../Text/Text.styles");
|
20
19
|
var _input$fieldControlWr, _objectSpread2;
|
21
20
|
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; }
|
@@ -26,8 +25,15 @@ var activeFloatLabel = {
|
|
26
25
|
pt: 'md',
|
27
26
|
pb: 'xs'
|
28
27
|
};
|
28
|
+
var defaultFocus = {
|
29
|
+
borderColor: 'active',
|
30
|
+
outline: '1px solid',
|
31
|
+
outlineColor: 'accent.60',
|
32
|
+
outlineOffset: '0px'
|
33
|
+
};
|
29
34
|
|
30
35
|
// Default input styling
|
36
|
+
exports.defaultFocus = defaultFocus;
|
31
37
|
var input = _objectSpread(_objectSpread({}, _Text.text.inputValue), {}, {
|
32
38
|
appearance: 'none',
|
33
39
|
boxSizing: 'border-box',
|
@@ -45,11 +51,7 @@ var input = _objectSpread(_objectSpread({}, _Text.text.inputValue), {}, {
|
|
45
51
|
py: 'sm',
|
46
52
|
width: '100%',
|
47
53
|
outline: 'none',
|
48
|
-
'&.is-focused': {
|
49
|
-
outline: '1px solid',
|
50
|
-
outlineColor: 'focus',
|
51
|
-
outlineOffset: '2px'
|
52
|
-
},
|
54
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
53
55
|
'.is-float-label &': {
|
54
56
|
height: '45px'
|
55
57
|
},
|
@@ -69,7 +71,7 @@ var input = _objectSpread(_objectSpread({}, _Text.text.inputValue), {}, {
|
|
69
71
|
'&::-ms-reveal, &::-ms-clear': {
|
70
72
|
display: 'none'
|
71
73
|
},
|
72
|
-
'&.is-error': {
|
74
|
+
'&.is-error:not(.is-focused)': {
|
73
75
|
borderColor: 'critical.bright'
|
74
76
|
}
|
75
77
|
});
|
@@ -81,10 +83,7 @@ input.large = _objectSpread(_objectSpread({}, input), {}, {
|
|
81
83
|
height: '4em'
|
82
84
|
});
|
83
85
|
input.search = _objectSpread(_objectSpread({}, input), {}, {
|
84
|
-
'&.is-focused': {
|
85
|
-
outline: 'none',
|
86
|
-
borderColor: 'focus'
|
87
|
-
}
|
86
|
+
'&.is-focused': _objectSpread({}, defaultFocus)
|
88
87
|
});
|
89
88
|
input.small = _objectSpread(_objectSpread({}, input), {}, {
|
90
89
|
height: '28px',
|
@@ -176,7 +175,6 @@ input.multivaluesWrapper = _objectSpread(_objectSpread({}, input.fieldControlWra
|
|
176
175
|
borderWidth: 1,
|
177
176
|
flexDirection: 'row !important',
|
178
177
|
flexWrap: 'wrap',
|
179
|
-
left: 2,
|
180
178
|
pt: 6,
|
181
179
|
pr: 10,
|
182
180
|
pb: 5,
|
@@ -195,7 +193,7 @@ input.multivaluesWrapper = _objectSpread(_objectSpread({}, input.fieldControlWra
|
|
195
193
|
bg: 'active',
|
196
194
|
width: 3,
|
197
195
|
top: -1,
|
198
|
-
left: -
|
196
|
+
left: -1,
|
199
197
|
bottom: -1
|
200
198
|
},
|
201
199
|
'> input': {
|
@@ -209,9 +207,7 @@ input.multivaluesWrapper = _objectSpread(_objectSpread({}, input.fieldControlWra
|
|
209
207
|
outline: 'none'
|
210
208
|
}
|
211
209
|
},
|
212
|
-
'&.is-focused': _objectSpread({
|
213
|
-
boxShadow: 'none'
|
214
|
-
}, _Buttons.defaultFocus)
|
210
|
+
'&.is-focused': _objectSpread({}, defaultFocus)
|
215
211
|
}, (0, _defineProperty2["default"])(_objectSpread2, "&.is-".concat(_statuses["default"].ERROR, "::after"), {
|
216
212
|
bg: 'critical.bright'
|
217
213
|
}), (0, _defineProperty2["default"])(_objectSpread2, "&.is-".concat(_statuses["default"].SUCCESS, "::after"), {
|
@@ -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 = {
|
@@ -83,9 +83,10 @@ var SearchField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
83
83
|
return (0, _react2.jsx)(_.Box, fieldContainerProps, label && (0, _react2.jsx)(_.Label, fieldLabelProps), (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
84
84
|
variant: "forms.search.wrapper"
|
85
85
|
}, fieldControlWrapperProps), (0, _react2.jsx)(_.Input, (0, _extends2["default"])({
|
86
|
+
variant: "forms.input.search",
|
86
87
|
ref: searchRef,
|
87
|
-
pl:
|
88
|
-
pr:
|
88
|
+
pl: "xl",
|
89
|
+
pr: "xl"
|
89
90
|
}, fieldControlInputProps)), icon && (0, _react2.jsx)(_.Icon, (0, _extends2["default"])({
|
90
91
|
icon: icon,
|
91
92
|
variant: "forms.search.icon",
|
@@ -15,7 +15,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
15
15
|
exports.select = void 0;
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
17
17
|
var _variants = require("../../styles/variants");
|
18
|
-
var _Buttons = require("../Button/Buttons.styles");
|
19
18
|
var _Input = require("../Input/Input.styles");
|
20
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; }
|
21
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; }
|
@@ -28,7 +27,7 @@ var activeFloatLabel = {
|
|
28
27
|
var select = _objectSpread(_objectSpread({}, _Input.input), {}, {
|
29
28
|
display: 'flex',
|
30
29
|
alignItems: 'center',
|
31
|
-
'&.is-focused': _objectSpread({},
|
30
|
+
'&.is-focused': _objectSpread({}, _Input.defaultFocus),
|
32
31
|
'.is-float-label &': _objectSpread({
|
33
32
|
height: '45px'
|
34
33
|
}, activeFloatLabel)
|
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
|
});
|
@@ -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, {
|
@@ -210,21 +210,14 @@ var EnvironmentBreadcrumb = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
210
210
|
restoreFocus: true,
|
211
211
|
autoFocus: true,
|
212
212
|
contain: true
|
213
|
-
}, ___EmotionJSX(ScrollBox, {
|
214
|
-
ref: scrollBoxRef
|
215
213
|
}, ___EmotionJSX(SearchField, _extends({
|
216
214
|
placeholder: "Search",
|
217
215
|
"aria-label": "Items Search",
|
218
216
|
"data-testid": "Environment-Breadcrumb-Search",
|
219
|
-
containerProps: {
|
220
|
-
// this one is needed to cancel default scrollBox items behavior
|
221
|
-
sx: {
|
222
|
-
overflow: 'visible',
|
223
|
-
padding: '3px'
|
224
|
-
}
|
225
|
-
},
|
226
217
|
onChange: setSearchValue
|
227
|
-
}, searchProps)),
|
218
|
+
}, searchProps)), ___EmotionJSX(ScrollBox, {
|
219
|
+
ref: scrollBoxRef
|
220
|
+
}, checkIfListEmpty() ? EmptyListState : ___EmotionJSX(ListBox, {
|
228
221
|
"aria-label": "Items List",
|
229
222
|
"data-id": breadCrumbDataIds.dropdownList,
|
230
223
|
state: listBoxState
|
@@ -11,7 +11,6 @@ var _input$fieldControlWr, _objectSpread2;
|
|
11
11
|
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; }
|
12
12
|
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; }
|
13
13
|
import statuses from '../../utils/devUtils/constants/statuses';
|
14
|
-
import { defaultFocus } from '../Button/Buttons.styles';
|
15
14
|
import { text } from '../Text/Text.styles';
|
16
15
|
|
17
16
|
// Styles for default input and variants go here.
|
@@ -20,6 +19,12 @@ var activeFloatLabel = {
|
|
20
19
|
pt: 'md',
|
21
20
|
pb: 'xs'
|
22
21
|
};
|
22
|
+
export var defaultFocus = {
|
23
|
+
borderColor: 'active',
|
24
|
+
outline: '1px solid',
|
25
|
+
outlineColor: 'accent.60',
|
26
|
+
outlineOffset: '0px'
|
27
|
+
};
|
23
28
|
|
24
29
|
// Default input styling
|
25
30
|
export var input = _objectSpread(_objectSpread({}, text.inputValue), {}, {
|
@@ -39,11 +44,7 @@ export var input = _objectSpread(_objectSpread({}, text.inputValue), {}, {
|
|
39
44
|
py: 'sm',
|
40
45
|
width: '100%',
|
41
46
|
outline: 'none',
|
42
|
-
'&.is-focused': {
|
43
|
-
outline: '1px solid',
|
44
|
-
outlineColor: 'focus',
|
45
|
-
outlineOffset: '2px'
|
46
|
-
},
|
47
|
+
'&.is-focused': _objectSpread({}, defaultFocus),
|
47
48
|
'.is-float-label &': {
|
48
49
|
height: '45px'
|
49
50
|
},
|
@@ -63,7 +64,7 @@ export var input = _objectSpread(_objectSpread({}, text.inputValue), {}, {
|
|
63
64
|
'&::-ms-reveal, &::-ms-clear': {
|
64
65
|
display: 'none'
|
65
66
|
},
|
66
|
-
'&.is-error': {
|
67
|
+
'&.is-error:not(.is-focused)': {
|
67
68
|
borderColor: 'critical.bright'
|
68
69
|
}
|
69
70
|
});
|
@@ -74,10 +75,7 @@ input.large = _objectSpread(_objectSpread({}, input), {}, {
|
|
74
75
|
height: '4em'
|
75
76
|
});
|
76
77
|
input.search = _objectSpread(_objectSpread({}, input), {}, {
|
77
|
-
'&.is-focused': {
|
78
|
-
outline: 'none',
|
79
|
-
borderColor: 'focus'
|
80
|
-
}
|
78
|
+
'&.is-focused': _objectSpread({}, defaultFocus)
|
81
79
|
});
|
82
80
|
input.small = _objectSpread(_objectSpread({}, input), {}, {
|
83
81
|
height: '28px',
|
@@ -169,7 +167,6 @@ input.multivaluesWrapper = _objectSpread(_objectSpread({}, input.fieldControlWra
|
|
169
167
|
borderWidth: 1,
|
170
168
|
flexDirection: 'row !important',
|
171
169
|
flexWrap: 'wrap',
|
172
|
-
left: 2,
|
173
170
|
pt: 6,
|
174
171
|
pr: 10,
|
175
172
|
pb: 5,
|
@@ -188,7 +185,7 @@ input.multivaluesWrapper = _objectSpread(_objectSpread({}, input.fieldControlWra
|
|
188
185
|
bg: 'active',
|
189
186
|
width: 3,
|
190
187
|
top: -1,
|
191
|
-
left: -
|
188
|
+
left: -1,
|
192
189
|
bottom: -1
|
193
190
|
},
|
194
191
|
'> input': {
|
@@ -202,9 +199,7 @@ input.multivaluesWrapper = _objectSpread(_objectSpread({}, input.fieldControlWra
|
|
202
199
|
outline: 'none'
|
203
200
|
}
|
204
201
|
},
|
205
|
-
'&.is-focused': _objectSpread({
|
206
|
-
boxShadow: 'none'
|
207
|
-
}, defaultFocus)
|
202
|
+
'&.is-focused': _objectSpread({}, defaultFocus)
|
208
203
|
}, _defineProperty(_objectSpread2, "&.is-".concat(statuses.ERROR, "::after"), {
|
209
204
|
bg: 'critical.bright'
|
210
205
|
}), _defineProperty(_objectSpread2, "&.is-".concat(statuses.SUCCESS, "::after"), {
|
@@ -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 {
|
@@ -73,9 +73,10 @@ var SearchField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
73
73
|
return ___EmotionJSX(Box, fieldContainerProps, label && ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, _extends({
|
74
74
|
variant: "forms.search.wrapper"
|
75
75
|
}, fieldControlWrapperProps), ___EmotionJSX(Input, _extends({
|
76
|
+
variant: "forms.input.search",
|
76
77
|
ref: searchRef,
|
77
|
-
pl:
|
78
|
-
pr:
|
78
|
+
pl: "xl",
|
79
|
+
pr: "xl"
|
79
80
|
}, fieldControlInputProps)), icon && ___EmotionJSX(Icon, _extends({
|
80
81
|
icon: icon,
|
81
82
|
variant: "forms.search.icon",
|
@@ -11,8 +11,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
11
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; }
|
12
12
|
// Styles for default select and variants go here.
|
13
13
|
import { text } from '../../styles/variants';
|
14
|
-
import { defaultFocus } from '../
|
15
|
-
import { input } from '../Input/Input.styles';
|
14
|
+
import { defaultFocus, input } from '../Input/Input.styles';
|
16
15
|
var activeFloatLabel = {
|
17
16
|
pt: 'md',
|
18
17
|
pb: 'xs'
|
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
|
});
|