carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 2.47 kB
JavaScript
import{jsxs as e,jsx as r}from"react/jsx-runtime";import"react";import t from"./pill.style.js";import o from"../icon/icon.component.js";import n from"../../__internal__/utils/helpers/tags/tags.js";import l from"../../__internal__/utils/logger/index.js";import i from"../icon-button/icon-button.component.js";import a from"../../hooks/__internal__/useLocale/useLocale.js";function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}let s=!1;const u=u=>{var{wrapText:p,borderColor:b,colorVariant:f="neutral",isDarkBackground:m=!1,children:O,fill:y=!1,maxWidth:d,onClick:j,onDelete:g,pillRole:h="tag",size:k="M",ariaLabelOfRemoveButton:w}=u,v=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},l=Object.keys(e);for(o=0;o<l.length;o++)t=l[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)t=l[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(u,["wrapText","borderColor","colorVariant","isDarkBackground","children","fill","maxWidth","onClick","onDelete","pillRole","size","ariaLabelOfRemoveButton"]);const P=a();return s||m||"neutralWhite"!==f||y||(s=!0,l.warn("[WARNING] The `neutralWhite` variant should only be used on dark backgrounds with fill set to true. Please set the `isDarkBackground` and `fill` props to true or use another color variant.")),e(t,(_=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){c(e,r,t[r])}))}return e}({inFill:y,colorVariant:f,isDarkBackground:m,isDeletable:!!g,pillRole:h,size:k,borderColor:b,onClick:j,maxWidth:d,wrapText:p},v,n("pill",v)),x=null!=(x={children:[O,g&&r(i,{onClick:g,"data-element":"close","aria-label":w||P.pill.remove(O),children:r(o,{type:"cross"})})]})?x:{},Object.getOwnPropertyDescriptors?Object.defineProperties(_,Object.getOwnPropertyDescriptors(x)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(x)).forEach((function(e){Object.defineProperty(_,e,Object.getOwnPropertyDescriptor(x,e))})),_));var _,x};export{u as Pill,u as default};