ar-design 0.1.47 → 0.1.48
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.
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.ar-dnd {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 1rem 0;
|
|
5
|
+
}
|
|
6
|
+
.ar-dnd > div {
|
|
7
|
+
position: relative;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
align-items: center;
|
|
11
|
+
gap: 0 0.5rem;
|
|
12
|
+
width: 100%;
|
|
13
|
+
border-radius: var(--border-radius-lg);
|
|
14
|
+
cursor: move;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
}
|
|
17
|
+
.ar-dnd > div.drag-item {
|
|
18
|
+
opacity: 0.5;
|
|
19
|
+
}
|
|
20
|
+
.ar-dnd > div.over-item {
|
|
21
|
+
box-shadow: 0 0 0 1.5px rgba(var(--success-rgb), 0.25), 0 0 0 5px rgba(var(--success-rgb), 0.15);
|
|
22
|
+
transition: box-shadow 250ms ease-in-out;
|
|
23
|
+
}
|
|
24
|
+
.ar-dnd > div.end-item {
|
|
25
|
+
/* Sırasıyla; Ad, Süre, Hız, Gecikme Süresi, Tekrar Sayısı, Yön, Bitiş Süreci */
|
|
26
|
+
animation: endItem ease-in-out 1000ms 0s 1 normal both;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ar-dnd > div > .move {
|
|
30
|
+
flex: 1rem;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 1.5rem;
|
|
33
|
+
border-right: transparent;
|
|
34
|
+
}
|
|
35
|
+
.ar-dnd > div > .move {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: 0.25rem 0;
|
|
41
|
+
cursor: move;
|
|
42
|
+
}
|
|
43
|
+
.ar-dnd > div > .move > span {
|
|
44
|
+
display: block;
|
|
45
|
+
background-color: var(--gray-500);
|
|
46
|
+
width: 90%;
|
|
47
|
+
height: 2px;
|
|
48
|
+
border-radius: var(--border-radius-pill);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.ar-dnd > div > .content {
|
|
52
|
+
flex: 100%;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@import url("./animations.css");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { useEffect, useRef } from "react";
|
|
3
|
+
import "../../../assets/css/components/data-display/dnd/dnd.css";
|
|
3
4
|
const DnD = function ({ data, renderItem, onChange }) {
|
|
4
5
|
// refs
|
|
5
6
|
const _arDnD = useRef(null);
|
|
@@ -9,17 +10,40 @@ const DnD = function ({ data, renderItem, onChange }) {
|
|
|
9
10
|
return;
|
|
10
11
|
_arDnD.current.childNodes.forEach((item) => {
|
|
11
12
|
const targetItem = item;
|
|
12
|
-
|
|
13
|
-
targetItem.style.cursor = "move";
|
|
13
|
+
// Events
|
|
14
14
|
targetItem.ondragstart = (event) => {
|
|
15
15
|
const dragItem = event.currentTarget;
|
|
16
|
-
// Drag olan öğeyi yakalanıyor.
|
|
17
16
|
_dragItem.current = dragItem;
|
|
18
|
-
dragItem.
|
|
17
|
+
dragItem.classList.add("drag-item");
|
|
18
|
+
// Korumaya başla
|
|
19
|
+
if (_arDnD.current) {
|
|
20
|
+
_arDnD.current.childNodes.forEach((item) => {
|
|
21
|
+
const firewall = document.createElement("div");
|
|
22
|
+
firewall.setAttribute("data-id", "ar-firewall");
|
|
23
|
+
firewall.style.position = "absolute";
|
|
24
|
+
firewall.style.inset = "0";
|
|
25
|
+
item.appendChild(firewall);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
targetItem.ondragover = (event) => {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
const overItem = event.currentTarget;
|
|
32
|
+
if (!overItem.classList.contains("over-item")) {
|
|
33
|
+
overItem.classList.add("over-item");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
targetItem.ondragleave = (event) => {
|
|
37
|
+
const leaveItem = event.currentTarget;
|
|
38
|
+
leaveItem.classList.remove("over-item");
|
|
19
39
|
};
|
|
20
40
|
targetItem.ondrop = (event) => {
|
|
21
41
|
event.preventDefault();
|
|
22
42
|
const dropItem = event.currentTarget;
|
|
43
|
+
// Cleaner...
|
|
44
|
+
dropItem.classList.remove("over-item");
|
|
45
|
+
const nodes = document.querySelectorAll("[data-id='ar-firewall']");
|
|
46
|
+
nodes.forEach((node) => node.remove());
|
|
23
47
|
if (_dragItem.current !== dropItem) {
|
|
24
48
|
if (_arDnD.current && _dragItem.current) {
|
|
25
49
|
const dragItemIndex = [..._arDnD.current.children].indexOf(_dragItem.current);
|
|
@@ -40,11 +64,18 @@ const DnD = function ({ data, renderItem, onChange }) {
|
|
|
40
64
|
};
|
|
41
65
|
targetItem.ondragend = (event) => {
|
|
42
66
|
const item = event.currentTarget;
|
|
43
|
-
item.
|
|
67
|
+
item.classList.remove("drag-item");
|
|
68
|
+
item.classList.add("end-item");
|
|
69
|
+
setTimeout(() => item.classList.remove("end-item"), 1000);
|
|
44
70
|
};
|
|
45
71
|
});
|
|
46
72
|
_arDnD.current.ondragover = (event) => event.preventDefault();
|
|
47
73
|
}, [data]);
|
|
48
|
-
return (React.createElement("div", { ref: _arDnD, className: "ar-dnd" }, data.map((item, index) =>
|
|
74
|
+
return (React.createElement("div", { ref: _arDnD, className: "ar-dnd" }, data.map((item, index) => (React.createElement("div", { draggable: true },
|
|
75
|
+
React.createElement("div", { className: "move" },
|
|
76
|
+
React.createElement("span", null),
|
|
77
|
+
React.createElement("span", null),
|
|
78
|
+
React.createElement("span", null)),
|
|
79
|
+
React.createElement("div", { className: "content" }, renderItem(item, index)))))));
|
|
49
80
|
};
|
|
50
81
|
export default DnD;
|