kea-react
Version:
Componentes comunes de react
62 lines (61 loc) • 3.37 kB
JavaScript
"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");
var signatureCanvas_1 = require("./signatureCanvas");
var formField_1 = require("./fields/formField");
var modal_1 = require("./modal");
var botones_1 = require("./botones");
var SignaturePad = /** @class */ (function (_super) {
__extends(SignaturePad, _super);
function SignaturePad(props) {
var _this = _super.call(this, props) || this;
_this.handleEditar = function () {
_this.setState({ editando: true, firmaTemp: [] });
};
_this.handleGuardar = function () {
_this.setState({ editando: false });
if (_this.props.onChange) {
_this.props.onChange(_this.state.firmaTemp);
}
};
_this.handleOnChange = function (value) {
_this.setState({ firmaTemp: value });
};
_this.handleLimpiar = function () {
_this.setState({ firmaTemp: [] });
};
_this.handleCancelar = function () {
_this.setState({ editando: false });
};
_this.state = { editando: false, firmaTemp: [] };
return _this;
}
SignaturePad.prototype.render = function () {
return (React.createElement("div", { style: { display: "flex", flexFlow: "column" } },
React.createElement(formField_1.FormField, { error: this.props.error, label: this.props.label }, (this.props.value || []).length > 0 &&
React.createElement("div", { style: { width: "100%", height: "200px" }, className: "well" },
React.createElement(signatureCanvas_1.SignatureCanvas, { zoomToFit: true, value: this.props.value || [] }))),
!this.props.isReadOnly &&
React.createElement("div", { style: { alignSelf: "flex-start" } },
React.createElement(botones_1.Button, { style: "info", iconClass: "fa fa-pencil", onClick: this.handleEditar }, "Editar firma")),
this.state.editando &&
React.createElement(modal_1.Modal, { title: "Escriba su firma aquí:", buttonsWithKey: [
React.createElement(botones_1.Button, { key: "0", onClick: this.handleLimpiar, iconClass: "fa fa-trash", style: "danger" }, "Limpiar"),
React.createElement(botones_1.GuardarButton, { key: "1", onClick: this.handleGuardar })
], fullScreen: true, onClose: this.handleCancelar },
React.createElement("div", { style: { flex: 1, display: "flex" } },
React.createElement(signatureCanvas_1.SignatureCanvas, { value: this.state.firmaTemp, onChange: this.handleOnChange })))));
};
return SignaturePad;
}(React.Component));
exports.SignaturePad = SignaturePad;