{"version":3,"file":"SelectableTag.mjs","names":[],"sources":["../../../src/selectable-tag/SelectableTag.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 CommonProps } from '../_common/types';\nimport type { TagSize } from '../tag-base';\n\nexport interface SelectableTagProps {\n  /** The content of the tag */\n  children?: React.ReactNode;\n  /** Whether the tag is disabled */\n  isDisabled?: boolean;\n  /** Whether the tag is selected */\n  isSelected: boolean;\n  /** Number displayed in a badge after the content */\n  badgeCount?: number;\n  /** Icon to display before the content */\n  leadingVisual?: React.ReactNode;\n  /** Size of the tag */\n  size?: TagSize;\n  /** Callback fired when the tag is clicked */\n  onClick: React.MouseEventHandler<HTMLButtonElement>;\n}\n\nexport const SelectableTag = ({\n  children,\n  className,\n  htmlAttributes,\n  isSelected,\n  badgeCount,\n  leadingVisual,\n  onClick,\n  ref,\n  isDisabled = false,\n  size = 'medium',\n  style,\n  ...restProps\n}: CommonProps<'button', SelectableTagProps>) => {\n  const classes = classNames('ndl-tag-selectable', className, {\n    'ndl-disabled': isDisabled,\n    'ndl-large': size === 'large',\n    'ndl-medium': size === 'medium',\n    'ndl-small': size === 'small',\n    'ndl-tag-selected': isSelected,\n    'ndl-x-small': size === 'x-small',\n  });\n\n  return (\n    <button\n      type=\"button\"\n      aria-pressed={isSelected}\n      className={classes}\n      disabled={isDisabled}\n      onClick={onClick}\n      ref={ref}\n      style={style}\n      {...htmlAttributes}\n      {...restProps}\n    >\n      {Boolean(leadingVisual) && (\n        <span className=\"ndl-selectable-tag-leading-visual\">\n          {leadingVisual}\n        </span>\n      )}\n      <span className=\"ndl-selectable-tag-content\">{children}</span>\n      {badgeCount !== undefined && (\n        <span className=\"ndl-selectable-tag-badge\">{badgeCount}</span>\n      )}\n    </button>\n  );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;CA4CE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAXF,MAAa,iBAAiB,SAamB;CAbnB,IAAA,EAC5B,UACA,WACA,gBACA,YACA,YACA,eACA,SACA,KACA,aAAa,OACb,OAAO,UACP,UAAA,MACG,YAAA,yBAAA,MAAA,SAAA;CAEH,MAAM,UAAU,WAAW,sBAAsB,WAAW;EAC1D,gBAAgB;EAChB,aAAa,SAAS;EACtB,cAAc,SAAS;EACvB,aAAa,SAAS;EACtB,oBAAoB;EACpB,eAAe,SAAS;CAC1B,CAAC;CAED,OACE,qBAAC,UAAA,eAAA,eAAA,eAAA;EACC,MAAK;EACL,gBAAc;EACd,WAAW;EACX,UAAU;EACD;EACJ;EACE;CACH,GAAA,cAAA,GACA,SAAA,GAAA,CAAA,GAAA,EAAA,UATN;EAWG,QAAQ,aAAa,KACpB,oBAAC,QAAD;GAAM,WAAU;GACb,UAAA;EACG,CAAA;EAER,oBAAC,QAAD;GAAM,WAAU;GAA8B;EAAe,CAAA;EAC5D,eAAe,KAAA,KACd,oBAAC,QAAD;GAAM,WAAU;GAA4B,UAAA;EAAiB,CAAA;CAEzD,EAAA,CAAA,CAAA;AAEZ"}