{"version":3,"file":"Label.mjs","sources":["../../../src/components/Label/Label.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport type { ReactNode } from 'react';\nimport React from 'react';\n\nimport { assertEdsUsage } from '../../util/logging';\nimport Text from '../Text';\nimport styles from './Label.module.css';\n\nexport type LabelProps = {\n  /**\n   * CSS class names that can be appended to the component.\n   */\n  className?: string;\n  /**\n   * Indicates disabled state of the input.\n   */\n  disabled?: boolean;\n  /**\n   * HTML `for` attribute, which maps the label to an associated input `id`\n   */\n  htmlFor?: string;\n  /**\n   * HTML id for the component\n   */\n  id?: string;\n  /**\n   * Slot for node to appear directly after field label. Typically used to include a Toolip\n   */\n  labelAfter?: ReactNode;\n  /**\n   * **Deprecated.** Has no effect: it renders no indicator and sets no attribute. Mark the\n   * associated input as required instead.\n   *\n   * @deprecated TODO(next-major): remove.\n   */\n  required?: boolean;\n  /**\n   * The label text string\n   */\n  text: ReactNode;\n};\n\n/**\n * ## Usage\n *\n * Text styling used for selection controls like `Radio` and `Checkbox`. This component should not\n * generally be used, except on custom radio or checkbox components.\n *\n * Pair `htmlFor` with the control's `id` so the label and the control are associated. `Radio.Label`\n * is this component, and `Checkbox` and `Toggle` render it for you.\n *\n * `labelAfter` is a trailing slot beside the label text, typically used for a `Tooltip`.\n */\nexport const Label = ({\n  className,\n  disabled,\n  htmlFor,\n  id,\n  labelAfter,\n  required,\n  text,\n  ...other\n}: LabelProps) => {\n  const componentClassName = clsx(\n    styles['label'],\n    disabled && styles['label--disabled'],\n    className,\n  );\n\n  assertEdsUsage(\n    [typeof required !== 'undefined'],\n    'the required prop has been deprecated, has no effect, and will be removed from the next major version of EDS',\n  );\n\n  return (\n    <label className={componentClassName} htmlFor={htmlFor} id={id} {...other}>\n      <Text as=\"span\" preset=\"body-md\">\n        {text}\n      </Text>{' '}\n      {labelAfter && (\n        <Text as=\"span\" preset=\"body-sm\">\n          {labelAfter}\n        </Text>\n      )}\n    </label>\n  );\n};\n\nLabel.displayName = 'Label';\n"],"names":["React"],"mappings":";;;;;;AA0CA;;;;;;;;;;AAUG;AACI,MAAM,KAAK,GAAG,CAAC,EACpB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,EAAE,EACF,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,GAAG,KAAK,EACG,KAAI;AACf,IAAA,MAAM,kBAAkB,GAAG,IAAI,CAC7B,MAAM,CAAC,OAAO,CAAC,EACf,QAAQ,IAAI,MAAM,CAAC,iBAAiB,CAAC,EACrC,SAAS,CACV;IAED,cAAc,CACZ,CAAC,OAAO,QAAQ,KAAK,WAAW,CAAC,EACjC,8GAA8G,CAC/G;AAED,IAAA,QACEA,cAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,SAAS,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,KAAM,KAAK,EAAA;QACvEA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAC,MAAM,EAAC,MAAM,EAAC,SAAS,EAAA,EAC7B,IAAI,CACA;QAAC,GAAG;AACV,QAAA,UAAU,KACTA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAC,MAAM,EAAC,MAAM,EAAC,SAAS,EAAA,EAC7B,UAAU,CACN,CACR,CACK;AAEZ;AAEA,KAAK,CAAC,WAAW,GAAG,OAAO;;"}