@pingux/astro 1.2.0-alpha.8 → 1.2.0-alpha.9
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.
@@ -18,8 +18,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
18
18
|
|
19
19
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
20
20
|
|
21
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
22
|
-
|
23
21
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
24
22
|
|
25
23
|
var _react = _interopRequireWildcard(require("react"));
|
@@ -52,14 +50,8 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
52
50
|
onClose = _useOverlayPanelState.onClose;
|
53
51
|
|
54
52
|
var overlayPanelRef = (0, _react.useRef)();
|
55
|
-
|
56
|
-
var _useState = (0, _react.useState)(true),
|
57
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
58
|
-
contain = _useState2[0],
|
59
|
-
setIsContained = _useState2[1];
|
60
53
|
/* istanbul ignore next */
|
61
54
|
|
62
|
-
|
63
55
|
(0, _react.useImperativeHandle)(ref, function () {
|
64
56
|
return overlayPanelRef.current;
|
65
57
|
});
|
@@ -73,18 +65,12 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
73
65
|
e.stopPropagation();
|
74
66
|
|
75
67
|
if (e.key === 'Escape') {
|
76
|
-
|
68
|
+
onClose(state, triggerRef, onCloseProp);
|
77
69
|
}
|
78
70
|
};
|
79
71
|
|
80
|
-
(0, _react.useEffect)(function () {
|
81
|
-
if (!contain && onClose) {
|
82
|
-
onClose(state, triggerRef, onCloseProp);
|
83
|
-
}
|
84
|
-
}, [contain]);
|
85
72
|
return (0, _react2.jsx)(_focus.FocusScope, {
|
86
|
-
autoFocus: true
|
87
|
-
contain: contain
|
73
|
+
autoFocus: true
|
88
74
|
}, (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
89
75
|
variant: "overlayPanel.overlayPanel",
|
90
76
|
ref: overlayPanelRef
|
@@ -79,6 +79,15 @@ test('onClose callback fires when provided', function () {
|
|
79
79
|
|
80
80
|
expect(onClose).toHaveBeenCalled();
|
81
81
|
});
|
82
|
+
test('custom classname can be passed', function () {
|
83
|
+
getComponent({
|
84
|
+
className: 'testing-class'
|
85
|
+
});
|
86
|
+
|
87
|
+
var overlayPanel = _testWrapper.screen.getByTestId(testId);
|
88
|
+
|
89
|
+
expect(overlayPanel).toHaveClass('testing-class');
|
90
|
+
});
|
82
91
|
test('neither callback fires when not provided', function () {
|
83
92
|
var onClose = jest.fn();
|
84
93
|
getComponent({
|
@@ -137,4 +146,39 @@ test('triggerRef.current.focus() fires when provided', function () {
|
|
137
146
|
});
|
138
147
|
|
139
148
|
expect(focusFunction).toHaveBeenCalled();
|
149
|
+
});
|
150
|
+
test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
|
151
|
+
var onClose = jest.fn();
|
152
|
+
var focusFunction = jest.fn();
|
153
|
+
var state = {
|
154
|
+
close: onClose
|
155
|
+
};
|
156
|
+
var triggerRef = {
|
157
|
+
current: {
|
158
|
+
focus: focusFunction
|
159
|
+
}
|
160
|
+
};
|
161
|
+
getComponent({
|
162
|
+
state: state,
|
163
|
+
children: (0, _react2.jsx)("div", null, "Test"),
|
164
|
+
triggerRef: triggerRef
|
165
|
+
});
|
166
|
+
|
167
|
+
var overlayPanel = _testWrapper.screen.getByTestId(testId);
|
168
|
+
|
169
|
+
_testWrapper.fireEvent.keyDown(overlayPanel, {
|
170
|
+
key: 'KeyA',
|
171
|
+
code: 'KeyA',
|
172
|
+
keyCode: 65,
|
173
|
+
charCode: 65
|
174
|
+
});
|
175
|
+
|
176
|
+
_testWrapper.fireEvent.keyUp(overlayPanel, {
|
177
|
+
key: 'KeyA',
|
178
|
+
code: 'KeyA',
|
179
|
+
keyCode: 65,
|
180
|
+
charCode: 65
|
181
|
+
});
|
182
|
+
|
183
|
+
expect(focusFunction).not.toHaveBeenCalled();
|
140
184
|
});
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
3
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
4
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
5
4
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
|
-
import React, { forwardRef, useRef, useImperativeHandle
|
5
|
+
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
7
6
|
import PropTypes from 'prop-types';
|
8
7
|
import { FocusScope } from '@react-aria/focus';
|
9
8
|
import Box from '../Box';
|
@@ -26,14 +25,8 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
25
|
onClose = _useOverlayPanelState.onClose;
|
27
26
|
|
28
27
|
var overlayPanelRef = useRef();
|
29
|
-
|
30
|
-
var _useState = useState(true),
|
31
|
-
_useState2 = _slicedToArray(_useState, 2),
|
32
|
-
contain = _useState2[0],
|
33
|
-
setIsContained = _useState2[1];
|
34
28
|
/* istanbul ignore next */
|
35
29
|
|
36
|
-
|
37
30
|
useImperativeHandle(ref, function () {
|
38
31
|
return overlayPanelRef.current;
|
39
32
|
});
|
@@ -47,18 +40,12 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
47
40
|
e.stopPropagation();
|
48
41
|
|
49
42
|
if (e.key === 'Escape') {
|
50
|
-
|
43
|
+
onClose(state, triggerRef, onCloseProp);
|
51
44
|
}
|
52
45
|
};
|
53
46
|
|
54
|
-
useEffect(function () {
|
55
|
-
if (!contain && onClose) {
|
56
|
-
onClose(state, triggerRef, onCloseProp);
|
57
|
-
}
|
58
|
-
}, [contain]);
|
59
47
|
return ___EmotionJSX(FocusScope, {
|
60
|
-
autoFocus: true
|
61
|
-
contain: contain
|
48
|
+
autoFocus: true
|
62
49
|
}, ___EmotionJSX(Box, _extends({
|
63
50
|
variant: "overlayPanel.overlayPanel",
|
64
51
|
ref: overlayPanelRef
|
@@ -60,6 +60,13 @@ test('onClose callback fires when provided', function () {
|
|
60
60
|
});
|
61
61
|
expect(onClose).toHaveBeenCalled();
|
62
62
|
});
|
63
|
+
test('custom classname can be passed', function () {
|
64
|
+
getComponent({
|
65
|
+
className: 'testing-class'
|
66
|
+
});
|
67
|
+
var overlayPanel = screen.getByTestId(testId);
|
68
|
+
expect(overlayPanel).toHaveClass('testing-class');
|
69
|
+
});
|
63
70
|
test('neither callback fires when not provided', function () {
|
64
71
|
var onClose = jest.fn();
|
65
72
|
getComponent({
|
@@ -110,4 +117,35 @@ test('triggerRef.current.focus() fires when provided', function () {
|
|
110
117
|
charCode: 27
|
111
118
|
});
|
112
119
|
expect(focusFunction).toHaveBeenCalled();
|
120
|
+
});
|
121
|
+
test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
|
122
|
+
var onClose = jest.fn();
|
123
|
+
var focusFunction = jest.fn();
|
124
|
+
var state = {
|
125
|
+
close: onClose
|
126
|
+
};
|
127
|
+
var triggerRef = {
|
128
|
+
current: {
|
129
|
+
focus: focusFunction
|
130
|
+
}
|
131
|
+
};
|
132
|
+
getComponent({
|
133
|
+
state: state,
|
134
|
+
children: ___EmotionJSX("div", null, "Test"),
|
135
|
+
triggerRef: triggerRef
|
136
|
+
});
|
137
|
+
var overlayPanel = screen.getByTestId(testId);
|
138
|
+
fireEvent.keyDown(overlayPanel, {
|
139
|
+
key: 'KeyA',
|
140
|
+
code: 'KeyA',
|
141
|
+
keyCode: 65,
|
142
|
+
charCode: 65
|
143
|
+
});
|
144
|
+
fireEvent.keyUp(overlayPanel, {
|
145
|
+
key: 'KeyA',
|
146
|
+
code: 'KeyA',
|
147
|
+
keyCode: 65,
|
148
|
+
charCode: 65
|
149
|
+
});
|
150
|
+
expect(focusFunction).not.toHaveBeenCalled();
|
113
151
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pingux/astro",
|
3
|
-
"version": "1.2.0-alpha.
|
3
|
+
"version": "1.2.0-alpha.9",
|
4
4
|
"description": "PingUX themeable React component library",
|
5
5
|
"author": "uxdev@pingidentity.com",
|
6
6
|
"license": "Apache-2.0",
|
@@ -132,7 +132,7 @@
|
|
132
132
|
"lodash": "^4.17.21",
|
133
133
|
"mdi-react": "^7.4.0",
|
134
134
|
"moment": "^2.29.1",
|
135
|
-
"prism-react-renderer": "
|
135
|
+
"prism-react-renderer": "1.2.1",
|
136
136
|
"prop-types": "^15.7.2",
|
137
137
|
"react-calendar": "^3.4.0",
|
138
138
|
"react-color": "^2.19.3",
|