{"version":3,"file":"StatusLabel.mjs","names":["SquareIcon","CircleIcon","RhombusIcon","TriangleIcon"],"sources":["../../../src/status-label/StatusLabel.tsx"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport CircleIcon from '../icons/generated/custom/Circle';\nimport RhombusIcon from '../icons/generated/custom/Rhombus';\nimport SquareIcon from '../icons/generated/custom/Square';\nimport TriangleIcon from '../icons/generated/custom/Triangle';\n\n/**\n *\n *\n * Types\n *\n *\n */\n\ntype EventTypeStatusLabelProps = {\n  /** Additional Classnames */\n  className?: string;\n\n  /** The content displayed inside the status label */\n  children: React.ReactNode;\n\n  /** Color of the status label that indicates its purpose. */\n  variant?: (typeof StatusLabelVariants)[number];\n\n  /** Fill type of status label, determines the background and border styles. */\n  fill?: (typeof StatusLabelFill)[number];\n\n  /** Whether the status label have an icon */\n  hasIcon?: boolean;\n\n  /** Size of the status label */\n  size?: 'small' | 'large';\n};\n\nconst StatusLabelVariants = [\n  'info',\n  'success',\n  'warning',\n  'danger',\n  'default',\n  'discovery',\n] as const;\n\nconst StatusLabelFill = ['filled', 'outlined', 'semi-filled', 'clean'] as const;\n\nexport const StatusLabel = <T extends React.ElementType = 'span'>({\n  as,\n  variant = 'default',\n  children,\n  className,\n  style,\n  fill = 'filled',\n  hasIcon = false,\n  htmlAttributes,\n  size = 'large',\n  ref,\n  ...restProps\n}: PolymorphicCommonProps<T, EventTypeStatusLabelProps>) => {\n  let icon: React.ReactNode | null;\n\n  // Clean Status label without icon is not allowed\n  if (!hasIcon && fill === 'clean') {\n    console.error('Clean StatusLabel has to have an icon');\n  }\n\n  // All colors map to the light-theme palette except the info\n  const mappedColor = variant === 'info' ? 'primary' : variant;\n\n  if (hasIcon) {\n    const isFilled = fill === 'filled';\n    if (mappedColor === 'default') {\n      const fillColor = isFilled\n        ? 'currentColor'\n        : 'var(--theme-color-neutral-bg-status)';\n      icon = <SquareIcon htmlAttributes={{ color: fillColor }} />;\n    } else if (mappedColor === 'primary') {\n      const fillColor = isFilled\n        ? 'currentColor'\n        : 'var(--theme-color-primary-bg-status)';\n      icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n    } else if (mappedColor === 'success') {\n      const fillColor = isFilled\n        ? 'currentColor'\n        : 'var(--theme-color-success-bg-status)';\n      icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n    } else if (mappedColor === 'danger') {\n      const fillColor = isFilled\n        ? 'currentColor'\n        : 'var(--theme-color-danger-bg-status)';\n      icon = <RhombusIcon htmlAttributes={{ color: fillColor }} />;\n    } else if (mappedColor === 'warning') {\n      const fillColor = isFilled\n        ? 'currentColor'\n        : 'var(--theme-color-warning-bg-status)';\n      icon = <TriangleIcon htmlAttributes={{ color: fillColor }} />;\n    } else if (mappedColor === 'discovery') {\n      const fillColor = isFilled\n        ? 'currentColor'\n        : 'var(--theme-color-discovery-bg-status)';\n      icon = <CircleIcon htmlAttributes={{ color: fillColor }} />;\n    }\n  }\n\n  const classes = classNames(\n    'ndl-status-label',\n    `ndl-status-label-${variant}`,\n    className,\n    {\n      'ndl-clean': fill === 'clean',\n      'ndl-filled': fill === 'filled',\n      'ndl-large': size === 'large',\n      'ndl-outlined': fill === 'outlined',\n      'ndl-semi-filled': fill === 'semi-filled',\n      'ndl-small': size === 'small',\n    },\n  );\n\n  const Component: React.ElementType = as ?? 'span';\n\n  return (\n    <Component\n      role=\"status\"\n      className={classes}\n      style={style}\n      ref={ref}\n      {...restProps}\n      {...htmlAttributes}\n    >\n      <div className=\"ndl-status-label-content\">\n        {icon}\n        <span\n          // To enable native tooltip on hover if the children is a string\n          title={typeof children === 'string' ? children : 'status label'}\n          className=\"ndl-status-label-text\"\n        >\n          {children}\n        </span>\n      </div>\n    </Component>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAVF,MAAa,eAAqD,SAYN;CAZM,IAAA,EAChE,IACA,UAAU,WACV,UACA,WACA,OACA,OAAO,UACP,UAAU,OACV,gBACA,OAAO,SACP,QAAA,MACG,YAAA,yBAAA,MAAA,SAAA;CAEH,IAAI;CAGJ,IAAI,CAAC,WAAW,SAAS,SACvB,QAAQ,MAAM,uCAAuC;CAIvD,MAAM,cAAc,YAAY,SAAS,YAAY;CAErD,IAAI,SAAS;EACX,MAAM,WAAW,SAAS;EAC1B,IAAI,gBAAgB,WAIlB,OAAO,oBAACA,WAAD,EAAY,gBAAgB,EAAE,OAHnB,WACd,iBACA,uCACkD,EAAI,CAAA;OACrD,IAAI,gBAAgB,WAIzB,OAAO,oBAACC,WAAD,EAAY,gBAAgB,EAAE,OAHnB,WACd,iBACA,uCACkD,EAAI,CAAA;OACrD,IAAI,gBAAgB,WAIzB,OAAO,oBAACA,WAAD,EAAY,gBAAgB,EAAE,OAHnB,WACd,iBACA,uCACkD,EAAI,CAAA;OACrD,IAAI,gBAAgB,UAIzB,OAAO,oBAACC,YAAD,EAAa,gBAAgB,EAAE,OAHpB,WACd,iBACA,sCACmD,EAAI,CAAA;OACtD,IAAI,gBAAgB,WAIzB,OAAO,oBAACC,aAAD,EAAc,gBAAgB,EAAE,OAHrB,WACd,iBACA,uCACoD,EAAI,CAAA;OACvD,IAAI,gBAAgB,aAIzB,OAAO,oBAACF,WAAD,EA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