UNPKG

@gooddata/react-components

Version:

GoodData.UI - A powerful JavaScript library for building analytical applications

49 lines 2.53 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); // (C) 2019-2020 GoodData Corporation var React = require("react"); var react_intl_1 = require("react-intl"); var set = require("lodash/set"); var DisabledBubbleMessage_1 = require("../DisabledBubbleMessage"); var translations_1 = require("../../utils/translations"); var CheckboxControl = /** @class */ (function (_super) { __extends(CheckboxControl, _super); function CheckboxControl(props) { var _this = _super.call(this, props) || this; _this.onValueChanged = _this.onValueChanged.bind(_this); return _this; } CheckboxControl.prototype.render = function () { var _a = this.props, checked = _a.checked, disabled = _a.disabled, labelText = _a.labelText, showDisabledMessage = _a.showDisabledMessage, intl = _a.intl; return (React.createElement(DisabledBubbleMessage_1.default, { showDisabledMessage: showDisabledMessage }, React.createElement("label", { className: "input-checkbox-label" }, React.createElement("input", { checked: checked, disabled: disabled, type: "checkbox", className: "input-checkbox", onChange: this.onValueChanged }), React.createElement("span", { className: "input-label-text" }, translations_1.getTranslation(labelText, intl))))); }; CheckboxControl.prototype.onValueChanged = function (event) { var _a = this.props, valuePath = _a.valuePath, properties = _a.properties, pushData = _a.pushData; var newProperties = set(properties, "controls." + valuePath, event.target.checked); pushData({ properties: newProperties }); }; CheckboxControl.defaultProps = { checked: false, disabled: false, showDisabledMessage: false, }; return CheckboxControl; }(React.Component)); exports.default = react_intl_1.injectIntl(CheckboxControl); //# sourceMappingURL=CheckboxControl.js.map