UNPKG

@carbon/react

Version:

React components for the Carbon Design System

104 lines (95 loc) 3.46 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'); 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); 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__default["default"].createElement("svg", _rollupPluginBabelHelpers["extends"]({ xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", "aria-hidden": "true" }, props), /*#__PURE__*/React__default["default"].createElement("path", { fill: "#fff", fillOpacity: 0.01, d: "M0 0h16v16H0z", style: { mixBlendMode: 'multiply' } }), _path || (_path = /*#__PURE__*/React__default["default"].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 }; const ShapeIndicator = /*#__PURE__*/React__default["default"].forwardRef(function ShapeIndicatorContent({ className: customClassName, kind, label, textSize = 12, ...rest }, ref) { const prefix = usePrefix.usePrefix(); const classNames = cx__default["default"](`${prefix}--shape-indicator`, customClassName, { [`${prefix}--shape-indicator--14`]: textSize == 14 }); const ShapeForKind = shapeTypes[kind]; if (!ShapeForKind) { return null; } return /*#__PURE__*/React__default["default"].createElement("div", { className: classNames, ref: ref }, /*#__PURE__*/React__default["default"].createElement(ShapeForKind, { size: 16, className: `${prefix}--shape-indicator--${kind}` }), label); }); ShapeIndicator.propTypes = { /** * Specify an optional className to add. */ className: PropTypes__default["default"].string, /** * Specify the kind of the Shape Indicator */ kind: PropTypes__default["default"].oneOf(ShapeIndicatorKinds).isRequired, /** * Label next to the shape. */ label: PropTypes__default["default"].string.isRequired, /** * Specify the text size of the Shape Indicator. Defaults to 12. */ textSize: PropTypes__default["default"].oneOf([12, 14]) }; exports.ShapeIndicator = ShapeIndicator; exports.ShapeIndicatorKinds = ShapeIndicatorKinds; exports["default"] = ShapeIndicator;