{"version":3,"file":"index.cjs","sources":["../../../../src/components/TextAreaField/TextAreaField.tsx"],"sourcesContent":["import { ChangeEvent, TextareaHTMLAttributes, forwardRef, useId, useRef } from 'react';\nimport { TextAreaElement, InputWrapper, WrapperProps } from '@/components/InputWrapper';\nimport { mergeRefs } from '@/utils/mergeRefs';\n\nexport interface TextAreaFieldProps\n  extends\n    Omit<WrapperProps, 'id' | 'children'>,\n    Omit<\n      TextareaHTMLAttributes<HTMLTextAreaElement>,\n      'children' | 'type' | 'value' | 'onChange' | 'dir'\n    > {\n  /** Number of visible text rows */\n  rows?: number;\n  /** The current value of the textarea */\n  value?: string;\n  /** Callback when the textarea value changes */\n  onChange: (inputValue: string, e?: ChangeEvent<HTMLTextAreaElement>) => void;\n  /** The orientation of the label relative to the input */\n  orientation?: 'vertical' | 'horizontal';\n  /** The direction/position of the label - start places label before, end places label after */\n  dir?: 'start' | 'end';\n}\n\nexport const TextAreaField = forwardRef<HTMLTextAreaElement, TextAreaFieldProps>(\n  (\n    {\n      rows,\n      disabled,\n      label,\n      error,\n      id,\n      value = '',\n      onChange: onChangeProp,\n      orientation,\n      dir,\n      ...props\n    },\n    ref\n  ) => {\n    const inputRef = useRef<HTMLTextAreaElement>(null);\n    const defaultId = useId();\n    const onChange = (e: ChangeEvent<HTMLTextAreaElement>) => {\n      onChangeProp(e.target.value, e);\n    };\n\n    return (\n      <InputWrapper\n        disabled={disabled}\n        id={id ?? defaultId}\n        label={label}\n        error={error}\n        orientation={orientation}\n        dir={dir}\n        resize=\"vertical\"\n      >\n        <TextAreaElement\n          ref={mergeRefs([inputRef, ref])}\n          rows={rows ?? 5}\n          id={id ?? defaultId}\n          disabled={disabled}\n          value={value}\n          onChange={onChange}\n          {...props}\n        />\n      </InputWrapper>\n    );\n  }\n);\n"],"names":["forwardRef","useRef","useId","jsx","InputWrapper","TextAreaElement","mergeRefs"],"mappings":";;;;;;;;;AAuBO,MAAM,aAAA,GAAgBA,gBAAA;AAAA,EAC3B,CACE;AAAA,IACE,IAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,EAAA;AAAA,IACA,KAAA,GAAQ,EAAA;AAAA,IACR,QAAA,EAAU,YAAA;AAAA,IACV,WAAA;AAAA,IACA,GAAA;AAAA,IACA,GAAG;AAAA,KAEL,GAAA,KACG;AACH,IAAA,MAAM,QAAA,GAAWC,aAA4B,IAAI,CAAA;AACjD,IAAA,MAAM,YAAYC,WAAA,EAAM;AACxB,IAAA,MAAM,QAAA,GAAW,CAAC,CAAA,KAAwC;AACxD,MAAA,YAAA,CAAa,CAAA,CAAE,MAAA,CAAO,KAAA,EAAO,CAAC,CAAA;AAAA,IAChC,CAAA;AAEA,IAAA,uBACEC,cAAA;AAAA,MAACC,yBAAA;AAAA,MAAA;AAAA,QACC,QAAA;AAAA,QACA,IAAI,EAAA,IAAM,SAAA;AAAA,QACV,KAAA;AAAA,QACA,KAAA;AAAA,QACA,WAAA;AAAA,QACA,GAAA;AAAA,QACA,MAAA,EAAO,UAAA;AAAA,QAEP,QAAA,kBAAAD,cAAA;AAAA,UAACE,4BAAA;AAAA,UAAA;AAAA,YACC,GAAA,EAAKC,mBAAA,CAAU,CAAC,QAAA,EAAU,GAAG,CAAC,CAAA;AAAA,YAC9B,MAAM,IAAA,IAAQ,CAAA;AAAA,YACd,IAAI,EAAA,IAAM,SAAA;AAAA,YACV,QAAA;AAAA,YACA,KAAA;AAAA,YACA,QAAA;AAAA,YACC,GAAG;AAAA;AAAA;AACN;AAAA,KACF;AAAA,EAEJ;AACF;;"}