UNPKG

2.58 kBJavaScriptView Raw
1/*
2 * Copyright 2017 Palantir Technologies, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { __decorate, __extends } from "tslib";
17import classNames from "classnames";
18import * as React from "react";
19import { polyfill } from "react-lifecycles-compat";
20import { AbstractPureComponent2, Classes } from "../../common";
21import { DISPLAYNAME_PREFIX } from "../../common/props";
22var FormGroup = /** @class */ (function (_super) {
23 __extends(FormGroup, _super);
24 function FormGroup() {
25 return _super !== null && _super.apply(this, arguments) || this;
26 }
27 FormGroup.prototype.render = function () {
28 var _a = this.props, children = _a.children, contentClassName = _a.contentClassName, helperText = _a.helperText, label = _a.label, labelFor = _a.labelFor, labelInfo = _a.labelInfo, style = _a.style;
29 return (React.createElement("div", { className: this.getClassName(), style: style },
30 label && (React.createElement("label", { className: Classes.LABEL, htmlFor: labelFor },
31 label,
32 " ",
33 React.createElement("span", { className: Classes.TEXT_MUTED }, labelInfo))),
34 React.createElement("div", { className: classNames(Classes.FORM_CONTENT, contentClassName) },
35 children,
36 helperText && React.createElement("div", { className: Classes.FORM_HELPER_TEXT }, helperText))));
37 };
38 FormGroup.prototype.getClassName = function () {
39 var _a;
40 var _b = this.props, className = _b.className, disabled = _b.disabled, inline = _b.inline, intent = _b.intent;
41 return classNames(Classes.FORM_GROUP, Classes.intentClass(intent), (_a = {},
42 _a[Classes.DISABLED] = disabled,
43 _a[Classes.INLINE] = inline,
44 _a), className);
45 };
46 FormGroup.displayName = DISPLAYNAME_PREFIX + ".FormGroup";
47 FormGroup = __decorate([
48 polyfill
49 ], FormGroup);
50 return FormGroup;
51}(AbstractPureComponent2));
52export { FormGroup };
53//# sourceMappingURL=formGroup.js.map
\No newline at end of file