@optilogic/core 1.3.1 → 1.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optilogic/core",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Core UI components for Optilogic - A professional React component library",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -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.useLayoutEffect(() => {
171
- if (!fillWidth || !parentRef.current) return;
172
- const observer = new ResizeObserver((entries) => {
173
- const w = entries[0]?.contentRect.width;
174
- if (w && w > 0) setContainerWidth(w);
175
- });
176
- observer.observe(parentRef.current);
177
- return () => observer.disconnect();
178
- }, [fillWidth]);
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={parentRef}
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={parentRef} className="flex-1 overflow-auto min-h-0">
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(