@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.
31 lines (28 loc) • 1.9 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 { stripFocusAndHoverStyles } from '../../stripFocusAndHoverStyles.mjs';
import { getSelectOptionCss as getComponentCss$r } from '../../../../../../components/dist/styles/esm/styles-entry.mjs';
import { getOptionAriaAttributes } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
import { PIcon } from '../components/icon.wrapper.mjs';
/**
* @slot {"name": "", "description": "Default slot for the option content." }
*/
class DSRSelectOption extends Component {
host;
render() {
splitChildren(this.props.children);
const { theme = 'light', selected, highlighted, hidden } = this.props;
const isDisabled = this.props.disabled || this.props.disabledParent;
const style = minifyCss(stripFocusAndHoverStyles(getComponentCss$r(theme)));
return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx(Fragment, { children: jsxs("div", { role: "option", className: {
option: true,
'option--selected': selected,
'option--highlighted': highlighted,
'option--disabled': isDisabled,
}, ...getOptionAriaAttributes(selected, isDisabled, hidden, !!this.props.value), children: [jsx("slot", {}), selected && (jsx(PIcon, { className: "icon", "aria-hidden": "true", name: "check", color: isDisabled ? 'state-disabled' : 'primary', theme: theme }))] }) })] }), this.props.children] }));
}
}
export { DSRSelectOption };