UNPKG

@carbon/react

Version:

React components for the Carbon Design System

84 lines (76 loc) 2.84 kB
/** * Copyright IBM Corp. 2016, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var PropTypes = require('prop-types'); var React = require('react'); var cx = require('classnames'); var usePrefix = require('../../internal/usePrefix.js'); var iconsReact = require('@carbon/icons-react'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); var React__default = /*#__PURE__*/_interopDefaultLegacy(React); var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx); const IconIndicatorKinds = ['failed', 'caution-major', 'caution-minor', 'undefined', 'succeeded', 'normal', 'in-progress', 'incomplete', 'not-started', 'pending', 'unknown', 'informative']; const iconTypes = { failed: iconsReact.ErrorFilled, ['caution-major']: iconsReact.WarningAltInvertedFilled, ['caution-minor']: iconsReact.WarningAltFilled, undefined: iconsReact.UndefinedFilled, succeeded: iconsReact.CheckmarkFilled, normal: iconsReact.CheckmarkOutline, ['in-progress']: iconsReact.InProgress, incomplete: iconsReact.Incomplete, ['not-started']: iconsReact.CircleDash, pending: iconsReact.PendingFilled, unknown: iconsReact.UnknownFilled, informative: iconsReact.WarningSquareFilled }; const IconIndicator = /*#__PURE__*/React__default["default"].forwardRef(function IconIndicatorContent({ className: customClassName, kind, label, size = 16, ...rest }, ref) { const prefix = usePrefix.usePrefix(); const classNames = cx__default["default"](`${prefix}--icon-indicator`, customClassName, { [`${prefix}--icon-indicator--20`]: size == 20 }); const IconForKind = iconTypes[kind]; if (!IconForKind) { return null; } return /*#__PURE__*/React__default["default"].createElement("div", { className: classNames, ref: ref }, /*#__PURE__*/React__default["default"].createElement(IconForKind, { size: size, className: `${prefix}--icon-indicator--${kind}` }), label); }); IconIndicator.propTypes = { /** * Specify an optional className to add. */ className: PropTypes__default["default"].string, /** * Specify the kind of the Icon Indicator */ kind: PropTypes__default["default"].oneOf(IconIndicatorKinds).isRequired, /** * Label next to the icon. */ label: PropTypes__default["default"].string.isRequired, /** * Specify the size of the Icon Indicator. Defaults to 16. */ size: PropTypes__default["default"].oneOf([16, 20]) }; exports.IconIndicator = IconIndicator; exports.IconIndicatorKinds = IconIndicatorKinds; exports["default"] = IconIndicator;