{"version":3,"file":"TextFieldDefault-CkYr4ZbQ.js","sources":["../../../frontend/src/Utils/Posts/Form/withOptional.ts","../../../frontend/src/Components/Posts/Forms/TextFieldDefault/TextFieldDefault.tsx"],"sourcesContent":["function withOptional(label: any, required = false, asterisk = false) {\n const symbol = required && asterisk ? '*' : '';\n\n if (!label) {\n return null;\n }\n\n return `${label} ${symbol}`.trim();\n}\n\nexport default withOptional;\n","import React from 'react';\nimport { TextField, TextFieldProps } from '@mui/material';\nimport { useIntl } from 'react-intl';\n\nimport withOptional from '../../../../Utils/Posts/Form/withOptional';\n\nexport type TextFieldDefaultProps = TextFieldProps & {\n maxLength?: number;\n value: string | null | undefined;\n};\n\n// This TextField is preset for Forms\nconst TextFieldDefault = React.forwardRef(\n (\n {\n maxLength,\n value,\n error,\n helperText,\n label,\n required,\n slotProps,\n ...restProps\n }: TextFieldDefaultProps,\n ref: any,\n ) => {\n const intl = useIntl();\n const valuePlainText = value || '';\n const valuePlainTextLength = valuePlainText.length;\n\n const counter = intl.formatMessage(\n {\n id: 'TEXT_FIELD.LENGTH',\n },\n { length: valuePlainTextLength, maxLength },\n );\n\n const isLengthError = maxLength && valuePlainText && maxLength < valuePlainTextLength;\n\n const lengthErrorHelperText = intl.formatMessage(\n {\n id: 'TEXT_FIELD.LENGTH_ERROR_TEXT',\n },\n { length: value?.length, maxLength },\n );\n\n let newHelperText;\n\n if (helperText && !maxLength) {\n newHelperText = helperText;\n } else if (maxLength && helperText) {\n newHelperText = `${counter} - ${helperText}`;\n } else if (maxLength) {\n newHelperText = counter;\n }\n\n if (isLengthError) {\n newHelperText = `${counter} - ${lengthErrorHelperText}`;\n }\n\n return (\n \n );\n },\n);\n\nTextFieldDefault.displayName = 'TextFieldDefault';\n\nexport default TextFieldDefault;\n"],"names":["withOptional","label","required","arguments","length","undefined","asterisk","symbol","concat","trim","TextFieldDefault","React","forwardRef","_ref","ref","maxLength","value","error","helperText","slotProps","restProps","_objectWithoutProperties","_excluded","intl","useIntl","valuePlainText","valuePlainTextLength","counter","formatMessage","id","isLengthError","lengthErrorHelperText","newHelperText","createElement","TextField","_extends","variant","fullWidth","_objectSpread","inputLabel","shrink","displayName"],"mappings":"4FAAA,SAASA,EAAaC,EAAgD,CAApCC,IAAAA,EAAQC,UAAAC,OAAA,GAAAD,UAAA,CAAA,IAAAE,OAAAF,UAAA,CAAA,EAAG,GAAOG,EAAQH,UAAAC,OAAA,GAAAD,UAAA,CAAA,IAAAE,OAAAF,UAAA,CAAA,EAAG,GACvDI,EAASL,GAAYI,EAAW,IAAM,GAE5C,OAAKL,EAIE,GAAAO,OAAGP,EAAK,GAAA,EAAAO,OAAID,CAAM,EAAGE,KAAK,EAHxB,IAIX,i4DCIA,IAAMC,EAAmBC,EAAMC,WAC7B,SAAAC,EAWEC,EACG,CAVDC,IAAAA,EAASF,EAATE,UACAC,EAAKH,EAALG,MACAC,EAAKJ,EAALI,MACAC,EAAUL,EAAVK,WACAjB,EAAKY,EAALZ,MACAC,EAAQW,EAARX,SACAiB,EAASN,EAATM,UACGC,EAASC,EAAAR,EAAAS,CAAA,EAIRC,EAAOC,EAAQ,EACfC,EAAiBT,GAAS,GAC1BU,EAAuBD,EAAerB,OAEtCuB,EAAUJ,EAAKK,cACnB,CACEC,GAAI,mBAAA,EAEN,CAAEzB,OAAQsB,EAAsBX,UAAAA,CAAAA,CAClC,EAEMe,EAAgBf,GAAaU,GAAkBV,EAAYW,EAE3DK,EAAwBR,EAAKK,cACjC,CACEC,GAAI,8BAAA,EAEN,CAAEzB,OAAQY,GAAK,KAALA,OAAAA,EAAOZ,OAAQW,UAAAA,CAAAA,CAC3B,EAEIiB,EAEAd,OAAAA,GAAc,CAACH,EACDG,EAAAA,EACPH,GAAaG,EACtBc,EAAa,GAAAxB,OAAMmB,SAAOnB,OAAMU,CAAU,EACjCH,IACOY,EAAAA,GAGdG,IACFE,EAAa,GAAAxB,OAAMmB,SAAOnB,OAAMuB,CAAqB,GAIrDpB,EAAAsB,cAACC,EAASC,E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