UNPKG

kea-react

Version:

Componentes comunes de react

51 lines (50 loc) 2.46 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var 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 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 }); var React = require("react"); /**Un checkbox de un input simple */ var SimpleCheckbox = /** @class */ (function (_super) { __extends(SimpleCheckbox, _super); function SimpleCheckbox() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.handleChange = function (event) { if (_this.props.onChange) _this.props.onChange(event.currentTarget.checked); }; return _this; } SimpleCheckbox.prototype.render = function () { return (React.createElement("input", { type: "checkbox", checked: this.props.value || false, disabled: this.props.isReadOnly, onChange: this.handleChange })); }; return SimpleCheckbox; }(React.PureComponent)); /**Un checkbox. Si no se establece un label el checkbox sera solamente el input, si se * establece un label el checkbox sera el checkbox estilizado para bootstrap */ var Checkbox = /** @class */ (function (_super) { __extends(Checkbox, _super); function Checkbox() { return _super !== null && _super.apply(this, arguments) || this; } Checkbox.prototype.render = function () { return (this.props.label ? React.createElement("div", { className: "checkbox" }, React.createElement("label", null, React.createElement(SimpleCheckbox, { value: this.props.value, isReadOnly: this.props.isReadOnly, onChange: this.props.onChange }), " ", React.createElement("span", { style: this.props.error ? { color: "red" } : {} }, this.props.label))) : React.createElement(SimpleCheckbox, { value: this.props.value, isReadOnly: this.props.isReadOnly, onChange: this.props.onChange })); }; return Checkbox; }(React.PureComponent)); exports.Checkbox = Checkbox;