ar-design 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,3 +1,14 @@
|
|
|
1
|
+
.ar-notification-popup-wrapper {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
z-index: 1050;
|
|
5
|
+
}
|
|
6
|
+
.ar-notification-popup-wrapper > .ar-notification-popup-bg {
|
|
7
|
+
position: fixed;
|
|
8
|
+
inset: 0;
|
|
9
|
+
background-color: rgba(var(--black-rgb), 0.5);
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
.ar-notification-popup {
|
|
2
13
|
visibility: hidden;
|
|
3
14
|
opacity: 0;
|
|
@@ -41,7 +52,7 @@
|
|
|
41
52
|
}
|
|
42
53
|
.ar-notification-popup > .icon.success::before {
|
|
43
54
|
content: "";
|
|
44
|
-
width:
|
|
55
|
+
width: 3rem;
|
|
45
56
|
height: 1.75rem;
|
|
46
57
|
transform: rotate(-45deg);
|
|
47
58
|
border: solid 10.5px transparent;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import React, { useContext, useEffect, useState } from "react";
|
|
2
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
3
3
|
import "../../../assets/css/components/feedback/popup/popup.css";
|
|
4
4
|
import Button from "../../form/button";
|
|
5
5
|
import ReactDOM from "react-dom";
|
|
6
6
|
import { NotificationContext } from "../../../libs/core/application/contexts/Notification";
|
|
7
7
|
const Popup = ({ title, message, status, isOpen, buttons }) => {
|
|
8
|
+
// contexts
|
|
8
9
|
const { setIsPopupOpen } = useContext(NotificationContext);
|
|
10
|
+
// refs
|
|
11
|
+
const _arNotificationPopupWrapper = useRef(null);
|
|
12
|
+
const _arNotificationPopup = useRef(null);
|
|
9
13
|
// states
|
|
14
|
+
const _notificaitonPopupWrapperClassName = ["ar-notification-popup-wrapper"];
|
|
10
15
|
const [className, setClassName] = useState(["ar-notification-popup", ""]);
|
|
11
16
|
// useEffects
|
|
12
17
|
useEffect(() => {
|
|
@@ -14,20 +19,36 @@ const Popup = ({ title, message, status, isOpen, buttons }) => {
|
|
|
14
19
|
const updated = [...prev.slice(0, -1), isOpen ? "open" : ""];
|
|
15
20
|
return updated;
|
|
16
21
|
});
|
|
22
|
+
if (isOpen)
|
|
23
|
+
document.body.style.overflow = "hidden";
|
|
24
|
+
return () => {
|
|
25
|
+
document.body.style.removeProperty("overflow");
|
|
26
|
+
};
|
|
17
27
|
}, [isOpen]);
|
|
18
28
|
return (isOpen &&
|
|
19
|
-
ReactDOM.createPortal(React.createElement("div", { className:
|
|
20
|
-
React.createElement("div", { className:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
ReactDOM.createPortal(React.createElement("div", { ref: _arNotificationPopupWrapper, className: _notificaitonPopupWrapperClassName.map((c) => c).join(" ") },
|
|
30
|
+
React.createElement("div", { className: "ar-notification-popup-bg", onMouseDown: (event) => {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
const target = event.target;
|
|
33
|
+
if (_arNotificationPopup.current && !_arNotificationPopup.current.contains(target)) {
|
|
34
|
+
setClassName((prev) => {
|
|
35
|
+
const updated = [...prev.slice(0, -1), isOpen ? "open" : ""];
|
|
36
|
+
return updated;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
} }),
|
|
40
|
+
React.createElement("div", { ref: _arNotificationPopup, className: className.map((c) => c).join(" ") },
|
|
41
|
+
React.createElement("div", { className: `icon ${status}` }),
|
|
42
|
+
React.createElement("div", { className: "content" },
|
|
43
|
+
React.createElement("span", { className: `title ${status}` },
|
|
44
|
+
title,
|
|
45
|
+
"!"),
|
|
46
|
+
React.createElement("span", { className: "message" }, message)),
|
|
47
|
+
React.createElement(Button, { variant: "filled", status: status == "success" ? "success" : "danger", onClick: () => {
|
|
48
|
+
(() => buttons?.okay?.onClick && buttons.okay?.onClick())();
|
|
49
|
+
(() => {
|
|
50
|
+
setIsPopupOpen && setIsPopupOpen((prev) => !prev);
|
|
51
|
+
})();
|
|
52
|
+
} }, buttons?.okay?.text ?? "Tamam"))), document.body));
|
|
32
53
|
};
|
|
33
54
|
export default Popup;
|