1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { __assign, __extends, __rest } from "tslib";
|
17 | import classNames from "classnames";
|
18 | import * as React from "react";
|
19 | import { AbstractPureComponent, Classes } from "../../common";
|
20 | import { DISPLAYNAME_PREFIX } from "../../common/props";
|
21 | var NS = Classes.getClassNamespace();
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | var FileInput = (function (_super) {
|
30 | __extends(FileInput, _super);
|
31 | function FileInput() {
|
32 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
33 | _this.handleInputChange = function (e) {
|
34 | var _a, _b, _c, _d;
|
35 | (_b = (_a = _this.props).onInputChange) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
36 | (_d = (_c = _this.props.inputProps) === null || _c === void 0 ? void 0 : _c.onChange) === null || _d === void 0 ? void 0 : _d.call(_c, e);
|
37 | };
|
38 | return _this;
|
39 | }
|
40 | FileInput.prototype.render = function () {
|
41 | var _a, _b, _c;
|
42 | var _d = this.props, buttonText = _d.buttonText, className = _d.className, disabled = _d.disabled, fill = _d.fill, hasSelection = _d.hasSelection, inputProps = _d.inputProps, large = _d.large, onInputChange = _d.onInputChange, small = _d.small, text = _d.text, htmlProps = __rest(_d, ["buttonText", "className", "disabled", "fill", "hasSelection", "inputProps", "large", "onInputChange", "small", "text"]);
|
43 | var rootClasses = classNames(className, Classes.FILE_INPUT, (_a = {},
|
44 | _a[Classes.FILE_INPUT_HAS_SELECTION] = hasSelection,
|
45 | _a[Classes.DISABLED] = disabled,
|
46 | _a[Classes.FILL] = fill,
|
47 | _a[Classes.LARGE] = large,
|
48 | _a[Classes.SMALL] = small,
|
49 | _a));
|
50 | var uploadProps = (_b = {},
|
51 | _b["".concat(NS, "-button-text")] = buttonText,
|
52 | _b.className = classNames(Classes.FILE_UPLOAD_INPUT, (_c = {},
|
53 | _c[Classes.FILE_UPLOAD_INPUT_CUSTOM_TEXT] = !!buttonText,
|
54 | _c)),
|
55 | _b);
|
56 | return (React.createElement("label", __assign({}, htmlProps, { className: rootClasses }),
|
57 | React.createElement("input", __assign({}, inputProps, { onChange: this.handleInputChange, type: "file", disabled: disabled })),
|
58 | React.createElement("span", __assign({}, uploadProps), text)));
|
59 | };
|
60 | FileInput.displayName = "".concat(DISPLAYNAME_PREFIX, ".FileInput");
|
61 | FileInput.defaultProps = {
|
62 | hasSelection: false,
|
63 | inputProps: {},
|
64 | text: "Choose file...",
|
65 | };
|
66 | return FileInput;
|
67 | }(AbstractPureComponent));
|
68 | export { FileInput };
|
69 |
|
\ | No newline at end of file |