| 1 |
import styles from '@patternfly/react-styles/css/components/MultipleFileUpload/multiple-file-upload'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
import { MultipleFileUploadTitle } from './MultipleFileUploadTitle'; |
| 4 |
import { MultipleFileUploadButton } from './MultipleFileUploadButton'; |
| 5 |
import { MultipleFileUploadInfo } from './MultipleFileUploadInfo'; |
| 6 |
|
| 7 |
/** Creates the visual upload interface, including the area to drag and drop files, |
| 8 |
* an optional upload button, and descriptive instructions. |
| 9 |
*/ |
| 10 |
export interface MultipleFileUploadMainProps extends React.HTMLProps<HTMLDivElement> { |
| 11 |
/** Class to add to outer div */ |
| 12 |
className?: string; |
| 13 |
/** Content rendered inside the title icon div */ |
| 14 |
titleIcon?: React.ReactNode; |
| 15 |
/** Content rendered inside the title text div */ |
| 16 |
titleText?: React.ReactNode; |
| 17 |
/** Content rendered inside the title text separator div */ |
| 18 |
titleTextSeparator?: React.ReactNode; |
| 19 |
/** Content rendered inside the info div */ |
| 20 |
infoText?: React.ReactNode; |
| 21 |
/** Flag to prevent the upload button from being rendered */ |
| 22 |
isUploadButtonHidden?: boolean; |
| 23 |
/** Visible text label for the upload button */ |
| 24 |
browseButtonText?: string; |
| 25 |
} |
| 26 |
|
| 27 |
export const MultipleFileUploadMain: React.FunctionComponent<MultipleFileUploadMainProps> = ({ |
| 28 |
className, |
| 29 |
titleIcon, |
| 30 |
titleText, |
| 31 |
titleTextSeparator, |
| 32 |
infoText, |
| 33 |
isUploadButtonHidden, |
| 34 |
browseButtonText = 'Upload', |
| 35 |
...props |
| 36 |
}: MultipleFileUploadMainProps) => { |
| 37 |
const showTitle = !!titleIcon || !!titleText || !!titleTextSeparator; |
| 38 |
|
| 39 |
return ( |
| 40 |
<div className={css(styles.multipleFileUploadMain, className)} {...props}> |
| 41 |
{showTitle && <MultipleFileUploadTitle icon={titleIcon} text={titleText} textSeparator={titleTextSeparator} />} |
| 42 |
{isUploadButtonHidden || <MultipleFileUploadButton browseButtonText={browseButtonText} />} |
| 43 |
{!!infoText && <MultipleFileUploadInfo>{infoText}</MultipleFileUploadInfo>} |
| 44 |
</div> |
| 45 |
); |
| 46 |
}; |
| 47 |
|
| 48 |
MultipleFileUploadMain.displayName = 'MultipleFileUploadMain'; |