UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

57 lines (56 loc) 1.56 kB
"use client"; import { useCallback, useRef } from 'react'; import clsx from 'clsx'; import HeightAnimation from "../height-animation/HeightAnimation.js"; import { jsx as _jsx } from "react/jsx-runtime"; export default function AccordionTertiaryContent({ contentId, expanded, noAnimation = false, shouldFocusContent = false, onFocusHandled, contentRef, className, children, ...rest }) { const { keepInDOM = false, onAnimationStart, onAnimationEnd, title, ['aria-label']: ariaLabel, ...wrapperProps } = rest; const fallbackRef = useRef(null); const targetRef = contentRef || fallbackRef; const handleOpen = useCallback(() => { if (shouldFocusContent && targetRef.current) { targetRef.current.focus({ preventScroll: true }); onFocusHandled === null || onFocusHandled === void 0 || onFocusHandled(); } }, [shouldFocusContent, targetRef, onFocusHandled]); return _jsx("section", { ...wrapperProps, ref: targetRef, id: contentId, className: clsx("dnb-tab-focus dnb-accordion__tertiary-content", className), tabIndex: -1, title: title, "aria-label": ariaLabel, "aria-hidden": !expanded, children: _jsx(HeightAnimation, { className: "dnb-accordion__content", open: expanded, animate: !noAnimation, keepInDOM: keepInDOM, onAnimationStart: onAnimationStart, onAnimationEnd: onAnimationEnd, onOpen: handleOpen, children: children }) }); } //# sourceMappingURL=AccordionTertiaryContent.js.map