@carbon/ibm-products
Version:
Carbon for IBM Products
321 lines (319 loc) • 9.3 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 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 { __toESM } from "../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../node_modules/classnames/index.js";
import { pkg } from "../../settings.js";
import { getDevtoolsProps } from "../../global/js/utils/devtools.js";
import React, { forwardRef } from "react";
import PropTypes from "prop-types";
import { CheckmarkFilled, CheckmarkOutline, ErrorFilled, InProgress, InformationSquareFilled, Misuse, Pending, UndefinedFilled, UnknownFilled, WarningAltFilled, WarningAltInvertedFilled } from "@carbon/react/icons";
//#region src/components/StatusIcon/StatusIcon.tsx
/**
* Copyright IBM Corp. 2021, 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ __toESM(require_classnames());
const blockClass = `${pkg.prefix}--status-icon`;
const componentName = "StatusIcon";
const StatusIcon = forwardRef(({ kind, theme, size, className, iconDescription, ...rest }, ref) => {
const forwardedRef = ref;
const IconComponent = {
fatal: {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(Misuse, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(Misuse, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(Misuse, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(Misuse, {
size: 32,
ref: forwardedRef,
...props
}))
},
critical: {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(ErrorFilled, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(ErrorFilled, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(ErrorFilled, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(ErrorFilled, {
size: 32,
ref: forwardedRef,
...props
}))
},
"major-warning": {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(WarningAltInvertedFilled, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(WarningAltInvertedFilled, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(WarningAltInvertedFilled, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(WarningAltInvertedFilled, {
size: 32,
ref: forwardedRef,
...props
}))
},
"minor-warning": {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(WarningAltFilled, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(WarningAltFilled, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(WarningAltFilled, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(WarningAltFilled, {
size: 32,
ref: forwardedRef,
...props
}))
},
undefined: {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(UndefinedFilled, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(UndefinedFilled, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(UndefinedFilled, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(UndefinedFilled, {
size: 32,
ref: forwardedRef,
...props
}))
},
unknown: {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(UnknownFilled, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(UnknownFilled, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(UnknownFilled, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(UnknownFilled, {
size: 32,
ref: forwardedRef,
...props
}))
},
normal: {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(CheckmarkFilled, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(CheckmarkFilled, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(CheckmarkFilled, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(CheckmarkFilled, {
size: 32,
ref: forwardedRef,
...props
}))
},
info: {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(InformationSquareFilled, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(InformationSquareFilled, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(InformationSquareFilled, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(InformationSquareFilled, {
size: 32,
ref: forwardedRef,
...props
}))
},
"in-progress": {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(InProgress, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(InProgress, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(InProgress, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(InProgress, {
size: 32,
ref: forwardedRef,
...props
}))
},
running: {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(CheckmarkOutline, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(CheckmarkOutline, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(CheckmarkOutline, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(CheckmarkOutline, {
size: 32,
ref: forwardedRef,
...props
}))
},
pending: {
sm: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(Pending, {
size: 16,
ref: forwardedRef,
...props
})),
md: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(Pending, {
size: 20,
ref: forwardedRef,
...props
})),
lg: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(Pending, {
size: 24,
ref: forwardedRef,
...props
})),
xl: forwardRef((props, _ref) => /* @__PURE__ */ React.createElement(Pending, {
size: 32,
ref: forwardedRef,
...props
}))
}
}[kind]?.[size];
const classNames = (0, import_classnames.default)(className, blockClass, `${blockClass}--${theme}`, { [`${blockClass}--${theme}-${kind}`]: kind });
return IconComponent && /* @__PURE__ */ React.createElement(IconComponent, {
...rest,
className: classNames,
ref,
...getDevtoolsProps(componentName)
}, /* @__PURE__ */ React.createElement("title", null, iconDescription));
});
StatusIcon.displayName = componentName;
StatusIcon.propTypes = {
/**
* Provide an optional class to be applied to the modal root node.
*/
className: PropTypes.string,
/**
* A required prop that provides a title element and tooltip for the icon for accessibility purposes
*/
iconDescription: PropTypes.string.isRequired,
/**
* A required prop that displays the respective icon associated with the status
*/
kind: PropTypes.oneOf([
"fatal",
"critical",
"major-warning",
"minor-warning",
"undefined",
"unknown",
"normal",
"info",
"in-progress",
"running",
"pending"
]).isRequired,
/**
* A required prop that displays the size of the icon associate with the status
*/
size: PropTypes.oneOf([
"sm",
"md",
"lg",
"xl"
]).isRequired,
/**
* A required prop that displays the theme of the icon associated with the status
*/
theme: PropTypes.oneOf(["light", "dark"]).isRequired
};
//#endregion
export { StatusIcon };