jobiqo-cl
Version:
[](https://circleci.com/gh/jobiqo/jobiqo-cl)
87 lines (86 loc) • 1.97 kB
TypeScript
/**
* @file index.tsx
*
* @fileoverview File input component. Renders a button input together with its label.
*/
import React, { ChangeEvent, Component } from 'react';
export interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
/**
* The label to be shown next to the input.
*/
label?: string;
/**
* Marks if a field is in an error state.
*
* @default false
*/
error?: boolean;
/**
* The placeholder to be shown next to the input.
*/
placeholder?: string;
/**
* The style for the button.
*
* @default "default"
*/
buttonStyle?: 'primary' | 'secondary' | 'default';
/**
* If the file upload allows multiple file selection.
*
* @default "false"
*/
multiple?: boolean;
/**
* Event when the file is chose.
*/
onChange?(file: File | File[] | ChangeEvent): void;
}
interface FileItem {
/**
* The file that was uploaded.
*/
file: any;
/**
* The name of the file that was uploaded.
*/
filename: string;
/**
* The size of the file that was uploaded.
*/
fileSize: string;
/**
* The type of file.
*/
type: string;
}
interface State {
/**
* The file that was uploaded.
*/
files: FileItem[];
}
/**
* A file input is a form element where users can chose a file from their local
* computer and use it to upload.
*/
export declare class FileInput extends Component<Props, State> {
/**
* Internal property to hold the reference to the file input.
*/
fileInput: React.RefObject<HTMLInputElement>;
state: {
files: any[];
};
constructor(props: any);
/**
* Triggers a click on the input.
*/
handleClick: (event: any) => void;
/**
* Handle change on the input field.
*/
handleChange: (event: any) => void;
render(): JSX.Element;
}
export default FileInput;