{"version":3,"sources":["../components/form/textarea.tsx"],"sourcesContent":["\"use client\";\nimport React, { TextareaHTMLAttributes, useRef } from 'react';\nimport _isFunction from 'lodash-es/isFunction';\nimport _kebabCase from 'lodash-es/kebabCase';\nimport { cn } from '../../utils/ui';\nimport { Label } from '../ui/label';\nimport { Textarea } from '../ui/textarea';\n\ninterface InputProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {}\n\nconst inputClass = '';\n\nexport interface FormTextareaProps extends InputProps {\n  id?: string;\n  name: string;\n  label?: string;\n  inputProps?: InputProps & { ref?: any };\n  classNames?: {\n    wrapper?: string;\n    label?: string;\n    input?: string;\n  };\n}\n\nexport function FormTextarea({\n  id,\n  name,\n  label,\n  rows = 5,\n  classNames,\n  required,\n  disabled,\n  inputProps = {},\n  ...rest\n}: FormTextareaProps) {\n  if (!id) id = _kebabCase(name);\n  const _ref = useRef<HTMLTextAreaElement>(null);\n\n  return (\n    <div className={cn('$form-textarea space-y-1', classNames?.wrapper)}>\n      {label && (\n        <Label htmlFor={id} className={classNames?.label} required={required}>\n          {label}\n        </Label>\n      )}\n\n      <Textarea\n        id={id}\n        name={name}\n        rows={rows}\n        required={required}\n        disabled={disabled}\n        autoComplete=\"off\"\n        {...inputProps}\n        {...rest}\n        // Required to bind three potential refs:\n        // 1. From the inputProps ex) react-hook-form.\n        // 2. From the this component instance itself.\n        ref={(el) => {\n          if (!el) return;\n\n          [_ref, inputProps.ref].forEach((rf) => {\n            if (!rf) return;\n\n            if (_isFunction(rf)) {\n              rf(el);\n            } else {\n              rf.current = el;\n            }\n          });\n        }}\n        className={cn(inputClass, classNames?.input)}\n      />\n    </div>\n  );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,OAAO,SAAiC,cAAc;AACtD,OAAO,iBAAiB;AACxB,OAAO,gBAAgB;AAOvB,IAAM,aAAa;AAcZ,SAAS,aAAa,IAUP;AAVO,eAC3B;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,CAAC;AAAA,EAhChB,IAwB6B,IASxB,iBATwB,IASxB;AAAA,IARH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAGA,MAAI,CAAC,GAAI,MAAK,WAAW,IAAI;AAC7B,QAAM,OAAO,OAA4B,IAAI;AAE7C,SACE,oCAAC,SAAI,WAAW,GAAG,4BAA4B,yCAAY,OAAO,KAC/D,SACC,oCAAC,SAAM,SAAS,IAAI,WAAW,yCAAY,OAAO,YAC/C,KACH,GAGF;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAa;AAAA,OACT,aACA,OARL;AAAA,MAYC,KAAK,CAAC,OAAO;AACX,YAAI,CAAC,GAAI;AAET,SAAC,MAAM,WAAW,GAAG,EAAE,QAAQ,CAAC,OAAO;AACrC,cAAI,CAAC,GAAI;AAET,cAAI,YAAY,EAAE,GAAG;AACnB,eAAG,EAAE;AAAA,UACP,OAAO;AACL,eAAG,UAAU;AAAA,UACf;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,WAAW,GAAG,YAAY,yCAAY,KAAK;AAAA;AAAA,EAC7C,CACF;AAEJ;","names":[]}