{"version":3,"file":"Tag.mjs","sources":["../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React from 'react';\nimport { assertEdsUsage } from '../../util/logging';\nimport type { IconOrContent } from '../../util/utility-types';\nimport type { Emphasis, Status } from '../../util/variant-types';\n\nimport { hasSlotContent, IconSlot } from '../Icon';\nimport { InternalText } from '../Text/Text';\n\nimport styles from './Tag.module.css';\n\ntype Props = {\n  // Component API\n  /**\n   * CSS class names that can be appended to the component for styling.\n   */\n  className?: string;\n  /**\n   * CSS properties defined for the HTML element. Includes the component's CSS Custom Properties:\n   *\n   * - `--tag__bg`\n   * - `--tag__border`\n   * - `--tag__fg`\n   */\n  style?: TagCSSProperties;\n  // Design API\n  /**\n   * Controls how much the tag stands out. **NOTE**: emphasis can only be set to \"low\" when status is \"informational\".\n   *\n   * **Default is `\"high\"`**.\n   */\n  emphasis?: Emphasis;\n  /**\n   * Leading slot for the tag. Takes an EDS icon name, or any content to render in its\n   * place at 16px.\n   */\n  icon?: IconOrContent;\n  /**\n   * The text contents of the tag, nested inside the component.\n   */\n  label?: string;\n  /**\n   * Status for the component state\n   */\n  status?: Status;\n};\n\nexport interface TagCSSProperties extends React.CSSProperties {\n  /**\n   * Custom property to customize the background color of this component (e.g., background color)\n   */\n  '--tag__bg'?: string;\n\n  /**\n   * Custom property to customize the border color of this component\n   */\n  '--tag__border'?: string;\n\n  /**\n   * Custom property to customize the foreground color of this component (e.g., text, icon, etc.)\n   */\n  '--tag__fg'?: string;\n}\n\n/**\n * ## Usage\n *\n * | Type/Use | Description | Example |\n * |----------|-------------|---------|\n * | State indicators | Shows the current status of an item or process. | A green \"Active\" tag for a user profile. |\n * | Availability | Indicates if something is available or not. | \"Available\" or \"Unavailable\" tag for a product. |\n * | Progress / Workflow | Marks the stage in a workflow or pipeline. | \"In Review,\" \"Draft,\" or \"Completed\" tags for a document. |\n * | Urgency / Priority | Highlights critical items needing attention. | \"High Priority\" or \"Urgent\" tag in a task list. |\n * | Validation status | Shows whether an item passed or failed validation. | \"Valid\" or \"Error\" status tags for form inputs. |\n * | New or updated content | Marks new or recently changed items. | A \"New\" or \"Updated\" tag for an article or notification. |\n *\n * ### Best Practices\n *\n * * Use short labels, keeping them to 1-2 words since tags represent discrete pieces of information.\n * * When using multiple tags together, separate them with 16px of space.\n * * Use tag status variants that are appropriate for the tag's content.\n * * Don't use tags solely for their colors or in a semantically incorrect way. If you need color-coded tags that are not tied to a particular status, reach out to EDS.\n *\n * ## Content & Accessibility\n *\n * ### Do's\n *\n * * Keep labels to 1-2 words.\n * * Remember that tags represent discrete pieces of information.\n *\n * ### Don'ts\n *\n * * Don't overload users with excessive content, which increases cognitive load.\n * * Don't rely on just color to communicate status—add text or icons.\n */\nexport const Tag = ({\n  className,\n  emphasis = 'high',\n  icon,\n  label,\n  status = 'informational',\n  style,\n}: Props) => {\n  const componentClassName = clsx(\n    styles['tag'],\n    emphasis && styles[`tag--emphasis-${emphasis}`],\n    status && styles[`tag--status-${status}`],\n    className,\n  );\n\n  assertEdsUsage(\n    [status !== 'informational' && emphasis === 'low'],\n    'Emphasis can only be set to low when status is \"informational\"',\n  );\n\n  return (\n    <InternalText\n      as=\"span\"\n      className={componentClassName}\n      preset=\"tag\"\n      style={style}\n    >\n      {hasSlotContent(icon) && (\n        <IconSlot content={icon} purpose=\"decorative\" size=\"16px\" />\n      )}\n      {label && <span className={styles['tag__body']}>{label}</span>}\n    </InternalText>\n  );\n};\n\nTag.displayName = 'Tag';\n"],"names":["React"],"mappings":";;;;;;;;;AAgEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;MACU,GAAG,GAAG,CAAC,EAClB,SAAS,EACT,QAAQ,GAAG,MAAM,EACjB,IAAI,EACJ,KAAK,EACL,MAAM,GAAG,eAAe,EACxB,KAAK,GACC,KAAI;AACV,IAAA,MAAM,kBAAkB,GAAG,IAAI,CAC7B,MAAM,CAAC,KAAK,CAAC,EACb,QAAQ,IAAI,MAAM,CAAC,CAAA,cAAA,EAAiB,QAAQ,CAAA,CAAE,CAAC,EAC/C,MAAM,IAAI,MAAM,CAAC,CAAA,YAAA,EAAe,MAAM,CAAA,CAAE,CAAC,EACzC,SAAS,CACV;AAED,IAAA,cAAc,CACZ,CAAC,MAAM,KAAK,eAAe,IAAI,QAAQ,KAAK,KAAK,CAAC,EAClD,gEAAgE,CACjE;AAED,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,YAAY,IACX,EAAE,EAAC,MAAM,EACT,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAC,KAAK,EACZ,KAAK,EAAE,KAAK,EAAA;QAEX,cAAc,CAAC,IAAI,CAAC,KACnBA,cAAA,CAAA,aAAA,CAAC,QAAQ,IAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,YAAY,EAAC,IAAI,EAAC,MAAM,GAAG,CAC7D;AACA,QAAA,KAAK,IAAIA,cAAA,CAAA,aAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,EAAA,EAAG,KAAK,CAAQ,CACjD;AAEnB;AAEA,GAAG,CAAC,WAAW,GAAG,KAAK;;"}