@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.
15 lines (12 loc) • 1.26 kB
JavaScript
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
import { splitChildren } from '../../splitChildren.mjs';
import { labelId, descriptionId } from '../../../../../../components/dist/utils/esm/utils-entry.mjs';
import { Required } from './required.mjs';
const Label = ({ hasLabel, hasDescription, children,
// host,
label, tag, description, htmlFor, isRequired, isLoading, isDisabled, stopClickPropagation, }) => {
splitChildren(children);
const TagType = tag || 'label';
return (jsxs(Fragment, { children: [hasLabel && (jsxs("div", { className: "label-wrapper", children: [jsx(TagType, { className: "label", id: labelId, "aria-disabled": isLoading || isDisabled ? 'true' : null, htmlFor: htmlFor, children: jsxs(Fragment, { children: [label || jsx("slot", { name: "label" }), isRequired /* && !isParentFieldsetRequired(host) */ && jsx(Required, {})] }) }), stopClickPropagation ? (jsx("span", { className: "label-after", children: jsx("slot", { name: "label-after" }) })) : (jsx("slot", { name: "label-after" }))] })), hasDescription && (jsx("span", { className: "label", id: descriptionId, "aria-disabled": isLoading || isDisabled ? 'true' : null, children: description || jsx("slot", { name: "description" }) }))] }));
};
export { Label };