react-simple-game-engine 0.2.65 → 0.2.67
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.
@@ -1,11 +1,11 @@
|
|
1
|
-
import { ReactElement,
|
1
|
+
import { ReactElement, CSSProperties } from "react";
|
2
2
|
declare type ModalProps = {
|
3
3
|
children?: ReactElement;
|
4
|
-
content:
|
4
|
+
content: ReactElement;
|
5
|
+
backgroundStyle?: CSSProperties;
|
5
6
|
defaultOpen?: boolean;
|
6
7
|
event?: string;
|
7
8
|
onClose?: () => void;
|
8
|
-
backgroundStyle?: CSSProperties;
|
9
9
|
};
|
10
10
|
export declare type RefModalFunctions = {
|
11
11
|
open: () => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/ui-components/modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/ui-components/modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,EAKZ,aAAa,EAEd,MAAM,OAAO,CAAC;AAGf,aAAK,UAAU,GAAG;IAChB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,YAAY,CAAC;IACtB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,KAAK,0GA8FhB,CAAC"}
|
@@ -9,8 +9,8 @@ var __assign = (this && this.__assign) || function () {
|
|
9
9
|
};
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
|
-
import { jsx as _jsx,
|
13
|
-
import { useMemo, useEffect, useState, useCallback, forwardRef, cloneElement, useImperativeHandle, useRef, } from "react";
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
+
import { useMemo, useEffect, useState, useCallback, forwardRef, cloneElement, useImperativeHandle, useRef, memo, } from "react";
|
14
14
|
import * as ReactDOM from "react-dom";
|
15
15
|
export var Modal = forwardRef(function (_a, ref) {
|
16
16
|
var _b;
|
@@ -22,8 +22,6 @@ export var Modal = forwardRef(function (_a, ref) {
|
|
22
22
|
c.style.position = "fixed";
|
23
23
|
c.style.top = "0";
|
24
24
|
c.style.left = "0";
|
25
|
-
c.style.bottom = "0";
|
26
|
-
c.style.right = "0";
|
27
25
|
return c;
|
28
26
|
}, []);
|
29
27
|
useEffect(function () {
|
@@ -68,19 +66,34 @@ export var Modal = forwardRef(function (_a, ref) {
|
|
68
66
|
? cloneElement(trigger, (_b = {},
|
69
67
|
_b[event] = handleOpen,
|
70
68
|
_b), trigger.props.children)
|
71
|
-
: null, isOpen
|
72
|
-
? ReactDOM.createPortal(_jsxs("div", __assign({ style: {
|
73
|
-
width: "100%",
|
74
|
-
height: "100%",
|
75
|
-
position: "relative",
|
76
|
-
display: "flex",
|
77
|
-
alignItems: "center",
|
78
|
-
justifyContent: "center",
|
79
|
-
}, ref: refModal }, { children: [_jsx("div", { style: __assign({ width: "100%", height: "100%", position: "absolute", zIndex: 0 }, backgroundStyle), onClick: handleClose }), _jsx("main", __assign({ style: {
|
80
|
-
position: "relative",
|
81
|
-
zIndex: 1,
|
82
|
-
minWidth: "200px",
|
83
|
-
minHeight: "200px",
|
84
|
-
} }, { children: content }))] })), container)
|
85
|
-
: null] }));
|
69
|
+
: null, ReactDOM.createPortal(isOpen ? (_jsx(ModalWrap, { content: content, backgroundStyle: backgroundStyle, handleClose: handleClose })) : null, container)] }));
|
86
70
|
});
|
71
|
+
var ModalWrap = forwardRef(memo(function (_a, ref) {
|
72
|
+
var content = _a.content, backgroundStyle = _a.backgroundStyle, handleClose = _a.handleClose;
|
73
|
+
var el = useMemo(function () {
|
74
|
+
return cloneElement(content, {
|
75
|
+
close: handleClose,
|
76
|
+
}, content.props.children);
|
77
|
+
}, [content]);
|
78
|
+
return (_jsx("div", __assign({ style: {
|
79
|
+
width: "100%",
|
80
|
+
height: "100%",
|
81
|
+
position: "fixed",
|
82
|
+
top: 0,
|
83
|
+
left: 0,
|
84
|
+
right: 0,
|
85
|
+
bottom: 0,
|
86
|
+
} }, { children: _jsxs("div", __assign({ style: {
|
87
|
+
width: "100%",
|
88
|
+
height: "100%",
|
89
|
+
position: "relative",
|
90
|
+
display: "flex",
|
91
|
+
alignItems: "center",
|
92
|
+
justifyContent: "center",
|
93
|
+
}, ref: ref }, { children: [_jsx("div", { style: __assign({ width: "100%", height: "100%", position: "absolute", zIndex: 0 }, backgroundStyle), onClick: handleClose }), _jsx("main", __assign({ style: {
|
94
|
+
position: "relative",
|
95
|
+
zIndex: 1,
|
96
|
+
minWidth: "200px",
|
97
|
+
minHeight: "200px",
|
98
|
+
} }, { children: el }))] })) })));
|
99
|
+
}));
|