@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
63 lines • 3.03 kB
JavaScript
;
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 noop = require("lodash/noop");
var Button_1 = require("@gooddata/goodstrap/lib/Button/Button");
var layout_1 = require("../constants/layout");
var LAST_ADDED_TOTAL_ROW_HIGHLIGHT_PERIOD = 1000;
var RemoveRows = /** @class */ (function (_super) {
__extends(RemoveRows, _super);
function RemoveRows(props) {
var _this = _super.call(this, props) || this;
_this.setWrapperRef = _this.setWrapperRef.bind(_this);
return _this;
}
RemoveRows.prototype.render = function () {
var _this = this;
var _a = this.props, totalsWithData = _a.totalsWithData, lastAddedTotalType = _a.lastAddedTotalType;
var style = { bottom: layout_1.TOTALS_ADD_ROW_HEIGHT + "px" };
if (lastAddedTotalType) {
setTimeout(this.props.onLastAddedTotalRowHighlightPeriodEnd, LAST_ADDED_TOTAL_ROW_HIGHLIGHT_PERIOD);
}
return (React.createElement("div", { className: "indigo-totals-remove", style: style, ref: this.setWrapperRef }, totalsWithData.map(function (total) { return _this.renderRow(total); })));
};
RemoveRows.prototype.getWrapperRef = function () {
return this.wrapperRef;
};
RemoveRows.prototype.setWrapperRef = function (ref) {
this.wrapperRef = ref;
};
RemoveRows.prototype.renderRow = function (total) {
var _a = this.props, onRemove = _a.onRemove, lastAddedTotalType = _a.lastAddedTotalType;
var islastAddedTotalType = total.type === lastAddedTotalType;
var classes = classNames("indigo-totals-remove-row", "totals-remove-row-" + total.type, {
"last-added": islastAddedTotalType,
});
var onClick = function () { return onRemove(total.type); };
return (React.createElement("div", { className: classes, key: "totals-row-overlay-" + total.type },
React.createElement(Button_1.default, { className: classNames("s-totals-rows-remove-" + total.type, "indigo-totals-row-remove-button"), onClick: onClick })));
};
RemoveRows.defaultProps = {
onRemove: noop,
onLastAddedTotalRowHighlightPeriodEnd: noop,
totalsWithData: [],
};
return RemoveRows;
}(React.Component));
exports.RemoveRows = RemoveRows;
//# sourceMappingURL=RemoveRows.js.map