UNPKG

2.59 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 { __extends } from "tslib";
17import classNames from "classnames";
18import * as React from "react";
19import { AbstractPureComponent2, Classes } from "../../common";
20import { DISPLAYNAME_PREFIX } from "../../common/props";
21var FormGroup = /** @class */ (function (_super) {
22 __extends(FormGroup, _super);
23 function FormGroup() {
24 return _super !== null && _super.apply(this, arguments) || this;
25 }
26 FormGroup.prototype.render = function () {
27 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, subLabel = _a.subLabel;
28 return (React.createElement("div", { className: this.getClassName(), style: style },
29 label && (React.createElement("label", { className: Classes.LABEL, htmlFor: labelFor },
30 label,
31 " ",
32 React.createElement("span", { className: Classes.TEXT_MUTED }, labelInfo))),
33 subLabel && React.createElement("div", { className: Classes.FORM_GROUP_SUB_LABEL }, subLabel),
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 = "".concat(DISPLAYNAME_PREFIX, ".FormGroup");
47 return FormGroup;
48}(AbstractPureComponent2));
49export { FormGroup };
50//# sourceMappingURL=formGroup.js.map
\No newline at end of file