@optilogic/core 1.3.1 → 1.3.2
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/index.cjs +21 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/data-grid/DataGrid.tsx +25 -11
package/package.json
CHANGED
|
@@ -166,16 +166,30 @@ export function DataGrid<T = Record<string, CellValue>>({
|
|
|
166
166
|
|
|
167
167
|
// Measure container width for fillWidth mode
|
|
168
168
|
const [containerWidth, setContainerWidth] = React.useState(0);
|
|
169
|
+
const fillWidthObserverRef = React.useRef<ResizeObserver | null>(null);
|
|
169
170
|
|
|
170
|
-
React.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
171
|
+
const parentCallbackRef = React.useCallback(
|
|
172
|
+
(node: HTMLDivElement | null) => {
|
|
173
|
+
fillWidthObserverRef.current?.disconnect();
|
|
174
|
+
fillWidthObserverRef.current = null;
|
|
175
|
+
|
|
176
|
+
(parentRef as React.MutableRefObject<HTMLDivElement | null>).current = node;
|
|
177
|
+
|
|
178
|
+
if (!fillWidth || !node) return;
|
|
179
|
+
|
|
180
|
+
const observer = new ResizeObserver((entries) => {
|
|
181
|
+
const w = entries[0]?.contentRect.width;
|
|
182
|
+
if (w && w > 0) setContainerWidth(w);
|
|
183
|
+
});
|
|
184
|
+
observer.observe(node);
|
|
185
|
+
fillWidthObserverRef.current = observer;
|
|
186
|
+
},
|
|
187
|
+
[fillWidth],
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
React.useEffect(() => {
|
|
191
|
+
return () => fillWidthObserverRef.current?.disconnect();
|
|
192
|
+
}, []);
|
|
179
193
|
|
|
180
194
|
// Filter visible columns
|
|
181
195
|
const visibleColumns = React.useMemo(
|
|
@@ -589,7 +603,7 @@ export function DataGrid<T = Record<string, CellValue>>({
|
|
|
589
603
|
)}
|
|
590
604
|
|
|
591
605
|
<div
|
|
592
|
-
ref={
|
|
606
|
+
ref={parentCallbackRef}
|
|
593
607
|
className="flex-1 overflow-auto bg-background relative w-full min-h-0 max-h-full"
|
|
594
608
|
style={{ contain: "strict" }}
|
|
595
609
|
>
|
|
@@ -839,7 +853,7 @@ export function DataGrid<T = Record<string, CellValue>>({
|
|
|
839
853
|
</div>
|
|
840
854
|
)}
|
|
841
855
|
|
|
842
|
-
<div ref={
|
|
856
|
+
<div ref={parentCallbackRef} className="flex-1 overflow-auto min-h-0">
|
|
843
857
|
{/* Header row using HeaderCell for consistent features */}
|
|
844
858
|
<div
|
|
845
859
|
className={cn(
|