@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 CHANGED
@@ -4846,15 +4846,25 @@ function DataGrid({
4846
4846
  const [headerHeight, setHeaderHeight] = React20__namespace.useState(40);
4847
4847
  const [hoveredCell, setHoveredCell] = React20__namespace.useState(null);
4848
4848
  const [containerWidth, setContainerWidth] = React20__namespace.useState(0);
4849
- React20__namespace.useLayoutEffect(() => {
4850
- if (!fillWidth || !parentRef.current) return;
4851
- const observer = new ResizeObserver((entries) => {
4852
- const w = entries[0]?.contentRect.width;
4853
- if (w && w > 0) setContainerWidth(w);
4854
- });
4855
- observer.observe(parentRef.current);
4856
- return () => observer.disconnect();
4857
- }, [fillWidth]);
4849
+ const fillWidthObserverRef = React20__namespace.useRef(null);
4850
+ const parentCallbackRef = React20__namespace.useCallback(
4851
+ (node) => {
4852
+ fillWidthObserverRef.current?.disconnect();
4853
+ fillWidthObserverRef.current = null;
4854
+ parentRef.current = node;
4855
+ if (!fillWidth || !node) return;
4856
+ const observer = new ResizeObserver((entries) => {
4857
+ const w = entries[0]?.contentRect.width;
4858
+ if (w && w > 0) setContainerWidth(w);
4859
+ });
4860
+ observer.observe(node);
4861
+ fillWidthObserverRef.current = observer;
4862
+ },
4863
+ [fillWidth]
4864
+ );
4865
+ React20__namespace.useEffect(() => {
4866
+ return () => fillWidthObserverRef.current?.disconnect();
4867
+ }, []);
4858
4868
  const visibleColumns = React20__namespace.useMemo(
4859
4869
  () => columns.filter((col) => !col.hidden),
4860
4870
  [columns]
@@ -5157,7 +5167,7 @@ function DataGrid({
5157
5167
  /* @__PURE__ */ jsxRuntime.jsx(
5158
5168
  "div",
5159
5169
  {
5160
- ref: parentRef,
5170
+ ref: parentCallbackRef,
5161
5171
  className: "flex-1 overflow-auto bg-background relative w-full min-h-0 max-h-full",
5162
5172
  style: { contain: "strict" },
5163
5173
  children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -5372,7 +5382,7 @@ function DataGrid({
5372
5382
  }
5373
5383
  )
5374
5384
  ] }) }),
5375
- /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: parentRef, className: "flex-1 overflow-auto min-h-0", children: [
5385
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: parentCallbackRef, className: "flex-1 overflow-auto min-h-0", children: [
5376
5386
  /* @__PURE__ */ jsxRuntime.jsx(
5377
5387
  "div",
5378
5388
  {