react-confirm-alert 2.6.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 +3 -1
- package/index.d.ts +2 -0
- package/lib/index.js +23 -11
- package/package.json +1 -1
package/Readme.md
CHANGED
|
@@ -34,10 +34,12 @@ 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: () => {},
|
|
40
|
-
onKeypressEscape: () => {}
|
|
41
|
+
onKeypressEscape: () => {},
|
|
42
|
+
overlayClassName: "overlay-custom-class-name"
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
confirmAlert(options);
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare module 'react-confirm-alert' {
|
|
|
5
5
|
buttons?: Array<{
|
|
6
6
|
label: string
|
|
7
7
|
onClick: () => void
|
|
8
|
+
className?: string
|
|
8
9
|
}>
|
|
9
10
|
childrenElement?: () => React.ReactNode
|
|
10
11
|
customUI?: (customUiOptions: {
|
|
@@ -17,6 +18,7 @@ declare module 'react-confirm-alert' {
|
|
|
17
18
|
willUnmount?: () => void
|
|
18
19
|
onClickOutside?: () => void
|
|
19
20
|
onKeypressEscape?: () => void
|
|
21
|
+
overlayClassName?: string
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export function confirmAlert(options: ReactConfirmAlertProps): void
|
package/lib/index.js
CHANGED
|
@@ -61,14 +61,20 @@ var ReactConfirmAlert = (_temp2 = _class = function (_Component) {
|
|
|
61
61
|
var afterClose = _this.props.afterClose;
|
|
62
62
|
|
|
63
63
|
removeBodyClass();
|
|
64
|
-
removeElementReconfirm(
|
|
65
|
-
removeSVGBlurReconfirm();
|
|
64
|
+
removeElementReconfirm();
|
|
65
|
+
removeSVGBlurReconfirm(afterClose);
|
|
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
|
|
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);
|
|
@@ -107,13 +113,14 @@ var ReactConfirmAlert = (_temp2 = _class = function (_Component) {
|
|
|
107
113
|
message = _props.message,
|
|
108
114
|
buttons = _props.buttons,
|
|
109
115
|
childrenElement = _props.childrenElement,
|
|
110
|
-
customUI = _props.customUI
|
|
116
|
+
customUI = _props.customUI,
|
|
117
|
+
overlayClassName = _props.overlayClassName;
|
|
111
118
|
|
|
112
119
|
|
|
113
120
|
return _react2.default.createElement(
|
|
114
121
|
'div',
|
|
115
122
|
{
|
|
116
|
-
className: 'react-confirm-alert-overlay',
|
|
123
|
+
className: 'react-confirm-alert-overlay ' + overlayClassName,
|
|
117
124
|
ref: function ref(dom) {
|
|
118
125
|
return _this2.overlay = dom;
|
|
119
126
|
},
|
|
@@ -160,10 +167,12 @@ var ReactConfirmAlert = (_temp2 = _class = function (_Component) {
|
|
|
160
167
|
customUI: _propTypes2.default.func,
|
|
161
168
|
closeOnClickOutside: _propTypes2.default.bool,
|
|
162
169
|
closeOnEscape: _propTypes2.default.bool,
|
|
170
|
+
keyCodeForClose: _propTypes2.default.arrayOf(_propTypes2.default.number),
|
|
163
171
|
willUnmount: _propTypes2.default.func,
|
|
164
172
|
afterClose: _propTypes2.default.func,
|
|
165
173
|
onClickOutside: _propTypes2.default.func,
|
|
166
|
-
onKeypressEscape: _propTypes2.default.func
|
|
174
|
+
onKeypressEscape: _propTypes2.default.func,
|
|
175
|
+
overlayClassName: _propTypes2.default.string
|
|
167
176
|
}, _class.defaultProps = {
|
|
168
177
|
buttons: [{
|
|
169
178
|
label: 'Cancel',
|
|
@@ -183,6 +192,7 @@ var ReactConfirmAlert = (_temp2 = _class = function (_Component) {
|
|
|
183
192
|
},
|
|
184
193
|
closeOnClickOutside: true,
|
|
185
194
|
closeOnEscape: true,
|
|
195
|
+
keyCodeForClose: [],
|
|
186
196
|
willUnmount: function willUnmount() {
|
|
187
197
|
return null;
|
|
188
198
|
},
|
|
@@ -219,10 +229,13 @@ function createSVGBlurReconfirm() {
|
|
|
219
229
|
document.body.appendChild(svgElem);
|
|
220
230
|
}
|
|
221
231
|
|
|
222
|
-
function removeSVGBlurReconfirm() {
|
|
232
|
+
function removeSVGBlurReconfirm(afterClose) {
|
|
223
233
|
var svg = document.getElementById('react-confirm-alert-firm-svg');
|
|
224
|
-
|
|
234
|
+
if (svg) {
|
|
235
|
+
svg.parentNode.removeChild(svg);
|
|
236
|
+
}
|
|
225
237
|
document.body.children[0].classList.remove('react-confirm-alert-blur');
|
|
238
|
+
afterClose();
|
|
226
239
|
}
|
|
227
240
|
|
|
228
241
|
function createElementReconfirm(properties) {
|
|
@@ -240,12 +253,11 @@ function createElementReconfirm(properties) {
|
|
|
240
253
|
}
|
|
241
254
|
}
|
|
242
255
|
|
|
243
|
-
function removeElementReconfirm(
|
|
256
|
+
function removeElementReconfirm() {
|
|
244
257
|
var target = document.getElementById('react-confirm-alert');
|
|
245
258
|
if (target) {
|
|
246
259
|
(0, _reactDom.unmountComponentAtNode)(target);
|
|
247
260
|
target.parentNode.removeChild(target);
|
|
248
|
-
afterClose();
|
|
249
261
|
}
|
|
250
262
|
}
|
|
251
263
|
|