theme.keycloak.v2.admin.resources.assets.FileUploadForm-BgyzQxBE.js.map Maven / Gradle / Ivy
{"version":3,"file":"FileUploadForm-BgyzQxBE.js","sources":["../../src/components/json-file-upload/FileUploadForm.tsx"],"sourcesContent":["import { CodeEditor, Language } from \"@patternfly/react-code-editor\";\nimport {\n Button,\n FormGroup,\n FormHelperText,\n HelperText,\n HelperTextItem,\n Modal,\n ModalVariant,\n} from \"@patternfly/react-core\";\nimport {\n ChangeEvent,\n DragEvent as ReactDragEvent,\n MouseEvent as ReactMouseEvent,\n useState,\n} from \"react\";\nimport { DropEvent } from \"react-dropzone\";\nimport { useTranslation } from \"react-i18next\";\nimport { FileUpload, FileUploadProps } from \"./patternfly/FileUpload\";\n\ntype FileUploadType = {\n value: string;\n filename: string;\n isLoading: boolean;\n modal: boolean;\n};\n\nexport type FileUploadEvent =\n | ReactDragEvent // User dragged/dropped a file\n | ChangeEvent // User typed in the TextArea\n | ReactMouseEvent; // User clicked Clear button\n\nexport type FileUploadFormProps = Omit & {\n id: string;\n extension: string;\n onChange: (value: string) => void;\n helpText?: string;\n unWrap?: boolean;\n language?: Language;\n};\n\nexport const FileUploadForm = ({\n id,\n onChange,\n helpText = \"helpFileUpload\",\n unWrap = false,\n language,\n extension,\n ...rest\n}: FileUploadFormProps) => {\n const { t } = useTranslation();\n const defaultUpload: FileUploadType = {\n value: \"\",\n filename: \"\",\n isLoading: false,\n modal: false,\n };\n const [fileUpload, setFileUpload] = useState(defaultUpload);\n const removeDialog = () => setFileUpload({ ...fileUpload, modal: false });\n\n const handleFileInputChange = (_event: DropEvent, file: File) => {\n setFileUpload({ ...fileUpload, filename: file.name });\n };\n\n const handleTextOrDataChange = (value: string) => {\n setFileUpload({ ...fileUpload, value });\n onChange(value);\n };\n\n const handleClear = () => {\n setFileUpload({ ...fileUpload, modal: true });\n };\n\n return (\n <>\n {fileUpload.modal && (\n {\n setFileUpload(defaultUpload);\n onChange(\"\");\n }}\n >\n {t(\"clear\")}\n ,\n ,\n ]}\n >\n {t(\"clearFileExplain\")}\n \n )}\n {unWrap && (\n \n setFileUpload({ ...fileUpload, isLoading: true })\n }\n onReadFinished={() =>\n setFileUpload({ ...fileUpload, isLoading: false })\n }\n isLoading={fileUpload.isLoading}\n dropzoneProps={{\n accept: { \"application/text\": [extension] },\n }}\n />\n )}\n {!unWrap && (\n \n \n setFileUpload({ ...fileUpload, isLoading: true })\n }\n onReadFinished={() =>\n setFileUpload({ ...fileUpload, isLoading: false })\n }\n isLoading={fileUpload.isLoading}\n hideDefaultPreview\n >\n {!rest.hideDefaultPreview && (\n \n )}\n \n \n \n {t(helpText)} \n \n \n \n )}\n >\n );\n};\n"],"names":["FileUploadForm","id","onChange","helpText","unWrap","language","extension","rest","t","useTranslation","defaultUpload","fileUpload","setFileUpload","useState","removeDialog","handleFileInputChange","_event","file","handleTextOrDataChange","value","handleClear","jsxs","Fragment","jsx","Modal","ModalVariant","Button","FileUpload","FormGroup","CodeEditor","FormHelperText","HelperText","HelperTextItem"],"mappings":"uRAyCO,MAAMA,EAAiB,CAAC,CAC7B,GAAAC,EACA,SAAAC,EACA,SAAAC,EAAW,iBACX,OAAAC,EAAS,GACT,SAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IAA2B,CACnB,KAAA,CAAE,EAAAC,GAAMC,IACRC,EAAgC,CACpC,MAAO,GACP,SAAU,GACV,UAAW,GACX,MAAO,EAAA,EAEH,CAACC,EAAYC,CAAa,EAAIC,EAAyBH,CAAa,EACpEI,EAAe,IAAMF,EAAc,CAAE,GAAGD,EAAY,MAAO,GAAO,EAElEI,EAAwB,CAACC,EAAmBC,IAAe,CAC/DL,EAAc,CAAE,GAAGD,EAAY,SAAUM,EAAK,KAAM,CAAA,EAGhDC,EAA0BC,GAAkB,CAChDP,EAAc,CAAE,GAAGD,EAAY,MAAAQ,CAAO,CAAA,EACtCjB,EAASiB,CAAK,CAAA,EAGVC,EAAc,IAAM,CACxBR,EAAc,CAAE,GAAGD,EAAY,MAAO,EAAM,C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