{"version":3,"sources":["../src/components/form/textarea.tsx"],"names":["React","Textarea","id","classes","value","rows","cols","name","required","disabled","readOnly","validationState","errorMessage","hintText","onBlur","onPointerDown","onChange","onKeyDown","onEnter","styles","placeholder","props","ref","disabledProps","handlers","useDisabledState","e","isInvalid","describedByIds","ariaDescribedBy","ui_default","textarea_default"],"mappings":"kFAAA,OAAOA,MAAW,QAuCX,IAAMC,EAAWD,EAAM,WAC5B,CACE,CACE,GAAAE,EACA,QAAAC,EACA,MAAAC,EACA,KAAAC,EAAO,EACP,KAAAC,EAAO,GACP,KAAAC,EACA,SAAAC,EACA,SAAAC,EACA,SAAAC,EACA,gBAAAC,EAAkB,OAClB,aAAAC,EACA,SAAAC,EACA,OAAAC,EACA,cAAAC,EACA,SAAAC,EACA,UAAAC,EACA,QAAAC,EACA,OAAAC,EACA,YAAAC,EACA,GAAGC,CACL,EACAC,IACG,CAEH,GAAM,CAAE,cAAAC,EAAe,SAAAC,CAAS,EAAIC,EAClChB,EACA,CACE,SAAU,CACR,SAAAO,EACA,OAAAF,EACA,cAAAC,EACA,UAAYW,GAAgD,CAItDA,EAAE,MAAQ,SAAW,CAACA,EAAE,UAAYR,GACtCA,EAAQQ,CAAC,EAGPT,GACFA,EAAUS,CAAC,CAEf,CACF,EAEA,UAAWvB,CACb,CACF,EAGMwB,EAAYhB,IAAoB,UAGhCiB,EAA2B,CAAC,EAC9BhB,GAAgBV,GAClB0B,EAAe,KAAK,GAAG1B,CAAE,QAAQ,EAE/BW,GAAYX,GACd0B,EAAe,KAAK,GAAG1B,CAAE,OAAO,EAElC,IAAM2B,EACJD,EAAe,OAAS,EAAIA,EAAe,KAAK,GAAG,EAAI,OAEzD,OACE5B,EAAA,cAAC8B,EAAA,CACC,GAAG,WACH,GAAI5B,EACJ,KAAMK,EACN,KAAMF,EACN,KAAMC,EACN,OAAQa,EACR,UAAWI,EAAc,UACzB,aAAW,WACX,SAAUf,EACV,MAAOJ,EACP,gBAAemB,EAAc,eAAe,EAC5C,gBAAef,EACf,eAAcmB,EACd,mBAAkBE,EAClB,SAAUnB,EACT,GAAGc,EACJ,IAAKF,EACL,YAAaF,GAAe,GAAGZ,EAAW,IAAM,EAAE,WACjD,GAAGa,EACN,CAEJ,CACF,EAEApB,EAAS,YAAc,WAEvB,IAAO8B,EAAQ9B","sourcesContent":["import React from 'react'\nimport UI from '../ui'\nimport { useDisabledState } from '../../hooks/use-disabled-state'\n\nexport type { TextareaProps } from './form.types'\nimport type { TextareaProps } from './form.types'\n\n/**\n * Textarea component - Accessible multi-line text input with validation support\n *\n * A flexible textarea component that supports validation states, proper ARIA attributes\n * for accessibility, and an onEnter handler for keyboard interactions. The onEnter handler\n * fires only on Enter without Shift, allowing Shift+Enter to create new lines as expected.\n *\n * @component\n * @example\n * // Basic textarea\n * <Textarea\n *   id=\"message\"\n *   name=\"message\"\n *   placeholder=\"Enter your message\"\n *   required\n * />\n *\n * @example\n * // Textarea with Enter key handler for quick submission\n * <Textarea\n *   id=\"comment\"\n *   name=\"comment\"\n *   onEnter={(e) => handleSubmit()}\n *   placeholder=\"Press Enter to submit, Shift+Enter for new line\"\n * />\n *\n * @param {TextareaProps} props - Component props\n * @returns {JSX.Element} Textarea element with proper accessibility attributes\n *\n * @see {@link https://www.w3.org/WAI/WCAG21/Understanding/keyboard.html|WCAG 2.1.1 Keyboard}\n * @see {@link https://www.w3.org/WAI/WCAG21/Understanding/name-role-value.html|WCAG 4.1.2 Name, Role, Value}\n */\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n  (\n    {\n      id,\n      classes,\n      value,\n      rows = 5,\n      cols = 25,\n      name,\n      required,\n      disabled,\n      readOnly,\n      validationState = 'none',\n      errorMessage,\n      hintText,\n      onBlur,\n      onPointerDown,\n      onChange,\n      onKeyDown,\n      onEnter,\n      styles,\n      placeholder,\n      ...props\n    },\n    ref\n  ) => {\n    // Use the disabled state hook with enhanced API for automatic className merging\n    const { disabledProps, handlers } = useDisabledState<HTMLTextAreaElement>(\n      disabled,\n      {\n        handlers: {\n          onChange,\n          onBlur,\n          onPointerDown,\n          onKeyDown: (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n            // Handle Enter key press for accessibility\n            // Only triggers onEnter when Enter is pressed WITHOUT Shift modifier\n            // This allows Shift+Enter to create new lines as expected\n            if (e.key === 'Enter' && !e.shiftKey && onEnter) {\n              onEnter(e)\n            }\n            // Always call consumer's onKeyDown if provided\n            if (onKeyDown) {\n              onKeyDown(e)\n            }\n          },\n        },\n        // Automatic className merging - hook combines disabled class with user classes\n        className: classes,\n      }\n    )\n\n    // Determine aria-invalid based on validation state\n    const isInvalid = validationState === 'invalid'\n\n    // Generate describedby IDs for error and hint text\n    const describedByIds: string[] = []\n    if (errorMessage && id) {\n      describedByIds.push(`${id}-error`)\n    }\n    if (hintText && id) {\n      describedByIds.push(`${id}-hint`)\n    }\n    const ariaDescribedBy =\n      describedByIds.length > 0 ? describedByIds.join(' ') : undefined\n\n    return (\n      <UI\n        as=\"textarea\"\n        id={id}\n        name={name}\n        rows={rows}\n        cols={cols}\n        styles={styles}\n        className={disabledProps.className}\n        data-style=\"textarea\"\n        required={required}\n        value={value}\n        aria-disabled={disabledProps['aria-disabled']}\n        aria-required={required}\n        aria-invalid={isInvalid}\n        aria-describedby={ariaDescribedBy}\n        readOnly={readOnly}\n        {...handlers}\n        ref={ref}\n        placeholder={placeholder || `${required ? '*' : ''} Message`}\n        {...props}\n      />\n    )\n  }\n)\n\nTextarea.displayName = 'Textarea'\n\nexport default Textarea\n"]}