lecom-ui 5.2.21 → 5.2.23
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.
|
@@ -41,6 +41,59 @@ function DataTable({
|
|
|
41
41
|
}
|
|
42
42
|
return /* @__PURE__ */ React.createElement(Pagination, { ...pagination });
|
|
43
43
|
};
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (!isLoading) {
|
|
46
|
+
const listRows = document.querySelectorAll(`table#data-table tr`);
|
|
47
|
+
listRows.forEach((listRow, listRowIndex) => {
|
|
48
|
+
const rowsElem = listRow.querySelectorAll("[data-fixed]");
|
|
49
|
+
rowsElem.forEach((rowElem, rowElemIndex) => {
|
|
50
|
+
const beforeElem = rowsElem[rowElemIndex - 1];
|
|
51
|
+
const currentElem = rowElem;
|
|
52
|
+
const beforeElemWidth = beforeElem?.getBoundingClientRect()?.width ?? 0;
|
|
53
|
+
const beforeElemLeft = beforeElem?.style?.left ? Number(beforeElem.style.left.replace(/px/g, "")) : 0;
|
|
54
|
+
const lastColumnFixed = rowsElem.length - 1 === rowElemIndex;
|
|
55
|
+
const lastRow = listRows.length - 1 === listRowIndex;
|
|
56
|
+
const currentElemIsTh = currentElem.tagName === "TH";
|
|
57
|
+
const boxShadowWidth = currentElemIsTh ? "-1.5px" : "-0.5px";
|
|
58
|
+
const boxShadow = `#c9c9c9 0px ${lastRow ? "0px" : boxShadowWidth} 0px inset`;
|
|
59
|
+
currentElem.style.position = "sticky";
|
|
60
|
+
currentElem.style.left = `${beforeElemWidth + beforeElemLeft}px`;
|
|
61
|
+
currentElem.style.boxShadow = boxShadow;
|
|
62
|
+
if (lastColumnFixed) {
|
|
63
|
+
currentElem.setAttribute("data-separator-fixed", "true");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, [isLoading]);
|
|
69
|
+
const onScroll = (e) => {
|
|
70
|
+
const target = e.target;
|
|
71
|
+
const elemSeparator = document.querySelectorAll("[data-separator-fixed]");
|
|
72
|
+
const countSeparator = elemSeparator.length - 1;
|
|
73
|
+
if (target.scrollLeft > 0) {
|
|
74
|
+
elemSeparator.forEach((elem, i) => {
|
|
75
|
+
const separator = elem;
|
|
76
|
+
if (countSeparator === i) {
|
|
77
|
+
separator.style.boxShadow = "#c9c9c9 -0.5px 0px 0px inset";
|
|
78
|
+
} else {
|
|
79
|
+
separator.style.boxShadow = `#c9c9c9 -0.5px ${i === 0 ? "-1.5px" : "-0.5px"} 0px inset`;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
elemSeparator.forEach((elem, i) => {
|
|
84
|
+
const separator = elem;
|
|
85
|
+
if (i === 0) {
|
|
86
|
+
separator.style.boxShadow = "#c9c9c9 0px -1.5px 0px inset";
|
|
87
|
+
} else {
|
|
88
|
+
separator.style.boxShadow = `#c9c9c9 0px ${countSeparator === i ? "0px" : "-0.5px"} 0px inset`;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
document.querySelector("[data-radix-scroll-area-viewport]")?.addEventListener("scroll", onScroll);
|
|
95
|
+
return () => document.querySelector("[data-radix-scroll-area-viewport]")?.removeEventListener("scroll", onScroll);
|
|
96
|
+
}, []);
|
|
44
97
|
const renderTable = () => /* @__PURE__ */ React.createElement(
|
|
45
98
|
Table,
|
|
46
99
|
{
|