UNPKG

@carbon/react

Version:

React components for the Carbon Design System

75 lines (73 loc) 2.62 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. */ 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/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: _carbon_icons_react.ErrorFilled, ["caution-major"]: _carbon_icons_react.WarningAltInvertedFilled, ["caution-minor"]: _carbon_icons_react.WarningAltFilled, undefined: _carbon_icons_react.UndefinedFilled, succeeded: _carbon_icons_react.CheckmarkFilled, normal: _carbon_icons_react.CheckmarkOutline, ["in-progress"]: _carbon_icons_react.InProgress, incomplete: _carbon_icons_react.Incomplete, ["not-started"]: _carbon_icons_react.CircleDash, pending: _carbon_icons_react.PendingFilled, unknown: _carbon_icons_react.UnknownFilled, informative: _carbon_icons_react.WarningSquareFilled }; const IconIndicator = react.default.forwardRef(({ className: customClassName, kind, label, size = 16 }, ref) => { const prefix = require_usePrefix.usePrefix(); const classNames = (0, classnames.default)(`${prefix}--icon-indicator`, customClassName, { [`${prefix}--icon-indicator--20`]: size == 20 }); const IconForKind = iconTypes[kind]; if (!IconForKind) return null; return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { className: classNames, ref, children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconForKind, { size, className: `${prefix}--icon-indicator--${kind}` }), label] }); }); IconIndicator.propTypes = { className: prop_types.default.string, kind: prop_types.default.oneOf(IconIndicatorKinds).isRequired, label: prop_types.default.string.isRequired, size: prop_types.default.oneOf([16, 20]) }; //#endregion exports.default = IconIndicator;