@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/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.60",
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,48 @@ 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();
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
- onConfirm();
31
- };
47
+ }, []);
32
48
 
33
- const handleClose = (e: React.MouseEvent | React.TouchEvent) => {
34
- e.preventDefault();
49
+ const stopPropagationTouch = useCallback((e: React.TouchEvent) => {
35
50
  e.stopPropagation();
36
- onClose();
37
- };
51
+ }, []);
38
52
 
39
- const stopPropagation = (e: React.MouseEvent | React.TouchEvent) => {
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 onClick={handleClose} />
60
+ <Overlay onPointerDown={handleClose} />
47
61
  <ModalContainer>
48
62
  <ModalContent
49
- onClick={stopPropagation}
50
- onTouchStart={stopPropagation}
51
- onTouchEnd={stopPropagation}
52
- onTouchMove={stopPropagation}
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
- onClick={handleClose}
81
+ onPointerDown={handleClose}
67
82
  >
68
83
  No
69
84
  </Button>
70
85
  </CancelButtonWrapper>
71
86
  <Button
72
87
  buttonType={ButtonTypes.RPGUIButton}
73
- onClick={handleConfirm}
88
+ onPointerDown={handleConfirm}
74
89
  >
75
90
  Yes
76
91
  </Button>