UNPKG

kea-react

Version:

Componentes comunes de react

61 lines (60 loc) 3.79 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 __()); }; })(); var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var text_1 = require("../../fields/text"); var botones_1 = require("../../botones"); var mappings_1 = require("./mappings"); var export_1 = require("./export"); /**Compoonente que muestra el texto de búsqueda y el botón para descargar CSV */ var GridBusquedaComponent = /** @class */ (function (_super) { __extends(GridBusquedaComponent, _super); function GridBusquedaComponent(props) { var _this = _super.call(this, props) || this; _this.handleBusquedaChange = function (value) { var oldValue = _this.props.value; var newValue = __assign({}, oldValue, { filtroOrden: __assign({}, oldValue.filtroOrden, { busqueda: value }) }); _this.props.onChange(newValue); }; _this.handleOnExportChange = function (value) { var oldValue = _this.props.value; var newValue = __assign({}, oldValue, { export: value }); _this.props.onChange(newValue); }; _this.state = { showMappingModal: false, showExportarModal: false }; return _this; } GridBusquedaComponent.prototype.render = function () { var _this = this; var _a = this, props = _a.props, state = _a.state; return (React.createElement("div", { style: { display: "flex", flexDirection: "row" } }, React.createElement("div", { style: { flex: "1 1 auto" } }, React.createElement(text_1.Text, { value: this.props.value.filtroOrden.busqueda, placeholder: "Búsqueda", onChange: this.handleBusquedaChange, addon: React.createElement("i", { className: "fa fa-search" }) })), React.createElement("div", { style: { flex: "0 1 auto" } }, React.createElement(botones_1.Button, { tooltip: "Columnas", style: "info", iconClass: "fa fa-columns", onClick: function () { return _this.setState({ showMappingModal: true }); } })), React.createElement("div", { style: { flex: "0 1 auto" } }, React.createElement(botones_1.Button, { tooltip: "Descargar CSV", style: "success", iconClass: "fa fa-download", onClick: function () { return _this.setState({ showExportarModal: true }); } })), React.createElement(mappings_1.MappingComponent, { columnas: props.columnas, onClose: function () { return _this.setState({ showMappingModal: false }); }, onStateChange: props.onChange, state: props.value, show: state.showMappingModal }), this.state.showExportarModal && React.createElement(export_1.ExportComp, { columnas: props.columnas, onCerrar: function () { return _this.setState({ showExportarModal: false }); }, mapping: props.value.export, onMappingChange: this.handleOnExportChange, onExportar: this.props.onExpotar }))); }; return GridBusquedaComponent; }(React.PureComponent)); exports.GridBusquedaComponent = GridBusquedaComponent;