{"version":3,"file":"TextArea.mjs","sources":["../../../src/Inputs/TextArea/TextArea.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { forwardRef } from 'react';\n\nimport { Merge } from '../../utils';\nimport { inputClassNameBase } from '../_common';\nimport { useTextareaCharacterCount, useInputAttributes } from '../contexts';\n\nexport interface TextAreaProps extends Merge<\n  React.ComponentPropsWithRef<'textarea'>,\n  {\n    'aria-invalid'?: boolean;\n  }\n> {}\n\nexport const TextArea = forwardRef(function TextArea(\n  { className, maxLength, ...restProps }: TextAreaProps,\n  reference: React.ForwardedRef<HTMLTextAreaElement | null>,\n) {\n  const inputAttributes = useInputAttributes();\n  const value = restProps.value ?? restProps.defaultValue ?? '';\n  const currentLength = typeof value === 'string' ? value.length : String(value).length;\n\n  useTextareaCharacterCount(currentLength, maxLength);\n\n  return (\n    <textarea\n      ref={reference}\n      dir=\"auto\"\n      className={clsx(className, inputClassNameBase(), 'np-text-area')}\n      maxLength={maxLength}\n      {...inputAttributes}\n      {...restProps}\n    />\n  );\n});\n\nexport default TextArea;\n"],"names":["TextArea","forwardRef","className","maxLength","restProps","reference","inputAttributes","useInputAttributes","value","defaultValue","currentLength","length","String","useTextareaCharacterCount","_jsx","ref","dir","clsx","inputClassNameBase"],"mappings":";;;;;;MAcaA,QAAQ,gBAAGC,UAAU,CAAC,SAASD,QAAQA,CAClD;EAAEE,SAAS;EAAEC,SAAS;EAAE,GAAGC;AAAS,CAAiB,EACrDC,SAAyD,EAAA;AAEzD,EAAA,MAAMC,eAAe,GAAGC,kBAAkB,EAAE;EAC5C,MAAMC,KAAK,GAAGJ,SAAS,CAACI,KAAK,IAAIJ,SAAS,CAACK,YAAY,IAAI,EAAE;AAC7D,EAAA,MAAMC,aAAa,GAAG,OAAOF,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAACG,MAAM,GAAGC,MAAM,CAACJ,KAAK,CAAC,CAACG,MAAM;AAErFE,EAAAA,yBAAyB,CAACH,aAAa,EAAEP,SAAS,CAAC;AAEnD,EAAA,oBACEW,GAAA,CAAA,UAAA,EAAA;AACEC,IAAAA,GAAG,EAAEV,SAAU;AACfW,IAAAA,GAAG,EAAC,MAAM;IACVd,SAAS,EAAEe,IAAI,CAACf,SAAS,EAAEgB,kBAAkB,EAAE,EAAE,cAAc,CAAE;AACjEf,IAAAA,SAAS,EAAEA,SAAU;AAAA,IAAA,GACjBG,eAAe;IAAA,GACfF;AAAS,GAAC,CACd;AAEN,CAAC;;"}