UNPKG

@gooddata/react-components

Version:

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

67 lines 3.42 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) 2007-2019 GoodData Corporation var React = require("react"); var classNames = require("classnames"); var react_intl_1 = require("react-intl"); var noop = require("lodash/noop"); var sort_1 = require("../../../constants/sort"); var TableSortBubbleContentClass = /** @class */ (function (_super) { __extends(TableSortBubbleContentClass, _super); function TableSortBubbleContentClass(props) { var _this = _super.call(this, props) || this; _this.sortAsc = _this.handleSort.bind(_this, sort_1.ASC); _this.sortDesc = _this.handleSort.bind(_this, sort_1.DESC); return _this; } TableSortBubbleContentClass.prototype.render = function () { var _a = this.props, title = _a.title, onClose = _a.onClose; return (React.createElement("div", null, React.createElement("button", { className: "close-button gd-button-link gd-button-icon-only icon-cross", onClick: onClose }), React.createElement("div", { className: "gd-dialog-header gd-heading-3" }, title), React.createElement(react_intl_1.FormattedMessage, { id: "visualizations.sorting" }), React.createElement("div", { className: "buttons-wrap" }, React.createElement("div", { className: "buttons" }, this.renderButton(sort_1.ASC), this.renderButton(sort_1.DESC))))); }; TableSortBubbleContentClass.prototype.renderButton = function (dir) { var activeSortDir = this.props.activeSortDir; var isDisabled = dir === activeSortDir; var buttonClasses = classNames("gd-button", "gd-button-primary", "gd-button-small", "icon-dropdown", "icon-right", { "button-sort-asc": dir === sort_1.ASC, "button-sort-desc": dir === sort_1.DESC, disabled: isDisabled, }); var onClick = dir === sort_1.ASC ? this.sortAsc : this.sortDesc; var msg = dir === sort_1.ASC ? "visualizations.asc" : "visualizations.desc"; return (React.createElement("button", { onClick: onClick, disabled: isDisabled, className: buttonClasses }, React.createElement(react_intl_1.FormattedMessage, { id: msg }))); }; TableSortBubbleContentClass.prototype.handleSort = function (dir, e) { this.props.onSortChange(dir, e); this.props.onClose(); }; TableSortBubbleContentClass.defaultProps = { activeSortDir: null, onClose: noop, onSortChange: noop, }; return TableSortBubbleContentClass; }(React.Component)); exports.TableSortBubbleContentClass = TableSortBubbleContentClass; exports.TableSortBubbleContent = react_intl_1.injectIntl(TableSortBubbleContentClass); //# sourceMappingURL=TableSortBubbleContent.js.map