Files
klz-cables.com/.pnpm-store/v10/files/60/df6f081c26d85e3a7d39b2efbf63390e8b3e06a399f0028f5b5208123bf7f5561f04a5bc1e8c2f7466e208b2106988775f024b31e7c6070898d216a7f31f29
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

80 lines
2.3 KiB
Plaintext

'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import React, { useEffect, useRef } from 'react';
import { usePatchAnimateHeight } from './usePatchAnimateHeight.js';
import './index.scss';
export const AnimateHeight = ({
id,
children,
className,
duration = 300,
height
}) => {
const [open, setOpen] = React.useState(() => Boolean(height));
const prevIsOpen = useRef(open);
const [childrenDisplay, setChildrenDisplay] = React.useState(() => open ? '' : 'none');
const [parentOverflow, setParentOverflow] = React.useState(() => open ? '' : 'hidden');
const [isAnimating, setIsAnimating] = React.useState(false);
const containerRef = useRef(null);
const contentRef = useRef(null);
useEffect(() => {
let displayTimer;
let overflowTimer;
const newIsOpen = Boolean(height);
const hasChanged = prevIsOpen.current !== newIsOpen;
prevIsOpen.current = newIsOpen;
if (hasChanged) {
setIsAnimating(true);
setParentOverflow('hidden');
if (newIsOpen) {
setChildrenDisplay('');
} else {
// `display: none` once closed
displayTimer = window.setTimeout(() => {
setChildrenDisplay('none');
}, duration);
}
setOpen(newIsOpen);
// reset overflow once open
overflowTimer = window.setTimeout(() => {
setParentOverflow('');
setIsAnimating(false);
}, duration);
}
return () => {
if (displayTimer) {
clearTimeout(displayTimer);
}
if (overflowTimer) {
clearTimeout(overflowTimer);
}
};
}, [height, duration]);
usePatchAnimateHeight({
containerRef,
contentRef,
duration,
open
});
return /*#__PURE__*/_jsx("div", {
"aria-hidden": !open,
className: [className, 'rah-static', open && height === 'auto' && 'rah-static--height-auto', isAnimating && `rah-animating--${open ? 'down' : 'up'}`, isAnimating && height === 'auto' && `rah-animating--to-height-auto`].filter(Boolean).join(' '),
id: id,
ref: containerRef,
style: {
overflow: parentOverflow,
transition: `height ${duration}ms ease`
},
children: /*#__PURE__*/_jsx("div", {
ref: contentRef,
...(childrenDisplay ? {
style: {
display: childrenDisplay
}
} : {}),
children: children
})
});
};
//# sourceMappingURL=index.js.map