ehscan-react-table 0.0.21 → 0.0.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.
- package/dist/elements/Table.js +17 -20
- package/package.json +1 -1
package/dist/elements/Table.js
CHANGED
|
@@ -32,17 +32,13 @@ export const Table = ({ columns, rows, sortOrder, setSortOrder, cellComponents,
|
|
|
32
32
|
const calculateHeight = () => {
|
|
33
33
|
if (headerRef.current) {
|
|
34
34
|
const { bottom } = headerRef.current.getBoundingClientRect();
|
|
35
|
-
|
|
36
|
-
setWrapperBottom(bottom);
|
|
35
|
+
setWrapperBottom(bottom - 20);
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
calculateHeight();
|
|
40
39
|
window.addEventListener("resize", calculateHeight);
|
|
41
40
|
return () => window.removeEventListener("resize", calculateHeight);
|
|
42
41
|
}, []);
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
console.log(wrapperBottom);
|
|
45
|
-
}, [wrapperBottom]);
|
|
46
42
|
const checkHead = (entry) => {
|
|
47
43
|
if (entry === undefined)
|
|
48
44
|
return;
|
|
@@ -110,22 +106,23 @@ export const Table = ({ columns, rows, sortOrder, setSortOrder, cellComponents,
|
|
|
110
106
|
: _jsx("div", { onClick: () => setOpenCol(tag), children: colTitle }) })] }) }));
|
|
111
107
|
};
|
|
112
108
|
useEffect(() => {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const width = entry.contentRect.width;
|
|
123
|
-
console.log(`Column "${tag}" resized to`, width);
|
|
124
|
-
}
|
|
109
|
+
const timeout = setTimeout(() => {
|
|
110
|
+
const observer = new ResizeObserver((entries) => {
|
|
111
|
+
entries.forEach((entry) => {
|
|
112
|
+
const tag = Object.keys(colRefs.current).find(k => colRefs.current[k] === entry.target);
|
|
113
|
+
if (tag) {
|
|
114
|
+
const width = entry.contentRect.width;
|
|
115
|
+
console.log(`Column "${tag}" resized to:`, width);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
125
118
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
Object.values(colRefs.current).forEach((el) => {
|
|
120
|
+
if (el)
|
|
121
|
+
observer.observe(el);
|
|
122
|
+
});
|
|
123
|
+
return () => observer.disconnect();
|
|
124
|
+
}, 50); // 50ms is usually enough
|
|
125
|
+
return () => clearTimeout(timeout);
|
|
129
126
|
}, []);
|
|
130
127
|
const HeadCols = () => {
|
|
131
128
|
return (_jsxs(_Fragment, { children: [columns.map((col, i) => {
|