{"version":3,"file":"components/Badge/index.mjs","sources":["../../../src/components/Badge/index.tsx"],"sourcesContent":["import { Tooltip } from 'antd';\nimport React from 'react';\n\nexport enum BadgeType {\n  Default = 'default',\n  Success = 'success',\n  Warn = 'warn',\n  Error = 'error',\n}\n\nexport const BadgeColorMap = {\n  [BadgeType.Default]: 'linear-gradient(to bottom, #3ea2ff 0%, #0072db 100%)',\n  [BadgeType.Success]: 'linear-gradient(to bottom, #6cf42a 0%, #52C41A 100%)',\n  [BadgeType.Warn]: 'linear-gradient(to bottom, #ffc100 0%, #f59025 100%)',\n  [BadgeType.Error]: `linear-gradient(to bottom, rgb(250 127 22), #FF4D4F 100%)`,\n};\n\ninterface BadgeProps {\n  label: string | number | React.ReactNode;\n  value: string | number | React.ReactNode;\n  type?: BadgeType | `${BadgeType}`;\n  tooltip?: true | string | React.ReactNode;\n}\n\nexport const Badge: React.FC<BadgeProps> = ({ label, value, type = 'default', tooltip }) => {\n  const height = 22;\n\n  const borderRadius = 4;\n\n  const commonStyle: React.CSSProperties = {\n    height: '100%',\n    lineHeight: `${height}px`,\n    width: 'auto',\n    display: 'inline-block',\n    boxSizing: 'border-box',\n    padding: `0 6px`,\n    color: '#fff',\n    fontSize: 12,\n    textAlign: 'center',\n    verticalAlign: 'middle',\n  };\n\n  const Content = (\n    <div\n      style={{\n        height,\n        margin: 0,\n        padding: 0,\n        boxSizing: 'border-box',\n        borderRadius: 4,\n        fontSize: 0,\n        whiteSpace: 'nowrap',\n        textOverflow: 'ellipsis',\n        overflow: 'hidden',\n        display: 'flex',\n        justifyContent: 'flex-start',\n        alignItems: 'center',\n      }}\n    >\n      <div\n        style={{\n          ...commonStyle,\n          borderTopLeftRadius: borderRadius,\n          borderBottomLeftRadius: borderRadius,\n          background: 'linear-gradient(to bottom, #525252a3 0%, #1F1F1F 100%)',\n        }}\n      >\n        {label}\n      </div>\n      <div\n        style={{\n          ...commonStyle,\n          borderTopRightRadius: borderRadius,\n          borderBottomRightRadius: borderRadius,\n          overflow: 'hidden',\n          textOverflow: 'ellipsis',\n          background: BadgeColorMap[type] || BadgeColorMap[BadgeType.Default],\n        }}\n      >\n        {value}\n      </div>\n    </div>\n  );\n\n  if (tooltip) {\n    return (\n      <Tooltip title={tooltip === true ? value : tooltip} placement=\"topLeft\">\n        {Content}\n      </Tooltip>\n    );\n  }\n\n  return Content;\n};\n"],"names":["BadgeType","BadgeColorMap","Badge","label","value","type","tooltip","height","borderRadius","commonStyle","Content","Tooltip"],"mappings":";;;AAGO,IAAKA,kBAASA,WAAAA,GAAAA,SAATA,SAAS;;;;;WAATA;;AAOL,MAAMC,gBAAgB;IAC3B,CAAC,UAAkB,EAAE;IACrB,CAAC,UAAkB,EAAE;IACrB,CAAC,OAAe,EAAE;IAClB,CAAC,QAAgB,EAAE;AACrB;AASO,MAAMC,QAA8B,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAEC,OAAO,SAAS,EAAEC,OAAO,EAAE;IACrF,MAAMC,SAAS;IAEf,MAAMC,eAAe;IAErB,MAAMC,cAAmC;QACvC,QAAQ;QACR,YAAY,GAAGF,OAAO,EAAE,CAAC;QACzB,OAAO;QACP,SAAS;QACT,WAAW;QACX,SAAS;QACT,OAAO;QACP,UAAU;QACV,WAAW;QACX,eAAe;IACjB;IAEA,MAAMG,UAAU,WAAVA,GACJ,KAAC;QACC,OAAO;YACLH;YACA,QAAQ;YACR,SAAS;YACT,WAAW;YACX,cAAc;YACd,UAAU;YACV,YAAY;YACZ,cAAc;YACd,UAAU;YACV,SAAS;YACT,gBAAgB;YAChB,YAAY;QACd;;0BAEA,IAAC;gBACC,OAAO;oBACL,GAAGE,WAAW;oBACd,qBAAqBD;oBACrB,wBAAwBA;oBACxB,YAAY;gBACd;0BAECL;;0BAEH,IAAC;gBACC,OAAO;oBACL,GAAGM,WAAW;oBACd,sBAAsBD;oBACtB,yBAAyBA;oBACzB,UAAU;oBACV,cAAc;oBACd,YAAYP,aAAa,CAACI,KAAK,IAAIJ,aAAa,CAAC,UAAkB;gBACrE;0BAECG;;;;IAKP,IAAIE,SACF,OAAO,WAAP,GACE,IAACK,SAAOA;QAAC,OAAOL,AAAY,SAAZA,UAAmBF,QAAQE;QAAS,WAAU;kBAC3DI;;IAKP,OAAOA;AACT"}