@rpg-engine/long-bow 0.8.58 → 0.8.60
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/dist/long-bow.cjs.development.js +21 -14
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +21 -14
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ConfirmModal.tsx +34 -19
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode, useCallback } from 'react';
|
|
2
2
|
import styled, { createGlobalStyle } from 'styled-components';
|
|
3
3
|
import ModalPortal from './Abstractions/ModalPortal';
|
|
4
4
|
import { Button, ButtonTypes } from './Button';
|
|
@@ -23,33 +23,48 @@ export const ConfirmModal: React.FC<IConfirmModalProps> = ({
|
|
|
23
23
|
onClose,
|
|
24
24
|
message = 'Are you sure?',
|
|
25
25
|
}) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const handleConfirm = useCallback(
|
|
27
|
+
(e: React.PointerEvent) => {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
onConfirm();
|
|
31
|
+
},
|
|
32
|
+
[onConfirm]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const handleClose = useCallback(
|
|
36
|
+
(e: React.PointerEvent) => {
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
e.stopPropagation();
|
|
39
|
+
onClose();
|
|
40
|
+
},
|
|
41
|
+
[onClose]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Fix type issues by separating event handlers for different event types
|
|
45
|
+
const stopPropagationClick = useCallback((e: React.MouseEvent) => {
|
|
29
46
|
e.stopPropagation();
|
|
30
|
-
|
|
31
|
-
};
|
|
47
|
+
}, []);
|
|
32
48
|
|
|
33
|
-
const
|
|
34
|
-
e.preventDefault();
|
|
49
|
+
const stopPropagationTouch = useCallback((e: React.TouchEvent) => {
|
|
35
50
|
e.stopPropagation();
|
|
36
|
-
|
|
37
|
-
};
|
|
51
|
+
}, []);
|
|
38
52
|
|
|
39
|
-
const
|
|
53
|
+
const stopPropagationPointer = useCallback((e: React.PointerEvent) => {
|
|
40
54
|
e.stopPropagation();
|
|
41
|
-
};
|
|
55
|
+
}, []);
|
|
42
56
|
|
|
43
57
|
return (
|
|
44
58
|
<ModalPortal>
|
|
45
59
|
<GlobalStyle />
|
|
46
|
-
<Overlay
|
|
60
|
+
<Overlay onPointerDown={handleClose} />
|
|
47
61
|
<ModalContainer>
|
|
48
62
|
<ModalContent
|
|
49
|
-
onClick={
|
|
50
|
-
onTouchStart={
|
|
51
|
-
onTouchEnd={
|
|
52
|
-
onTouchMove={
|
|
63
|
+
onClick={stopPropagationClick}
|
|
64
|
+
onTouchStart={stopPropagationTouch}
|
|
65
|
+
onTouchEnd={stopPropagationTouch}
|
|
66
|
+
onTouchMove={stopPropagationTouch}
|
|
67
|
+
onPointerDown={stopPropagationPointer}
|
|
53
68
|
>
|
|
54
69
|
<MessageContainer>
|
|
55
70
|
{typeof message === 'string' ? (
|
|
@@ -63,14 +78,14 @@ export const ConfirmModal: React.FC<IConfirmModalProps> = ({
|
|
|
63
78
|
<CancelButtonWrapper>
|
|
64
79
|
<Button
|
|
65
80
|
buttonType={ButtonTypes.RPGUIButton}
|
|
66
|
-
|
|
81
|
+
onPointerDown={handleClose}
|
|
67
82
|
>
|
|
68
83
|
No
|
|
69
84
|
</Button>
|
|
70
85
|
</CancelButtonWrapper>
|
|
71
86
|
<Button
|
|
72
87
|
buttonType={ButtonTypes.RPGUIButton}
|
|
73
|
-
|
|
88
|
+
onPointerDown={handleConfirm}
|
|
74
89
|
>
|
|
75
90
|
Yes
|
|
76
91
|
</Button>
|