lecom-ui 5.2.22 → 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.
@@ -31,12 +31,69 @@ function DataTable({
31
31
  sorting
32
32
  }
33
33
  });
34
+ const styleDataTableContainer = () => ({
35
+ width: vwDiff ? `calc(100vw - ${vwDiff}px)` : "100%",
36
+ height: vhDiff ? `calc(100vh - ${vhDiff}px)` : "100%"
37
+ });
34
38
  const hasPagination = () => {
35
39
  if (!pagination) {
36
40
  return null;
37
41
  }
38
42
  return /* @__PURE__ */ React.createElement(Pagination, { ...pagination });
39
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
+ }, []);
40
97
  const renderTable = () => /* @__PURE__ */ React.createElement(
41
98
  Table,
42
99
  {
@@ -55,12 +112,14 @@ function DataTable({
55
112
  className: cn(
56
113
  "bg-white rounded-[8px] p-2 transition-all duration-500",
57
114
  className
58
- )
115
+ ),
116
+ style: noScroll ? void 0 : { width: styleDataTableContainer().width }
59
117
  },
60
118
  noScroll ? renderTable() : /* @__PURE__ */ React.createElement(ScrollArea, { type: "always", className: "p-2" }, /* @__PURE__ */ React.createElement(
61
119
  "div",
62
120
  {
63
- className: "transition-all duration-500"
121
+ className: "transition-all duration-500",
122
+ style: { maxHeight: styleDataTableContainer().height }
64
123
  },
65
124
  renderTable()
66
125
  ), /* @__PURE__ */ React.createElement(ScrollBar, { orientation: "horizontal" }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "5.2.22",
3
+ "version": "5.2.23",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",