UNPKG

@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.

29 lines (26 loc) 1.75 kB
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 { getTabsCss as getComponentCss$9 } from '../../../../../../components/dist/styles/esm/styles-entry.mjs'; import { PTabsBar } from '../components/tabs-bar.wrapper.mjs'; /** * @slot {"name": "", "description": "Default slot for the `p-tabs-item` tags." } * * @controlled { "props": ["activeTabIndex"], "event": "update", "isInternallyMutated": true } */ class DSRTabs extends Component { host; tabsItems = []; slot; render() { const { children, otherChildren } = splitChildren(this.props.children); const manipulatedChildren = children.map((child, i) => typeof child === 'object' && 'props' in child && otherChildren.includes(child) ? { ...child, props: { ...child.props, theme: this.props.theme, hidden: this.props.activeTabIndex !== i ? true : null } } : child); const style = minifyCss(getComponentCss$9()); return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxs(Fragment, { children: [jsx(PTabsBar, { className: "root", size: this.props.size, background: this.props.background, compact: this.props.compact, activeTabIndex: this.props.activeTabIndex, aria: this.props.aria, children: otherChildren.map((tab, index) => (jsx("button", { type: "button", children: typeof tab === 'object' && 'props' in tab && tab.props.label }, index))) }), jsx("slot", {})] })] }), manipulatedChildren] })); } } export { DSRTabs };