{"version":3,"file":"ControlledTextField-D8Ewa66o.js","sources":["../../../frontend/src/Components/ReactHookFormComponents/ControlledTextField.tsx"],"sourcesContent":["import React from 'react';\nimport { Controller, ControllerProps } from 'react-hook-form';\nimport { TextFieldProps } from '@mui/material';\n\nimport { ContentRich } from '../Posts/Forms';\nimport TextFieldDefault from '../Posts/Forms/TextFieldDefault';\n\n/**\n * A controlled form component used with react-hook-form.\n * @param control the form control created by react-hook-form (useForm)\n * @param defaultValue the default value related to this controlled form input\n */\n\ntype ControlledTextFieldProps = TextFieldProps & {\n control: any;\n name: string;\n defaultValue?: string;\n richText?: boolean;\n component?: any;\n componentProps?: any;\n editingOptions?: string[];\n maxLength?: number;\n rules?: ControllerProps['rules'];\n numbersOnly?: boolean;\n};\n\nfunction ControlledTextField({\n control,\n rules,\n name,\n defaultValue = '',\n richText = false,\n numbersOnly = false,\n component,\n componentProps = {},\n ...rest\n}: ControlledTextFieldProps) {\n const Comp = component || (richText ? ContentRich : TextFieldDefault);\n\n return (\n {\n const handleNumberChange = (event: React.ChangeEvent) => {\n const value = event.target.value;\n\n // allow only numbers\n if (value.match(/^-?\\d*\\.?\\d*$/)) {\n onChange?.(event);\n }\n };\n\n return (\n \n );\n }}\n />\n );\n}\n\nexport default ControlledTextField;\n"],"names":["ControlledTextField","_ref","control","rules","name","_ref$defaultValue","defaultValue","_ref$richText","richText","_ref$numbersOnly","numbersOnly","component","_ref$componentProps","componentProps","rest","_objectWithoutProperties","_excluded","Comp","ContentRich","TextFieldDefault","React","createElement","Controller","render","_ref2","_ref2$field","field","onChange","fieldProps","_excluded2","handleNumberChange","event","value","target","match","_extends","id"],"mappings":"g5BA0BA,SAASA,EAAmBC,EAUC,CAT3BC,IAAAA,EAAOD,EAAPC,QACAC,EAAKF,EAALE,MACAC,EAAIH,EAAJG,KAAIC,EAAAJ,EACJK,aAAAA,EAAYD,IAAG,OAAA,GAAEA,EAAAE,EAAAN,EACjBO,SAAAA,EAAQD,IAAG,OAAA,GAAKA,EAAAE,EAAAR,EAChBS,YAAAA,EAAWD,IAAG,OAAA,GAAKA,EACnBE,EAASV,EAATU,UAASC,EAAAX,EACTY,eAAAA,EAAcD,IAAA,OAAG,GAAEA,EAChBE,EAAIC,EAAAd,EAAAe,CAAA,EAEDC,EAAON,IAAcH,EAAWU,EAAcC,GAGlDC,OAAAA,EAAAC,cAACC,EAAU,CACTpB,QAAAA,EACAE,KAAAA,EACAD,MAAAA,EACAG,aAAcA,GAAgB,GAC9BiB,OAAQ,SAAFC,EAA8C,CAAAC,IAAAA,EAAAD,EAAzCE,MAASC,EAAQF,EAARE,SAAaC,EAAUb,EAAAU,EAAAI,CAAA,EACnCC,EAAqB,SAACC,EAA+C,CACnEC,IAAAA,EAAQD,EAAME,OAAOD,MAGvBA,EAAME,MAAM,eAAe,IAC7BP,SAAAA,EAAWI,CAAK,EAEpB,EAGEX,OAAAA,EAAAC,cAACJ,EAAIkB,EAAA,CACHR,SAAUjB,EAAcoB,EAAqBH,GACzCC,EAAU,CACdQ,GAAIhC,EACJA,KAAAA,CAAAA,EACIU,EACAD,CAAc,CACnB,CAAA,CAEL,CACD,CAEL"}