// src/atoms/collapse.tsx
import { useEffect, useRef, useState } from "react";
import { jsx } from "react/jsx-runtime";
function Collapse(props) {
  const { children, closedHeight = "0" } = props;
  const [open, setOpen] = useState(() => {
    return props.open || props.defaultOpen || false;
  });
  useEffect(() => {
    if (props.open === void 0)
      return;
    setOpen(props.open);
  }, [props.open]);
  const ref = useRef(null);
  useEffect(() => {
    if (!ref.current)
      return;
    ref.current.style.maxHeight = open ? `${ref.current.scrollHeight}px` : closedHeight;
  }, [closedHeight, open]);
  return /* @__PURE__ */ jsx("div", { className: "tipp-collapse", ref, children });
}

export {
  Collapse
};
//# sourceMappingURL=chunk-LZJR77Q2.js.map