UNPKG

@blueprintjs/core

Version:
38 lines 1.6 kB
/* * Copyright 2017 Palantir Technologies, Inc. All rights reserved. * * Licensed under the terms of the LICENSE file distributed with this project. */ import classNames from "classnames"; import * as React from "react"; import { Utils } from "../../common"; import * as Classes from "../../common/classes"; import { DISPLAYNAME_PREFIX } from "../../common/props"; // TODO: write tests (ignoring for now to get a build passing quickly) /* istanbul ignore next */ export class FileInput extends React.PureComponent { constructor() { super(...arguments); this.handleInputChange = (e) => { Utils.safeInvoke(this.props.onInputChange, e); Utils.safeInvoke(this.props.inputProps.onChange, e); }; } render() { const { className, fill, disabled, inputProps, onInputChange, large, text, ...htmlProps } = this.props; const rootClasses = classNames(Classes.FILE_INPUT, { [Classes.DISABLED]: disabled, [Classes.FILL]: fill, [Classes.LARGE]: large, }, className); return (React.createElement("label", Object.assign({}, htmlProps, { className: rootClasses }), React.createElement("input", Object.assign({}, inputProps, { onChange: this.handleInputChange, type: "file", disabled: disabled })), React.createElement("span", { className: Classes.FILE_UPLOAD_INPUT }, text))); } } FileInput.displayName = `${DISPLAYNAME_PREFIX}.FileInput`; FileInput.defaultProps = { inputProps: {}, text: "Choose file...", }; //# sourceMappingURL=fileInput.js.map