@carbon/react
Version:
React components for the Carbon Design System
90 lines (88 loc) • 2.99 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.
*/
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_usePrefix = require("../../internal/usePrefix.js");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let react_jsx_runtime = require("react/jsx-runtime");
let _carbon_icons_react = require("@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__ */ (0, react_jsx_runtime.jsxs)("svg", {
xmlns: "http://www.w3.org/2000/svg",
width: 16,
height: 16,
fill: "none",
"aria-hidden": "true",
...props,
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
fill: "#fff",
fillOpacity: .01,
d: "M0 0h16v16H0z",
style: { mixBlendMode: "multiply" }
}), /* @__PURE__ */ (0, react_jsx_runtime.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: _carbon_icons_react.Critical,
critical: _carbon_icons_react.CriticalSeverity,
high: _carbon_icons_react.Caution,
medium: _carbon_icons_react.DiamondFill,
low: _carbon_icons_react.LowSeverity,
cautious: _carbon_icons_react.Caution,
undefined: _carbon_icons_react.DiamondFill,
stable: _carbon_icons_react.CircleFill,
informative: _carbon_icons_react.LowSeverity,
incomplete: incompleteIcon,
draft: _carbon_icons_react.CircleStroke
};
const ShapeIndicator = react.default.forwardRef(({ className: customClassName, kind, label, textSize = 12 }, ref) => {
const prefix = require_usePrefix.usePrefix();
const classNames = (0, classnames.default)(`${prefix}--shape-indicator`, customClassName, { [`${prefix}--shape-indicator--14`]: textSize == 14 });
const ShapeForKind = shapeTypes[kind];
if (!ShapeForKind) return null;
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
className: classNames,
ref,
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShapeForKind, {
size: 16,
className: `${prefix}--shape-indicator--${kind}`
}), label]
});
});
ShapeIndicator.propTypes = {
className: prop_types.default.string,
kind: prop_types.default.oneOf(ShapeIndicatorKinds).isRequired,
label: prop_types.default.string.isRequired,
textSize: prop_types.default.oneOf([12, 14])
};
//#endregion
exports.default = ShapeIndicator;