@lensui/lens-table 0.1.8 → 0.1.9

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
@@ -1698,7 +1698,8 @@ function TableInner({
1698
1698
  const hoveredRowIndexRef = (0, import_react5.useRef)(null);
1699
1699
  const [viewport, setViewport] = (0, import_react5.useState)({ width: 0, height: typeof height === "number" ? height : FALLBACK_HEIGHT });
1700
1700
  const [horizontalScrollbarHeight, setHorizontalScrollbarHeight] = (0, import_react5.useState)(0);
1701
- const resolvedHeight = typeof height === "number" ? height : viewport.height || FALLBACK_HEIGHT;
1701
+ const [availableHeight, setAvailableHeight] = (0, import_react5.useState)(FALLBACK_HEIGHT);
1702
+ const resolvedHeight = typeof height === "number" ? height : availableHeight;
1702
1703
  const [scrollPosition, setScrollPosition] = (0, import_react5.useState)({ left: 0, top: 0 });
1703
1704
  const scrollRef = (0, import_react5.useRef)({ left: 0, top: 0 });
1704
1705
  const [rowKeys, setRowKeys] = useControllableKeys(selectedRowKeys, defaultSelectedRowKeys, (keys) => {
@@ -2375,7 +2376,15 @@ function TableInner({
2375
2376
  (0, import_react5.useLayoutEffect)(() => {
2376
2377
  const element = scrollerRef.current;
2377
2378
  if (!element) return;
2379
+ const root = element.parentElement;
2378
2380
  const update = () => {
2381
+ if (root && typeof height !== "number") {
2382
+ const renderedHeight = root.style.height;
2383
+ root.style.height = height;
2384
+ const nextAvailableHeight = root.clientHeight || FALLBACK_HEIGHT;
2385
+ root.style.height = renderedHeight;
2386
+ setAvailableHeight(nextAvailableHeight);
2387
+ }
2379
2388
  const measuredHeight = element.clientHeight || (typeof height === "number" ? height : FALLBACK_HEIGHT);
2380
2389
  setViewport({ width: element.clientWidth, height: measuredHeight });
2381
2390
  setHorizontalScrollbarHeight(Math.max(0, element.offsetHeight - element.clientHeight));
@@ -2387,6 +2396,7 @@ function TableInner({
2387
2396
  }
2388
2397
  const observer = new ResizeObserver(update);
2389
2398
  observer.observe(element);
2399
+ if (root?.parentElement) observer.observe(root.parentElement);
2390
2400
  return () => observer.disconnect();
2391
2401
  }, [height]);
2392
2402
  (0, import_react5.useEffect)(() => {
package/dist/index.js CHANGED
@@ -1668,7 +1668,8 @@ function TableInner({
1668
1668
  const hoveredRowIndexRef = useRef2(null);
1669
1669
  const [viewport, setViewport] = useState4({ width: 0, height: typeof height === "number" ? height : FALLBACK_HEIGHT });
1670
1670
  const [horizontalScrollbarHeight, setHorizontalScrollbarHeight] = useState4(0);
1671
- const resolvedHeight = typeof height === "number" ? height : viewport.height || FALLBACK_HEIGHT;
1671
+ const [availableHeight, setAvailableHeight] = useState4(FALLBACK_HEIGHT);
1672
+ const resolvedHeight = typeof height === "number" ? height : availableHeight;
1672
1673
  const [scrollPosition, setScrollPosition] = useState4({ left: 0, top: 0 });
1673
1674
  const scrollRef = useRef2({ left: 0, top: 0 });
1674
1675
  const [rowKeys, setRowKeys] = useControllableKeys(selectedRowKeys, defaultSelectedRowKeys, (keys) => {
@@ -2345,7 +2346,15 @@ function TableInner({
2345
2346
  useLayoutEffect2(() => {
2346
2347
  const element = scrollerRef.current;
2347
2348
  if (!element) return;
2349
+ const root = element.parentElement;
2348
2350
  const update = () => {
2351
+ if (root && typeof height !== "number") {
2352
+ const renderedHeight = root.style.height;
2353
+ root.style.height = height;
2354
+ const nextAvailableHeight = root.clientHeight || FALLBACK_HEIGHT;
2355
+ root.style.height = renderedHeight;
2356
+ setAvailableHeight(nextAvailableHeight);
2357
+ }
2349
2358
  const measuredHeight = element.clientHeight || (typeof height === "number" ? height : FALLBACK_HEIGHT);
2350
2359
  setViewport({ width: element.clientWidth, height: measuredHeight });
2351
2360
  setHorizontalScrollbarHeight(Math.max(0, element.offsetHeight - element.clientHeight));
@@ -2357,6 +2366,7 @@ function TableInner({
2357
2366
  }
2358
2367
  const observer = new ResizeObserver(update);
2359
2368
  observer.observe(element);
2369
+ if (root?.parentElement) observer.observe(root.parentElement);
2360
2370
  return () => observer.disconnect();
2361
2371
  }, [height]);
2362
2372
  useEffect2(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lensui/lens-table",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "A lightweight, canvas-rendered React table component for LensUI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",