@porsche-design-system/components-react
Version:
Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.
44 lines (40 loc) • 2.51 kB
JavaScript
;
var jsxRuntime = require('react/jsx-runtime');
var splitChildren = require('../../splitChildren.cjs');
var react = require('react');
var minifyCss = require('../../minifyCss.cjs');
var stylesEntry = require('../../../../../../components/dist/styles/esm/styles-entry.cjs');
var utilsEntry = require('../../../../../../components/dist/utils/esm/utils-entry.cjs');
var dialogBase = require('./dialog-base.cjs');
/**
* @slot {"name": "header", "description": "Renders a header section above the content area." }
* @slot {"name": "", "description": "Default slot for the main content." }
*
* @controlled {"props": ["open"], "event": "dismiss"}
*/
class DSRSheet extends react.Component {
host;
dialog;
scroller;
hasHeader;
topLayer = utilsEntry.createTopLayerController({
getElement: () => this.props.dialog,
isShown: () => !!this.props.dialog?.open,
show: () => utilsEntry.showDialog(this.props.dialog, this.props.scroller),
hide: () => this.props.dialog?.close(),
});
render() {
const { namedSlotChildren} = splitChildren.splitChildren(this.props.children);
const hasHeader = namedSlotChildren.filter(({ props: { slot } }) => slot === 'header').length > 0;
if (this.props.open) ;
const style = minifyCss.minifyCss(stylesEntry.getSheetCss(this.props.open, this.props.background, this.props.dismissButton));
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsxRuntime.jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxRuntime.jsx(dialogBase.DialogBase, { host: null, inert: !this.props.open, dismissable: this.props.dismissButton ?? undefined, containerClass: "sheet", header: hasHeader ? jsxRuntime.jsx("slot", { name: "header" }) : undefined, ariaAttributes: utilsEntry.parseAndGetAriaAttributes({
'aria-modal': true,
...(hasHeader && {
'aria-label': namedSlotChildren.filter(({ props: { slot } }) => slot === 'header').length > 0 && namedSlotChildren.find(({ props: { slot } }) => slot === 'header')?.props.children,
}),
...utilsEntry.parseAndGetAriaAttributes(this.props.aria),
}), children: jsxRuntime.jsx("slot", {}) })] }), this.props.children] }));
}
}
exports.DSRSheet = DSRSheet;