ehscan-react-table 0.0.22 → 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 -15
- package/package.json +1 -1
package/dist/elements/Table.js
CHANGED
|
@@ -32,8 +32,7 @@ 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 + 20);
|
|
35
|
+
setWrapperBottom(bottom - 20);
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
calculateHeight();
|
|
@@ -107,20 +106,23 @@ export const Table = ({ columns, rows, sortOrder, setSortOrder, cellComponents,
|
|
|
107
106
|
: _jsx("div", { onClick: () => setOpenCol(tag), children: colTitle }) })] }) }));
|
|
108
107
|
};
|
|
109
108
|
useEffect(() => {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
});
|
|
117
118
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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);
|
|
124
126
|
}, []);
|
|
125
127
|
const HeadCols = () => {
|
|
126
128
|
return (_jsxs(_Fragment, { children: [columns.map((col, i) => {
|