@rpg-engine/long-bow 0.8.58 → 0.8.59

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.8.58",
3
+ "version": "0.8.59",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -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,42 @@ export const ConfirmModal: React.FC<IConfirmModalProps> = ({
23
23
  onClose,
24
24
  message = 'Are you sure?',
25
25
  }) => {
26
- // Add a small delay to prevent accidental closes
27
- const handleConfirm = (e: React.MouseEvent | React.TouchEvent) => {
28
- e.preventDefault();
29
- e.stopPropagation();
30
- onConfirm();
31
- };
32
-
33
- const handleClose = (e: React.MouseEvent | React.TouchEvent) => {
34
- e.preventDefault();
35
- e.stopPropagation();
36
- onClose();
37
- };
38
-
39
- const stopPropagation = (e: React.MouseEvent | React.TouchEvent) => {
40
- e.stopPropagation();
41
- };
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
+ const stopPropagation = useCallback(
45
+ (e: React.PointerEvent | React.TouchEvent) => {
46
+ e.stopPropagation();
47
+ },
48
+ []
49
+ );
42
50
 
43
51
  return (
44
52
  <ModalPortal>
45
53
  <GlobalStyle />
46
- <Overlay onClick={handleClose} />
54
+ <Overlay onPointerDown={handleClose} />
47
55
  <ModalContainer>
48
56
  <ModalContent
49
57
  onClick={stopPropagation}
50
58
  onTouchStart={stopPropagation}
51
59
  onTouchEnd={stopPropagation}
52
60
  onTouchMove={stopPropagation}
61
+ onPointerDown={stopPropagation}
53
62
  >
54
63
  <MessageContainer>
55
64
  {typeof message === 'string' ? (
@@ -63,14 +72,14 @@ export const ConfirmModal: React.FC<IConfirmModalProps> = ({
63
72
  <CancelButtonWrapper>
64
73
  <Button
65
74
  buttonType={ButtonTypes.RPGUIButton}
66
- onClick={handleClose}
75
+ onPointerDown={handleClose}
67
76
  >
68
77
  No
69
78
  </Button>
70
79
  </CancelButtonWrapper>
71
80
  <Button
72
81
  buttonType={ButtonTypes.RPGUIButton}
73
- onClick={handleConfirm}
82
+ onPointerDown={handleConfirm}
74
83
  >
75
84
  Yes
76
85
  </Button>