UNPKG

@carbon/react

Version:

React components for the Carbon Design System

71 lines (69 loc) 2.2 kB
/** * 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 { CheckmarkFilled, CheckmarkOutline, CircleDash, ErrorFilled, InProgress, Incomplete, PendingFilled, UndefinedFilled, UnknownFilled, WarningAltFilled, WarningAltInvertedFilled, WarningSquareFilled } from "@carbon/icons-react"; //#region src/components/IconIndicator/index.tsx /** * 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 IconIndicatorKinds = [ "failed", "caution-major", "caution-minor", "undefined", "succeeded", "normal", "in-progress", "incomplete", "not-started", "pending", "unknown", "informative" ]; const iconTypes = { failed: ErrorFilled, ["caution-major"]: WarningAltInvertedFilled, ["caution-minor"]: WarningAltFilled, undefined: UndefinedFilled, succeeded: CheckmarkFilled, normal: CheckmarkOutline, ["in-progress"]: InProgress, incomplete: Incomplete, ["not-started"]: CircleDash, pending: PendingFilled, unknown: UnknownFilled, informative: WarningSquareFilled }; const IconIndicator = React.forwardRef(({ className: customClassName, kind, label, size = 16 }, ref) => { const prefix = usePrefix(); const classNames$1 = classNames(`${prefix}--icon-indicator`, customClassName, { [`${prefix}--icon-indicator--20`]: size == 20 }); const IconForKind = iconTypes[kind]; if (!IconForKind) return null; return /* @__PURE__ */ jsxs("div", { className: classNames$1, ref, children: [/* @__PURE__ */ jsx(IconForKind, { size, className: `${prefix}--icon-indicator--${kind}` }), label] }); }); IconIndicator.propTypes = { className: PropTypes.string, kind: PropTypes.oneOf(IconIndicatorKinds).isRequired, label: PropTypes.string.isRequired, size: PropTypes.oneOf([16, 20]) }; //#endregion export { IconIndicator as default };