UNPKG

@bigbinary/neetoui

Version:

neetoUI drives the experience at all neeto products

95 lines (92 loc) 4.38 kB
import _defineProperty from '@babel/runtime/helpers/defineProperty'; import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; import { forwardRef, Fragment } from 'react'; import classnames from 'classnames'; import Close from '@bigbinary/neeto-icons/Close'; import { jsxs, jsx } from 'react/jsx-runtime'; var _excluded = ["style", "indicatorStyle", "label", "icon", "className", "onClose", "disabled", "size", "type", "children"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var SIZES = { small: "small", large: "large" }; var TYPES = { outline: "outline", solid: "solid" }; var STYLES = { primary: "primary", secondary: "secondary", info: "info", success: "success", warning: "warning", danger: "danger" }; var Tag = /*#__PURE__*/forwardRef(function (_ref, ref) { var _ref$style = _ref.style, style = _ref$style === void 0 ? STYLES.primary : _ref$style, indicatorStyle = _ref.indicatorStyle, _ref$label = _ref.label, label = _ref$label === void 0 ? "" : _ref$label, _ref$icon = _ref.icon, icon = _ref$icon === void 0 ? null : _ref$icon, _ref$className = _ref.className, className = _ref$className === void 0 ? "" : _ref$className, _ref$onClose = _ref.onClose, onClose = _ref$onClose === void 0 ? null : _ref$onClose, _ref$disabled = _ref.disabled, disabled = _ref$disabled === void 0 ? false : _ref$disabled, _ref$size = _ref.size, size = _ref$size === void 0 ? SIZES.small : _ref$size, _ref$type = _ref.type, type = _ref$type === void 0 ? TYPES.outline : _ref$type, children = _ref.children, otherProps = _objectWithoutProperties(_ref, _excluded); var Icon = typeof icon === "string" ? function () { return /*#__PURE__*/jsx("i", { className: icon }); } : icon || Fragment; var renderLabel = label || children; return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({ ref: ref, "data-testid": "tag-container", className: classnames("neeto-ui-tag", { "neeto-ui-tag--size-large": size === SIZES.large, "neeto-ui-tag--size-small": size === SIZES.small, "neeto-ui-tag--type-outline": type === TYPES.outline, "neeto-ui-tag--type-solid": type === TYPES.solid, "neeto-ui-tag--style-primary": style === STYLES.primary, "neeto-ui-tag--style-secondary": style === STYLES.secondary, "neeto-ui-tag--style-success": style === STYLES.success, "neeto-ui-tag--style-info": style === STYLES.info, "neeto-ui-tag--style-warning": style === STYLES.warning, "neeto-ui-tag--style-danger": style === STYLES.danger }, className) }, otherProps), {}, { children: [indicatorStyle && /*#__PURE__*/jsx("span", { "data-testid": "tag-indicator", className: classnames("neeto-ui-tag__indicator", { "neeto-ui-bg-error-500": indicatorStyle === STYLES.danger, "neeto-ui-bg-info-500": indicatorStyle === STYLES.info, "neeto-ui-bg-warning-500": indicatorStyle === STYLES.warning, "neeto-ui-bg-success-500": indicatorStyle === STYLES.success, "neeto-ui-bg-primary-500": indicatorStyle === STYLES.primary, "neeto-ui-bg-gray-500": indicatorStyle === STYLES.secondary }) }), icon && /*#__PURE__*/jsx("span", { className: "neeto-ui-tag__icon", "data-testid": "class-icon", children: /*#__PURE__*/jsx(Icon, {}) }), renderLabel, onClose && /*#__PURE__*/jsx("span", { className: "neeto-ui-tag__close", "data-testid": "tag-close-icon", onClick: !disabled ? onClose : null, children: /*#__PURE__*/jsx(Close, {}) })] })); }); Tag.displayName = "Tag"; export { Tag as default }; //# sourceMappingURL=Tag.js.map