@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
63 lines (62 loc) • 1.88 kB
JavaScript
;
"use client";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = AccordionTertiaryContent;
var _react = require("react");
var _clsx = _interopRequireDefault(require("clsx"));
var _HeightAnimation = _interopRequireDefault(require("../height-animation/HeightAnimation.js"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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 = (0, _react.useRef)(null);
const targetRef = contentRef || fallbackRef;
const handleOpen = (0, _react.useCallback)(() => {
if (shouldFocusContent && targetRef.current) {
targetRef.current.focus({
preventScroll: true
});
onFocusHandled === null || onFocusHandled === void 0 || onFocusHandled();
}
}, [shouldFocusContent, targetRef, onFocusHandled]);
return (0, _jsxRuntime.jsx)("section", {
...wrapperProps,
ref: targetRef,
id: contentId,
className: (0, _clsx.default)("dnb-tab-focus dnb-accordion__tertiary-content", className),
tabIndex: -1,
title: title,
"aria-label": ariaLabel,
"aria-hidden": !expanded,
children: (0, _jsxRuntime.jsx)(_HeightAnimation.default, {
className: "dnb-accordion__content",
open: expanded,
animate: !noAnimation,
keepInDOM: keepInDOM,
onAnimationStart: onAnimationStart,
onAnimationEnd: onAnimationEnd,
onOpen: handleOpen,
children: children
})
});
}
//# sourceMappingURL=AccordionTertiaryContent.js.map