@adyen/adyen-platform-experience-web
Version:

46 lines (45 loc) • 1.83 kB
JavaScript
import { jsx as e } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import N from "classnames";
import { useState as s, useRef as O, useCallback as R, useLayoutEffect as _ } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import p from "../../../hooks/useUniqueId.js";
import { ACCORDION_HEADER_CLASS as S, ACCORDION_HEADER_CONTAINER_CLASS as h, ACCORDION_HEADER_CONTROLLER_CLASS as I, ACCORDION_CONTENT_CLASS as v, ACCORDION_BASE_CLASS as D } from "./constants.js";
/* empty css */
import { Icon as a } from "../Icon/Icon.js";
function y({ children: d, classNames: l, header: m, headerInformation: t }) {
const [n, C] = s(!1), [u, A] = s(0), o = O(null), f = R(() => C((E) => !E), []), c = p(), r = `accordion-content-${c}`, i = `accordion-controller-${c}`;
return _(() => {
o.current && A(o.current.offsetHeight);
}, []), /* @__PURE__ */ e("div", { className: N(D, l), children: [
/* @__PURE__ */ e("div", { className: S, children: [
/* @__PURE__ */ e(
"button",
{
id: i,
"aria-controls": r,
className: h,
onClick: f,
"aria-expanded": n,
children: /* @__PURE__ */ e("div", { className: I, children: [
m,
n ? /* @__PURE__ */ e(a, { name: "chevron-up" }) : /* @__PURE__ */ e(a, { name: "chevron-down" })
] })
}
),
t && /* @__PURE__ */ e("div", { children: t })
] }),
/* @__PURE__ */ e(
"div",
{
role: "region",
id: r,
"aria-labelledby": i,
style: { maxHeight: n ? u : 0 },
className: v,
children: /* @__PURE__ */ e("div", { ref: o, children: d })
}
)
] });
}
export {
y as default
};