UNPKG

@carbon/react

Version:

React components for the Carbon Design System

100 lines (93 loc) 3.13 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 _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js'); 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'); var _path; const ShapeIndicatorKinds = ['failed', 'critical', 'high', 'medium', 'low', 'cautious', 'undefined', 'stable', 'informative', 'incomplete', 'draft']; // TODO: update to import '@carbon/icons-react' const incompleteIcon = props => /*#__PURE__*/React.createElement("svg", _rollupPluginBabelHelpers.extends({ xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", "aria-hidden": "true" }, props), /*#__PURE__*/React.createElement("path", { fill: "#fff", fillOpacity: 0.01, d: "M0 0h16v16H0z", style: { mixBlendMode: 'multiply' } }), _path || (_path = /*#__PURE__*/React.createElement("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: iconsReact.Critical, critical: iconsReact.CriticalSeverity, high: iconsReact.Caution, medium: iconsReact.DiamondFill, low: iconsReact.LowSeverity, cautious: iconsReact.Caution, undefined: iconsReact.DiamondFill, stable: iconsReact.CircleFill, informative: iconsReact.LowSeverity, incomplete: incompleteIcon, draft: iconsReact.CircleStroke }; // eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452 const ShapeIndicator = /*#__PURE__*/React.forwardRef(({ className: customClassName, kind, label, textSize = 12, // eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452 ...rest }, ref) => { const prefix = usePrefix.usePrefix(); const classNames = cx(`${prefix}--shape-indicator`, customClassName, { [`${prefix}--shape-indicator--14`]: textSize == 14 }); const ShapeForKind = shapeTypes[kind]; if (!ShapeForKind) { return null; } return /*#__PURE__*/React.createElement("div", { className: classNames, ref: ref }, /*#__PURE__*/React.createElement(ShapeForKind, { size: 16, className: `${prefix}--shape-indicator--${kind}` }), label); }); ShapeIndicator.propTypes = { /** * Specify an optional className to add. */ className: PropTypes.string, /** * Specify the kind of the Shape Indicator */ kind: PropTypes.oneOf(ShapeIndicatorKinds).isRequired, /** * Label next to the shape. */ label: PropTypes.string.isRequired, /** * Specify the text size of the Shape Indicator. Defaults to 12. */ textSize: PropTypes.oneOf([12, 14]) }; exports.ShapeIndicator = ShapeIndicator; exports.ShapeIndicatorKinds = ShapeIndicatorKinds; exports.default = ShapeIndicator;