{"version":3,"file":"FieldLabel.mjs","sources":["../../../src/components/FieldLabel/FieldLabel.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, { type ReactNode } from 'react';\nimport type { Size } from '../../util/variant-types';\nimport Text from '../Text';\n\nimport styles from './FieldLabel.module.css';\n\nexport type FieldLabelProps = {\n  // Component API\n  /**\n   * Text to render in label.\n   */\n  children: ReactNode;\n  /**\n   * ID of the element\n   */\n  id?: string;\n  /**\n   * Additional classnames passed in for styling.\n   */\n  className?: string;\n  /**\n   * ID of input that label is associated with.\n   */\n  htmlFor?: string;\n  // Design API\n  /**\n   * Indicates disabled state of the input.\n   */\n  disabled?: boolean;\n  /**\n   * Size of the label.\n   *\n   * **Default is `\"lg\"`**.\n   */\n  size?: Extract<Size, 'sm' | 'md' | 'lg'>;\n};\n\n/**\n * ## Usage\n *\n * `FieldLabel` is used to add a label to EDS's controls (e.g., `InputField`, `TextareaField`,\n * `Select`, `Combobox`). This component should not be used in isolation, but can be used to label\n * any custom input controls.\n *\n * Pair `htmlFor` with the control's `id` so the label and the control are associated. The EDS\n * controls that render a label for you also expose it as a subcomponent, so `InputField.Label` and\n * `TextareaField.Label` are this component.\n *\n * For guidance on how to word a label, see the do's and don'ts on the control itself (for example,\n * `InputField`).\n */\nexport const FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(\n  ({ children, className, htmlFor, size = 'lg', disabled, ...other }, ref) => {\n    const componentClassName = clsx(\n      styles['label'],\n      size && styles[`label--${size}`],\n      disabled && styles['label--disabled'],\n      className,\n    );\n    return (\n      <label\n        aria-disabled={disabled ?? undefined}\n        className={componentClassName}\n        htmlFor={htmlFor}\n        ref={ref}\n        {...other}\n      >\n        <Text as=\"span\" preset={`label-${size}`}>\n          {children}\n        </Text>\n      </label>\n    );\n  },\n);\n\nFieldLabel.displayName = 'FieldLabel';\n"],"names":["React"],"mappings":";;;;;AAsCA;;;;;;;;;;;;;AAaG;AACI,MAAM,UAAU,GAAGA,cAAK,CAAC,UAAU,CACxC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;IACzE,MAAM,kBAAkB,GAAG,IAAI,CAC7B,MAAM,CAAC,OAAO,CAAC,EACf,IAAI,IAAI,MAAM,CAAC,CAAA,OAAA,EAAU,IAAI,CAAA,CAAE,CAAC,EAChC,QAAQ,IAAI,MAAM,CAAC,iBAAiB,CAAC,EACrC,SAAS,CACV;IACD,QACEA,yDACiB,QAAQ,KAAA,IAAA,IAAR,QAAQ,KAAA,MAAA,GAAR,QAAQ,GAAI,SAAS,EACpC,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EAAA,GACJ,KAAK,EAAA;AAET,QAAAA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAC,MAAM,EAAC,MAAM,EAAE,CAAA,MAAA,EAAS,IAAI,EAAE,EAAA,EACpC,QAAQ,CACJ,CACD;AAEZ,CAAC;AAGH,UAAU,CAAC,WAAW,GAAG,YAAY;;"}