react-better-html 1.1.138 → 1.1.140

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.mjs CHANGED
@@ -8667,7 +8667,7 @@ var FoldableComponent = forwardRef18(function Foldable({
8667
8667
  const theme2 = useTheme();
8668
8668
  const bodyRef = useRef9(null);
8669
8669
  const [internalIsOpen, setInternalIsOpen] = useBooleanState(defaultOpen);
8670
- const [bodyVirtualHeight, setBodyVirtualHeight] = useState12(500);
8670
+ const [bodyVirtualHeight, setBodyVirtualHeight] = useState12();
8671
8671
  const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
8672
8672
  const open = useCallback14(() => {
8673
8673
  if (controlledIsOpen === void 0) setInternalIsOpen.setTrue();
@@ -8683,7 +8683,26 @@ var FoldableComponent = forwardRef18(function Foldable({
8683
8683
  }, [controlledIsOpen, isOpen, onOpenChange]);
8684
8684
  useEffect13(() => {
8685
8685
  if (!bodyRef.current) return;
8686
- setBodyVirtualHeight(Math.min(500, bodyRef.current.scrollHeight * 2));
8686
+ const body = bodyRef.current;
8687
+ setBodyVirtualHeight(body.scrollHeight * 2);
8688
+ const timeout = setTimeout(() => {
8689
+ setBodyVirtualHeight(body.scrollHeight * 2);
8690
+ }, 0.2 * 1e3);
8691
+ return () => {
8692
+ clearTimeout(timeout);
8693
+ };
8694
+ }, [isOpen]);
8695
+ useEffect13(() => {
8696
+ if (!isOpen) return;
8697
+ if (!bodyRef.current) return;
8698
+ const observer = new ResizeObserver(() => {
8699
+ if (!bodyRef.current) return;
8700
+ setBodyVirtualHeight(bodyRef.current.scrollHeight * 2);
8701
+ });
8702
+ observer.observe(bodyRef.current);
8703
+ return () => {
8704
+ observer.disconnect();
8705
+ };
8687
8706
  }, [isOpen]);
8688
8707
  useImperativeHandle5(
8689
8708
  ref,