UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

45 lines (44 loc) 1.41 kB
"use client"; import React, { useContext } from 'react'; import clsx from 'clsx'; import { findElementInChildren } from "../../../shared/component-helper.js"; import Section from "../../section/Section.js"; import Space from "../../space/Space.js"; import ModalContext from "../ModalContext.js"; import H1 from "../../../elements/H1.js"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; export default function ModalHeader({ title = null, children = null, titleClass = null, size = null, ref, ...sectionProps }) { const context = useContext(ModalContext); const customHeader = findElementInChildren(children, cur => { return cur.type === 'h1' || cur.type === H1; }); const usedTitle = title || context.title; const showTitle = !customHeader && usedTitle; const fontSize = size || 'large'; return _jsxs(Section, { id: showTitle ? 'dnb-modal-' + context.id + '-title' : undefined, ...sectionProps, children: [showTitle ? _jsx(Space, { element: "h1", top: "zero", bottom: "small", className: clsx(`dnb-modal__title dnb-h--${fontSize}`, titleClass), children: usedTitle }) : _jsx("div", { "aria-hidden": true, tabIndex: -1, className: "dnb-modal__focus-helper dnb-sr-only", children: usedTitle }), _jsx("div", { children: children })] }); } //# sourceMappingURL=ModalHeader.js.map