ar-design 0.2.18 → 0.2.20
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.
|
@@ -5,10 +5,6 @@ import "../../../assets/css/components/feedback/notification/notification.css";
|
|
|
5
5
|
const Notification = ({ title, message, status, direction = "bottom-left", trigger }) => {
|
|
6
6
|
const _firstLoad = useRef(false);
|
|
7
7
|
const _notificationItems = useRef([]);
|
|
8
|
-
const _interval = useRef();
|
|
9
|
-
// const _automaticRemoveInterval = useRef<NodeJS.Timeout>();
|
|
10
|
-
// const _closedInterval = useRef<NodeJS.Timeout>();
|
|
11
|
-
const _i = useRef(0);
|
|
12
8
|
const [items, setItems] = useState([]);
|
|
13
9
|
useEffect(() => {
|
|
14
10
|
if (!_firstLoad.current) {
|
|
@@ -32,29 +28,28 @@ const Notification = ({ title, message, status, direction = "bottom-left", trigg
|
|
|
32
28
|
status = "error";
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
|
-
setItems((
|
|
31
|
+
setItems((prev) => [...prev, { id: Math.random(), title, message, status, direction }]);
|
|
36
32
|
}, [trigger]);
|
|
37
33
|
useEffect(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// }, 3000);
|
|
50
|
-
_interval.current = setTimeout(() => {
|
|
51
|
-
setItems((prevItems) => prevItems.slice(1));
|
|
52
|
-
// if (firstNotification) firstNotification.classList.remove("closed");
|
|
53
|
-
clearTimeout(_interval.current);
|
|
54
|
-
}, 3000);
|
|
34
|
+
let clearTimeoutId = undefined;
|
|
35
|
+
items.forEach((item) => {
|
|
36
|
+
if (!item.timeoutId) {
|
|
37
|
+
const timeoutId = setTimeout(() => {
|
|
38
|
+
clearTimeoutId = item.timeoutId;
|
|
39
|
+
setItems((prev) => prev.filter((_item) => _item.id !== item.id));
|
|
40
|
+
}, 3000);
|
|
41
|
+
// Öncesinde timeoutId değerinin tanımlanması yapılıyor.
|
|
42
|
+
setItems((prev) => prev.map((prevItem) => (prevItem.id === item.id ? { ...prevItem, timeoutId } : prevItem)));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
55
45
|
return () => {
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
if (items.length === 0)
|
|
47
|
+
return;
|
|
48
|
+
const item = items.find((x) => x.timeoutId == clearTimeoutId);
|
|
49
|
+
if (item) {
|
|
50
|
+
clearTimeout(item.timeoutId);
|
|
51
|
+
clearTimeoutId = undefined;
|
|
52
|
+
}
|
|
58
53
|
};
|
|
59
54
|
}, [items]);
|
|
60
55
|
const getBottomPosition = (index) => {
|
|
@@ -63,14 +58,14 @@ const Notification = ({ title, message, status, direction = "bottom-left", trigg
|
|
|
63
58
|
if (_notificationItems.current[index - 1]) {
|
|
64
59
|
bottom = _notificationItems.current.slice(0, index).reduce((acc, el) => {
|
|
65
60
|
const rect = el.getBoundingClientRect();
|
|
66
|
-
return acc + rect.height + 20; // +20 değeri ara boşluğu
|
|
61
|
+
return acc + rect.height + 20; // +20 değeri ara boşluğu arttırıyor.
|
|
67
62
|
}, 30); // 30px'lik boşluğu başlangıçta ekliyoruz.
|
|
68
63
|
}
|
|
69
64
|
return bottom;
|
|
70
65
|
};
|
|
71
66
|
return items.map((item, index) => {
|
|
72
67
|
const bottom = getBottomPosition(index);
|
|
73
|
-
return (React.createElement("div", { key:
|
|
68
|
+
return (React.createElement("div", { key: item.id, ref: (element) => (_notificationItems.current[index] = element), className: "ar-notification-item", style: items.length > 5
|
|
74
69
|
? {
|
|
75
70
|
backgroundColor: `rgba(var(--white-rgb), ${index === items.length - 1 ? 1 : 0.1})`,
|
|
76
71
|
backdropFilter: "blur(10px)",
|
|
@@ -87,15 +82,9 @@ const Notification = ({ title, message, status, direction = "bottom-left", trigg
|
|
|
87
82
|
React.createElement("span", { className: "title" }, item.title),
|
|
88
83
|
React.createElement("span", { className: "message" }, item.message)),
|
|
89
84
|
React.createElement("div", { className: "close", onClick: () => {
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
if (item.timeoutId)
|
|
86
|
+
clearTimeout(item.timeoutId);
|
|
92
87
|
setItems((prev) => prev.filter((_item) => _item.id !== item.id));
|
|
93
|
-
// if (_notificationItems.current[index]) _notificationItems.current[index]!.classList.add("closed");
|
|
94
|
-
// _closedInterval.current = setTimeout(() => {
|
|
95
|
-
// setItems((prev) => prev.filter((_item) => _item.id !== item.id));
|
|
96
|
-
// if (_notificationItems.current[index]) _notificationItems.current[index]!.classList.remove("closed");
|
|
97
|
-
// clearTimeout(_closedInterval.current);
|
|
98
|
-
// }, 500);
|
|
99
88
|
} })));
|
|
100
89
|
});
|
|
101
90
|
};
|
|
@@ -6,7 +6,7 @@ import Chip from "../../data-display/chip";
|
|
|
6
6
|
import Checkbox from "../checkbox";
|
|
7
7
|
import Utils from "../../../libs/infrastructure/shared/Utils";
|
|
8
8
|
import ReactDOM from "react-dom";
|
|
9
|
-
const Select = ({ variant = "outlined", status, border = { radius: "sm" }, options, value, onChange, onClick, onCreate, multiple, placeholder, validation, upperCase, disabled, }) => {
|
|
9
|
+
const Select = ({ variant = "outlined", status, border = { radius: "sm" }, options, value, onChange, onSearch, onClick, onCreate, multiple, placeholder, validation, upperCase, disabled, }) => {
|
|
10
10
|
const _selectionClassName = ["selections"];
|
|
11
11
|
// refs
|
|
12
12
|
const _arSelect = useRef(null);
|
|
@@ -219,6 +219,8 @@ const Select = ({ variant = "outlined", status, border = { radius: "sm" }, optio
|
|
|
219
219
|
optionItems[_navigationIndex.current]?.classList.add("navigate-with-arrow-keys");
|
|
220
220
|
// Yeniden konumlandır.
|
|
221
221
|
setTimeout(() => handlePosition(), 0);
|
|
222
|
+
// Aramayı bileşen dışında kullanmak için dışarı aktarım metodu.
|
|
223
|
+
onSearch && onSearch(searchText);
|
|
222
224
|
}, [searchText]);
|
|
223
225
|
useEffect(() => {
|
|
224
226
|
// Seçilen öğeye 'navigate-with-arrow-keys' sınıfını ekle
|
|
@@ -54,45 +54,48 @@ const TextEditor = ({ name, value, onChange, placeholder, height, validation })
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
// useEffects
|
|
57
|
-
// Iframe Document yüklendikten sonra çalışacaktır. (Bir defa çalışır.)
|
|
58
57
|
useEffect(() => {
|
|
58
|
+
// Iframe Document yüklendikten sonra çalışacaktır.
|
|
59
59
|
if (!iframeDocument)
|
|
60
60
|
return;
|
|
61
61
|
const selection = iframeDocument.getSelection();
|
|
62
62
|
let range = null;
|
|
63
63
|
// Eğer bir seçim (caret) varsa, konumunu kaydet
|
|
64
|
-
if (selection && selection.rangeCount > 0)
|
|
64
|
+
if (selection && selection.rangeCount > 0)
|
|
65
65
|
range = selection.getRangeAt(0);
|
|
66
|
-
}
|
|
67
66
|
// Eğer içeriği kendimiz değiştirmedikse ve gelen value farklıysa, içeriği güncelle
|
|
68
|
-
if (iframeDocument.body.innerHTML !== value)
|
|
67
|
+
if (iframeDocument.body.innerHTML !== value)
|
|
69
68
|
iframeDocument.body.innerHTML = value || `<p>${placeholder ?? ""}</p>`;
|
|
70
|
-
}
|
|
71
69
|
// Cursor (caret) konumunu geri yükle
|
|
72
70
|
if (range) {
|
|
73
71
|
selection?.removeAllRanges();
|
|
74
72
|
selection?.addRange(range);
|
|
75
73
|
}
|
|
76
74
|
}, [value, iframeDocument]);
|
|
77
|
-
// Iframe yüklendikten sonra çalışacaktır.
|
|
78
75
|
useEffect(() => {
|
|
76
|
+
// Iframe yüklendikten sonra çalışacaktır.
|
|
79
77
|
if (!iframe)
|
|
80
78
|
return;
|
|
81
79
|
const iframeDocument = iframe.contentDocument || iframe.contentWindow?.document;
|
|
82
|
-
if (iframeDocument)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
iframeDocument.body.innerHTML === "<br>" ? onChange(undefined) : onChange(iframeDocument.body.innerHTML);
|
|
89
|
-
});
|
|
80
|
+
if (!iframeDocument)
|
|
81
|
+
return; // 👈 Güvenlik önlemi
|
|
82
|
+
// Herhangi bir değişikliği izlemek için MutationObserver kullan
|
|
83
|
+
const observer = new MutationObserver((mutationsList) => {
|
|
84
|
+
mutationsList.forEach(() => {
|
|
85
|
+
iframeDocument?.body.innerHTML === "<br>" ? onChange(undefined) : onChange(iframeDocument.body.innerHTML);
|
|
90
86
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
87
|
+
});
|
|
88
|
+
setIframeDocument(iframeDocument);
|
|
89
|
+
iframeDocument.designMode = "on";
|
|
90
|
+
// Observer'ı body üzerinde başlat
|
|
91
|
+
observer.observe(iframeDocument.body, { childList: true, subtree: true, characterData: true, attributes: true });
|
|
92
|
+
iframeDocument.body.addEventListener("focus", handleFocus);
|
|
93
|
+
iframeDocument.body.addEventListener("blur", handleBlur);
|
|
94
|
+
return () => {
|
|
95
|
+
observer.disconnect();
|
|
96
|
+
iframeDocument?.body.removeEventListener("focus", handleFocus);
|
|
97
|
+
iframeDocument?.body.removeEventListener("blur", handleBlur);
|
|
98
|
+
};
|
|
96
99
|
}, [iframe]);
|
|
97
100
|
useEffect(() => {
|
|
98
101
|
if (!_arIframe.current)
|