@carbon/react
Version:
React components for the Carbon Design System
86 lines (84 loc) • 2.44 kB
JavaScript
/**
* Copyright IBM Corp. 2016, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { usePrefix } from "../../internal/usePrefix.js";
import classNames from "classnames";
import React from "react";
import PropTypes from "prop-types";
import { jsx, jsxs } from "react/jsx-runtime";
import { Caution, CircleFill, CircleStroke, Critical, CriticalSeverity, DiamondFill, LowSeverity } from "@carbon/icons-react";
//#region src/components/ShapeIndicator/index.tsx
/**
* Copyright IBM Corp. 2025, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const ShapeIndicatorKinds = [
"failed",
"critical",
"high",
"medium",
"low",
"cautious",
"undefined",
"stable",
"informative",
"incomplete",
"draft"
];
const incompleteIcon = (props) => /* @__PURE__ */ jsxs("svg", {
xmlns: "http://www.w3.org/2000/svg",
width: 16,
height: 16,
fill: "none",
"aria-hidden": "true",
...props,
children: [/* @__PURE__ */ jsx("path", {
fill: "#fff",
fillOpacity: .01,
d: "M0 0h16v16H0z",
style: { mixBlendMode: "multiply" }
}), /* @__PURE__ */ jsx("path", {
fill: "#161616",
d: "M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2Zm0 2a4.004 4.004 0 0 1 4 4H4a4.004 4.004 0 0 1 4-4Z"
})]
});
const shapeTypes = {
failed: Critical,
critical: CriticalSeverity,
high: Caution,
medium: DiamondFill,
low: LowSeverity,
cautious: Caution,
undefined: DiamondFill,
stable: CircleFill,
informative: LowSeverity,
incomplete: incompleteIcon,
draft: CircleStroke
};
const ShapeIndicator = React.forwardRef(({ className: customClassName, kind, label, textSize = 12 }, ref) => {
const prefix = usePrefix();
const classNames$1 = classNames(`${prefix}--shape-indicator`, customClassName, { [`${prefix}--shape-indicator--14`]: textSize == 14 });
const ShapeForKind = shapeTypes[kind];
if (!ShapeForKind) return null;
return /* @__PURE__ */ jsxs("div", {
className: classNames$1,
ref,
children: [/* @__PURE__ */ jsx(ShapeForKind, {
size: 16,
className: `${prefix}--shape-indicator--${kind}`
}), label]
});
});
ShapeIndicator.propTypes = {
className: PropTypes.string,
kind: PropTypes.oneOf(ShapeIndicatorKinds).isRequired,
label: PropTypes.string.isRequired,
textSize: PropTypes.oneOf([12, 14])
};
//#endregion
export { ShapeIndicator as default };