@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.
37 lines (34 loc) • 1.79 kB
JavaScript
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
import { Component } from 'react';
import '../../provider.mjs';
import { splitChildren } from '../../splitChildren.mjs';
import { minifyCss } from '../../minifyCss.mjs';
import { getTabsBarCss as getComponentCss$b } from '../../../../../../components/dist/styles/esm/styles-entry.mjs';
import { getSanitizedActiveTabIndex, parseAndGetAriaAttributes } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
import { PScroller } from '../components/scroller.wrapper.mjs';
/**
* @slot {"name": "", "description": "Default slot for the `button` or `a` tags which will be rendered as tabs." }
*
* @controlled {"props": ["activeTabIndex"], "event": "update"}
*/
class DSRTabsBar extends Component {
host;
tabs = [];
bar;
scroller;
slot;
hasPTabsParent;
isTabList;
resizeObserver;
render() {
const { children} = splitChildren(this.props.children);
const style = minifyCss(getComponentCss$b(this.props.background, this.props.size, this.props.compact, getSanitizedActiveTabIndex(this.props.activeTabIndex, children)));
return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxs(PScroller, { className: "scroller", compact: this.props.compact, ...(this.props.isTabList && {
aria: {
role: 'tablist',
...parseAndGetAriaAttributes(this.props.aria),
},
}), children: [jsx("slot", {}), jsx("span", { className: "bar" })] })] }), this.props.children] }));
}
}
export { DSRTabsBar };