UNPKG

2.69 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";
21/**
22 * Form group component.
23 *
24 * @see https://blueprintjs.com/docs/#core/components/form-group
25 */
26var FormGroup = /** @class */ (function (_super) {
27 __extends(FormGroup, _super);
28 function FormGroup() {
29 return _super !== null && _super.apply(this, arguments) || this;
30 }
31 FormGroup.prototype.render = function () {
32 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;
33 return (React.createElement("div", { className: this.getClassName(), style: style },
34 label && (React.createElement("label", { className: Classes.LABEL, htmlFor: labelFor },
35 label,
36 " ",
37 React.createElement("span", { className: Classes.TEXT_MUTED }, labelInfo))),
38 subLabel && React.createElement("div", { className: Classes.FORM_GROUP_SUB_LABEL }, subLabel),
39 React.createElement("div", { className: classNames(Classes.FORM_CONTENT, contentClassName) },
40 children,
41 helperText && React.createElement("div", { className: Classes.FORM_HELPER_TEXT }, helperText))));
42 };
43 FormGroup.prototype.getClassName = function () {
44 var _a;
45 var _b = this.props, className = _b.className, disabled = _b.disabled, inline = _b.inline, intent = _b.intent;
46 return classNames(Classes.FORM_GROUP, Classes.intentClass(intent), (_a = {},
47 _a[Classes.DISABLED] = disabled,
48 _a[Classes.INLINE] = inline,
49 _a), className);
50 };
51 FormGroup.displayName = "".concat(DISPLAYNAME_PREFIX, ".FormGroup");
52 return FormGroup;
53}(AbstractPureComponent2));
54export { FormGroup };
55//# sourceMappingURL=formGroup.js.map
\No newline at end of file