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.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8743,7 +8743,7 @@ var FoldableComponent = (0, import_react28.forwardRef)(function Foldable({
|
|
|
8743
8743
|
const theme2 = useTheme();
|
|
8744
8744
|
const bodyRef = (0, import_react28.useRef)(null);
|
|
8745
8745
|
const [internalIsOpen, setInternalIsOpen] = useBooleanState(defaultOpen);
|
|
8746
|
-
const [bodyVirtualHeight, setBodyVirtualHeight] = (0, import_react28.useState)(
|
|
8746
|
+
const [bodyVirtualHeight, setBodyVirtualHeight] = (0, import_react28.useState)();
|
|
8747
8747
|
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
8748
8748
|
const open = (0, import_react28.useCallback)(() => {
|
|
8749
8749
|
if (controlledIsOpen === void 0) setInternalIsOpen.setTrue();
|
|
@@ -8759,7 +8759,26 @@ var FoldableComponent = (0, import_react28.forwardRef)(function Foldable({
|
|
|
8759
8759
|
}, [controlledIsOpen, isOpen, onOpenChange]);
|
|
8760
8760
|
(0, import_react28.useEffect)(() => {
|
|
8761
8761
|
if (!bodyRef.current) return;
|
|
8762
|
-
|
|
8762
|
+
const body = bodyRef.current;
|
|
8763
|
+
setBodyVirtualHeight(body.scrollHeight * 2);
|
|
8764
|
+
const timeout = setTimeout(() => {
|
|
8765
|
+
setBodyVirtualHeight(body.scrollHeight * 2);
|
|
8766
|
+
}, 0.2 * 1e3);
|
|
8767
|
+
return () => {
|
|
8768
|
+
clearTimeout(timeout);
|
|
8769
|
+
};
|
|
8770
|
+
}, [isOpen]);
|
|
8771
|
+
(0, import_react28.useEffect)(() => {
|
|
8772
|
+
if (!isOpen) return;
|
|
8773
|
+
if (!bodyRef.current) return;
|
|
8774
|
+
const observer = new ResizeObserver(() => {
|
|
8775
|
+
if (!bodyRef.current) return;
|
|
8776
|
+
setBodyVirtualHeight(bodyRef.current.scrollHeight * 2);
|
|
8777
|
+
});
|
|
8778
|
+
observer.observe(bodyRef.current);
|
|
8779
|
+
return () => {
|
|
8780
|
+
observer.disconnect();
|
|
8781
|
+
};
|
|
8763
8782
|
}, [isOpen]);
|
|
8764
8783
|
(0, import_react28.useImperativeHandle)(
|
|
8765
8784
|
ref,
|