UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

81 lines (80 loc) 2.4 kB
import { jsx as s } from "../../../external/preact/jsx-runtime/dist/jsxRuntime.module.js"; import r from "classnames"; import { useState as p, useMemo as _, useCallback as E } from "../../../external/preact/hooks/dist/hooks.module.js"; import { InteractionKeyCode as R } from "../../types.js"; import { CARD_TOGGLE_CLASS as v, CARD_TITLE as w, CARD_SUBTITLE as B, CARD_HEADER_CONTENT as P, CARD_HEADER as g, CARD_BODY as G, CARD_BODY_WITH_TITLE as k, CARD_FOOTER as y, CARD_BASE_CLASS as K, CARD_COMPACT as M, CARD_EXPANDABLE_CLASS as U, CARD_NO_PADDING as Y, CARD_NO_OUTLINE as j, CARD_FILLED as q } from "./constants.js"; /* empty css */ import { Icon as W } from "../Icon/Icon.js"; import { uuid as X } from "../../../utils/random/uuid.js"; const $ = ({ title: i, subTitle: m, children: l, expandable: o = !1, footer: D, el: N, renderHeader: t, renderFooter: C, filled: T, noOutline: u, noPadding: d, classNameModifiers: f, testId: h, compact: I }) => { const L = N || "header", [c, S] = p(!1), A = _(() => X(), []), a = E(() => { o && S((n) => !n); }, [o]), e = E( (n) => { switch (n.code) { case R.ENTER: case R.SPACE: n.preventDefault(), a(); return; } }, [a] ), O = _(() => o ? { role: "button", tabIndex: 0, onClick: a, onKeyDown: e, "aria-controls": A, "aria-expanded": c } : {}, [o, c, A, e, a]); return /* @__PURE__ */ s( "section", { "data-testid": h, className: r(K, f, { [q]: T, [j]: u, [Y]: d, [U]: o, [M]: I }), ...O, children: [ (i || t) && /* @__PURE__ */ s(L, { className: r(g), children: /* @__PURE__ */ s("div", { className: r(P), children: [ o && /* @__PURE__ */ s(W, { name: c ? "chevron-up" : "chevron-down", className: v, role: "presentation" }), t || /* @__PURE__ */ s("span", { className: w, children: i }), m && /* @__PURE__ */ s("div", { className: B, children: m }) ] }) }), (!o || c) && /* @__PURE__ */ s( "div", { id: A, className: r(G, { [k]: i || t }), children: l } ), (D || C) && /* @__PURE__ */ s("footer", { className: y, children: C || D }) ] } ); }; export { $ as default };