{"version":3,"file":"TextArea.cjs","sources":["../../../../src/components/forms/TextArea.tsx"],"sourcesContent":["import React from \"react\";\n\ninterface TextAreaProps {\n  name: string;\n  label: string;\n  required?: boolean;\n  disabled?: boolean;\n  rows?: number;\n  defaultValue?: string;\n  placeholder?: string;\n  clasName?: string;\n  maxLength?: number | string;\n  note?: string;\n  error?: string;\n  helperText?: string;\n  id?: string;\n  setValue?: (value: string) => void;\n  onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n}\n\n/**\n * TextArea component\n * @example\n * ```tsx\n * <TextArea\n *   name=\"textArea\"\n *   label=\"Text Area\"\n *   rows={10}\n *   defaultValue=\"Default value\"\n * />\n * ```\n * Props interface for the TextArea component\n * @property {string} name - The name of the TextArea\n * @property {string} label - The label of the TextArea\n * @property {boolean} [required] - Whether the TextArea is required\n * @property {boolean} [disabled] - Whether the TextArea is disabled\n * @property {number} rows - The number of rows of the TextArea\n * @property {string} defaultValue - The default value of the TextArea\n * @property {string} placeholder - The placeholder of the TextArea\n * @property {string} [clasName] - The class name of the TextArea\n * @property {number | string} maxLength - The max length of the TextArea\n * @property {string} note - The note of the TextArea\n * @property {string} error - The error message of the TextArea\n * @property {string} helperText - The helper text of the TextArea\n * @property {string} id - The id of the TextArea\n * @property {(value: string) => void} setValue - The function to set the value of the TextArea\n * @property {(e: React.ChangeEvent<HTMLTextAreaElement>) => void} onChange - The function to handle the change of the TextArea\n * @returns {React.ReactElement} The TextArea component\n */\nconst TextArea: React.FC<TextAreaProps> = (props) => {\n  const showLabel = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n    if (e.target.value) e.target.parentElement?.classList.add(\"ihub-value\");\n    else e.target.parentElement?.classList.remove(\"ihub-value\");\n  };\n\n  const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n    if (props.setValue) props.setValue(e.target.value);\n    if (props.onChange) props.onChange(e);\n    showLabel(e);\n  };\n\n  return (\n    <div className={props.name}>\n      <div className=\"ihub-field\">\n        <div\n          className={`ihub-textarea-wrapper ${\n            props.defaultValue ? \"ihub-value\" : \"\"\n          }`}\n        >\n          <textarea\n            name={props.name}\n            rows={props.rows}\n            defaultValue={props.defaultValue}\n            className={`ihub-textarea ${props.clasName || \"\"}`}\n            disabled={props.disabled}\n            required={props.required}\n            onChange={handleInput}\n            placeholder={props.placeholder}\n            maxLength={\n              props.maxLength !== undefined\n                ? Number(props.maxLength)\n                : undefined\n            }\n          ></textarea>\n          <span className=\"ihub-textarea-label\">{props.label}</span>\n        </div>\n      </div>\n      {props.helperText && !props.error && <p className=\"ihub-notes\">{props.helperText}</p>}\n\n      {props.error && <p className=\"ihub-notes ihub-is_invalid\">{props.error}</p>}\n\n      {props.note && (\n        <p className=\"ihub-input-notes\" id={`${props.id}-note`}>\n          {props.note}\n        </p>\n      )}\n    </div>\n  );\n};\n\nexport default TextArea;\n"],"names":["props","_jsxs","className","name","children","_jsx","jsx","jsxs","concat","defaultValue","rows","clasName","disabled","required","onChange","e","setValue","target","value","_e$target$parentEleme","_e$target$parentEleme2","parentElement","classList","add","remove","showLabel","placeholder","maxLength","undefined","Number","label","helperText","error","note","id"],"mappings":"uHAiD0C,SAACA,GAYzC,OACEC,EAAAA,KAAK,MAAA,CAAAC,UAAWF,EAAMG,KACpBC,SAAA,CAAAC,EAAAC,IAAA,MAAA,CAAKJ,UAAU,aACbE,SAAAH,EAAAM,KAAA,MAAA,CACEL,UAAS,yBAAAM,OACPR,EAAMS,aAAe,aAAe,IAGtCL,SAAA,CAAAC,EAAAC,IAAA,WAAA,CACEH,KAAMH,EAAMG,KACZO,KAAMV,EAAMU,KACZD,aAAcT,EAAMS,aACpBP,UAAS,iBAAAM,OAAmBR,EAAMW,UAAY,IAC9CC,SAAUZ,EAAMY,SAChBC,SAAUb,EAAMa,SAChBC,SArBU,SAACC,GACff,EAAMgB,UAAUhB,EAAMgB,SAASD,EAAEE,OAAOC,OACxClB,EAAMc,UAAUd,EAAMc,SAASC,GAPnB,SAACA,GAAmD,IAAAI,EAAAC,EAChEL,EAAEE,OAAOC,MAA6BC,QAAtBA,EAAAJ,EAAEE,OAAOI,yBAAaF,GAAtBA,EAAwBG,UAAUC,IAAI,cAC/BH,QAAtBA,EAAAL,EAAEE,OAAOI,yBAAaD,GAAtBA,EAAwBE,UAAUE,OAAO,cAM9CC,CAAUV,IAmBFW,YAAa1B,EAAM0B,YACnBC,eACsBC,IAApB5B,EAAM2B,UACFE,OAAO7B,EAAM2B,gBACbC,IAGRvB,cAAMH,UAAU,sBAAqBE,SAAEJ,EAAM8B,aAGhD9B,EAAM+B,aAAe/B,EAAMgC,OAAS3B,EAAGC,IAAA,IAAA,CAAAJ,UAAU,sBAAcF,EAAM+B,aAErE/B,EAAMgC,OAAS3B,EAAAA,IAAG,IAAA,CAAAH,UAAU,sCAA8BF,EAAMgC,QAEhEhC,EAAMiC,MACL5B,EAAAA,IAAG,IAAA,CAAAH,UAAU,mBAAmBgC,MAAE1B,OAAKR,EAAMkC,GAAS,SACnD9B,SAAAJ,EAAMiC,SAKjB"}