1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.TextArea = void 0;
|
19 | var tslib_1 = require("tslib");
|
20 | var classnames_1 = tslib_1.__importDefault(require("classnames"));
|
21 | var React = tslib_1.__importStar(require("react"));
|
22 | var common_1 = require("../../common");
|
23 | var props_1 = require("../../common/props");
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | var TextArea = (function (_super) {
|
32 | tslib_1.__extends(TextArea, _super);
|
33 | function TextArea() {
|
34 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
35 | _this.state = {};
|
36 |
|
37 | _this.textareaElement = null;
|
38 | _this.handleRef = (0, common_1.refHandler)(_this, "textareaElement", _this.props.inputRef);
|
39 | _this.handleChange = function (e) {
|
40 | if (_this.props.growVertically) {
|
41 | _this.setState({
|
42 | height: e.target.scrollHeight,
|
43 | });
|
44 | }
|
45 | if (_this.props.onChange != null) {
|
46 | _this.props.onChange(e);
|
47 | }
|
48 | };
|
49 | return _this;
|
50 | }
|
51 | TextArea.prototype.componentDidMount = function () {
|
52 | var _a;
|
53 | if (this.props.growVertically && this.textareaElement !== null) {
|
54 |
|
55 |
|
56 | this.setState({
|
57 | height: (_a = this.textareaElement) === null || _a === void 0 ? void 0 : _a.scrollHeight,
|
58 | });
|
59 | }
|
60 | };
|
61 | TextArea.prototype.componentDidUpdate = function (prevProps) {
|
62 | if (prevProps.inputRef !== this.props.inputRef) {
|
63 | (0, common_1.setRef)(prevProps.inputRef, null);
|
64 | this.handleRef = (0, common_1.refHandler)(this, "textareaElement", this.props.inputRef);
|
65 | (0, common_1.setRef)(this.props.inputRef, this.textareaElement);
|
66 | }
|
67 | };
|
68 | TextArea.prototype.render = function () {
|
69 | var _a;
|
70 | var _b = this.props, className = _b.className, fill = _b.fill, inputRef = _b.inputRef, intent = _b.intent, large = _b.large, small = _b.small, growVertically = _b.growVertically, htmlProps = tslib_1.__rest(_b, ["className", "fill", "inputRef", "intent", "large", "small", "growVertically"]);
|
71 | var rootClasses = (0, classnames_1.default)(common_1.Classes.INPUT, common_1.Classes.intentClass(intent), (_a = {},
|
72 | _a[common_1.Classes.FILL] = fill,
|
73 | _a[common_1.Classes.LARGE] = large,
|
74 | _a[common_1.Classes.SMALL] = small,
|
75 | _a), className);
|
76 |
|
77 | var _c = htmlProps.style, style = _c === void 0 ? {} : _c;
|
78 | if (growVertically && this.state.height != null) {
|
79 |
|
80 |
|
81 | style = tslib_1.__assign(tslib_1.__assign({}, style), { height: "".concat(this.state.height, "px") });
|
82 | }
|
83 | return (React.createElement("textarea", tslib_1.__assign({}, htmlProps, { className: rootClasses, onChange: this.handleChange, ref: this.handleRef, style: style })));
|
84 | };
|
85 | TextArea.displayName = "".concat(props_1.DISPLAYNAME_PREFIX, ".TextArea");
|
86 | return TextArea;
|
87 | }(common_1.AbstractPureComponent2));
|
88 | exports.TextArea = TextArea;
|
89 |
|
\ | No newline at end of file |