{"version":3,"file":"TagBase.mjs","names":[],"sources":["../../../src/tag-base/TagBase.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 { tokens } from '@neo4j-ndl/base';\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport { type CommonProps } from '../_common/types';\n\nexport type TagSize = 'x-small' | 'small' | 'medium' | 'large';\n\nexport const CategoricalColors = [\n  '1',\n  '2',\n  '3',\n  '4',\n  '5',\n  '6',\n  '7',\n  '8',\n] as const;\n\nexport type TagColor = (typeof CategoricalColors)[number];\n\nexport interface TagBaseProps {\n  /** Categorical color for the background */\n  color?: TagColor;\n  /** The content of the tag */\n  children: React.ReactNode;\n  /** Id applied to the content element used for aria-describedby on actions */\n  contentId?: string;\n  /** Icon to display before the content */\n  leadingVisual?: React.ReactNode;\n  /** Size of the tag */\n  size?: TagSize;\n  /** Trailing content rendered after the content (e.g. a remove button) */\n  trailingContent?: React.ReactNode;\n}\n\nexport const colorMap: Record<\n  TagColor,\n  {\n    '--tag-background-color': string;\n    '--tag-text-color': string;\n  }\n> = {\n  '1': {\n    '--tag-background-color': tokens.categorical[1],\n    '--tag-text-color': '#000',\n  },\n  '2': {\n    '--tag-background-color': tokens.categorical[2],\n    '--tag-text-color': '#fff',\n  },\n  '3': {\n    '--tag-background-color': tokens.categorical[3],\n    '--tag-text-color': '#000',\n  },\n  '4': {\n    '--tag-background-color': tokens.categorical[4],\n    '--tag-text-color': '#000',\n  },\n  '5': {\n    '--tag-background-color': tokens.categorical[5],\n    '--tag-text-color': '#000',\n  },\n  '6': {\n    '--tag-background-color': tokens.categorical[6],\n    '--tag-text-color': '#000',\n  },\n  '7': {\n    '--tag-background-color': tokens.categorical[7],\n    '--tag-text-color': '#000',\n  },\n  '8': {\n    '--tag-background-color': tokens.categorical[8],\n    '--tag-text-color': '#fff',\n  },\n};\n\nexport const TagBase = ({\n  size = 'medium',\n  color,\n  children,\n  className,\n  contentId,\n  htmlAttributes,\n  leadingVisual,\n  trailingContent,\n  ref,\n  style,\n  ...restProps\n}: CommonProps<'div', TagBaseProps>) => {\n  const classes = classNames('ndl-tag-new', className, {\n    'ndl-large': size === 'large',\n    'ndl-medium': size === 'medium',\n    'ndl-small': size === 'small',\n    'ndl-tag-colored': Boolean(color),\n    'ndl-x-small': size === 'x-small',\n  });\n\n  const styles = {\n    ...style,\n    ...(color ? colorMap[color] : {}),\n  } as React.CSSProperties;\n\n  return (\n    <div\n      className={classes}\n      ref={ref}\n      style={styles}\n      {...htmlAttributes}\n      {...restProps}\n    >\n      {Boolean(leadingVisual) && (\n        <div className=\"ndl-tag-leading-element\">{leadingVisual}</div>\n      )}\n      <span className=\"ndl-tag-content\" id={contentId}>\n        {children}\n      </span>\n      {trailingContent}\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AA/EF,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAmBA,MAAa,WAMT;CACF,KAAK;EACH,0BAA0B,OAAO,YAAY;EAC7C,oBAAoB;CACtB;CACA,KAAK;EACH,0BAA0B,OAAO,YAAY;EAC7C,oBAAoB;CACtB;CACA,KAAK;EACH,0BAA0B,OAAO,YAAY;EAC7C,oBAAoB;CACtB;CACA,KAAK;EACH,0BAA0B,OAAO,YAAY;EAC7C,oBA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