{"version":3,"file":"InputChip.mjs","sources":["../../../src/components/InputChip/InputChip.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, { type MouseEventHandler } from 'react';\nimport type { IconOrContent } from '../../util/utility-types';\nimport type { Size } from '../../util/variant-types';\nimport { hasSlotContent, IconSlot, useSemanticIcon } from '../Icon';\nimport Text from '../Text';\n\nimport styles from './InputChip.module.css';\n\nexport type InputChipProps = {\n  // Component API\n  /**\n   * CSS class names that can be appended to the component.\n   */\n  className?: string;\n  // Design API\n  /**\n   * Whether the chip is in a non-interactive, disabled state\n   */\n  isDisabled?: boolean;\n  /**\n   * Text used in the chip to give it a description\n   */\n  label: string;\n  /**\n   * Leading slot for the chip. Takes an EDS icon name, or any content to render in its\n   * place at the chip's own type size.\n   */\n  leadingComponent?: IconOrContent;\n  /**\n   * click handler for the action button on the chip (ex: to dismiss or remove the chip from the screen)\n   */\n  onClick?: MouseEventHandler;\n  /**\n   * The display size of the chip\n   */\n  size?: Extract<Size, 'sm' | 'md'>;\n};\n\n/**\n * ## Usage\n *\n * | Type/Use | Description | Example |\n * |----------|-------------|---------|\n * | Input | A chip that represents user-generated input and can be edited or removed. | Displaying selected tags, keywords, or values in a form or input field, or combining multiple pieces of data such as a name and avatar. |\n *\n * ### Best Practices\n *\n * * **Displaying multi-selection from a large list**: show selections already made without reopening a long select dropdown. Input chips are most helpful when the list of options exceeds 15 items.\n * * **Representing search filters or criteria**: show active filters or search parameters to make complex filtering feel organized and easily editable.\n * * **Handling user-generated or free-form data**: transform user-entered text (e.g., email addresses) into a discrete component that confirms the UI recognizes the input.\n *\n * ## Interaction\n *\n * Unless used as a toggle, chips should always be presented as a group. Depending on the use, groups can either wrap to multiple lines or scroll horizontally.\n *\n * ## Content & Accessibility\n *\n * ### Do's\n *\n * * Keep labels to 1-2 words.\n * * Represent one piece of information per chip (a discrete thing, grouping, or category).\n */\nexport const InputChip = ({\n  className,\n  isDisabled,\n  label,\n  leadingComponent,\n  onClick,\n  size = 'md',\n  ...other\n}: InputChipProps) => {\n  const componentClassName = clsx(\n    styles['input-chip'],\n    isDisabled && styles[`input-chip--disabled`],\n    className,\n  );\n\n  // The chip's action button is semantic: it is the same close affordance as every other\n  // one in the app, so it is set once through `IconProvider` rather than per chip. The\n  // leading slot above is the consumer's to fill, and is left alone.\n  const closeIcon = useSemanticIcon('close');\n\n  return (\n    <div className={componentClassName} {...other}>\n      <div className={styles['input-chip__label']}>\n        {hasSlotContent(leadingComponent) && (\n          <IconSlot content={leadingComponent} purpose=\"decorative\" />\n        )}\n        <Text as=\"span\" preset=\"body-xs\">\n          {label}\n        </Text>\n      </div>\n      <button\n        // The name belongs on the button rather than on the icon inside it. An\n        // `IconProvider` can set `close` to a node, and `IconSlot` leaves custom content's\n        // accessible treatment to whoever passed it, so a name carried by the icon would\n        // disappear the moment an app overrode the role and leave this button unnamed.\n        aria-label={`remove ${label}`}\n        className={styles['input-chip__action-button']}\n        disabled={isDisabled}\n        onClick={onClick}\n      >\n        {hasSlotContent(closeIcon) && (\n          <IconSlot content={closeIcon} purpose=\"decorative\" />\n        )}\n      </button>\n    </div>\n  );\n};\n\nInputChip.displayName = 'InputChip';\n"],"names":["React"],"mappings":";;;;;;;;AAuCA;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACI,MAAM,SAAS,GAAG,CAAC,EACxB,SAAS,EACT,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,IAAI,GAAG,IAAI,EACX,GAAG,KAAK,EACO,KAAI;AACnB,IAAA,MAAM,kBAAkB,GAAG,IAAI,CAC7B,MAAM,CAAC,YAAY,CAAC,EACpB,UAAU,IAAI,MAAM,CAAC,CAAA,oBAAA,CAAsB,CAAC,EAC5C,SAAS,CACV;;;;AAKD,IAAA,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC;AAE1C,IAAA,QACEA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,kBAAkB,KAAM,KAAK,EAAA;AAC3C,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