react-confirm-alert 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Readme.md CHANGED
@@ -34,6 +34,7 @@ const options = {
34
34
  customUI: ({ onClose }) => <div>Custom UI</div>,
35
35
  closeOnEscape: true,
36
36
  closeOnClickOutside: true,
37
+ keyCodeForClose: [8, 32],
37
38
  willUnmount: () => {},
38
39
  afterClose: () => {}
39
40
  onClickOutside: () => {},
package/lib/index.js CHANGED
@@ -66,9 +66,15 @@ var ReactConfirmAlert = (_temp2 = _class = function (_Component) {
66
66
  }, _this.keyboardClose = function (event) {
67
67
  var _this$props2 = _this.props,
68
68
  closeOnEscape = _this$props2.closeOnEscape,
69
- onKeypressEscape = _this$props2.onKeypressEscape;
69
+ onKeypressEscape = _this$props2.onKeypressEscape,
70
+ keyCodeForClose = _this$props2.keyCodeForClose;
70
71
 
71
- var isKeyCodeEscape = event.keyCode === 27;
72
+ var keyCode = event.keyCode;
73
+ var isKeyCodeEscape = keyCode === 27;
74
+
75
+ if (keyCodeForClose.includes(keyCode)) {
76
+ _this.close();
77
+ }
72
78
 
73
79
  if (closeOnEscape && isKeyCodeEscape) {
74
80
  onKeypressEscape(event);
@@ -161,6 +167,7 @@ var ReactConfirmAlert = (_temp2 = _class = function (_Component) {
161
167
  customUI: _propTypes2.default.func,
162
168
  closeOnClickOutside: _propTypes2.default.bool,
163
169
  closeOnEscape: _propTypes2.default.bool,
170
+ keyCodeForClose: _propTypes2.default.arrayOf(_propTypes2.default.number),
164
171
  willUnmount: _propTypes2.default.func,
165
172
  afterClose: _propTypes2.default.func,
166
173
  onClickOutside: _propTypes2.default.func,
@@ -185,6 +192,7 @@ var ReactConfirmAlert = (_temp2 = _class = function (_Component) {
185
192
  },
186
193
  closeOnClickOutside: true,
187
194
  closeOnEscape: true,
195
+ keyCodeForClose: [],
188
196
  willUnmount: function willUnmount() {
189
197
  return null;
190
198
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-confirm-alert",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "react component confirm dialog.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {