@up-group/react-controls
Version:
We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get
72 lines • 3.53 kB
JavaScript
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 UpCheckBox_1 = require("../../Inputs/Checkbox/UpCheckBox");
var UpDataGridCellHeader_1 = require("./UpDataGridCellHeader");
var UpDataGridRowHeader = (function (_super) {
__extends(UpDataGridRowHeader, _super);
function UpDataGridRowHeader(props, context) {
var _this = _super.call(this, props, context) || this;
_this.onSelectionChange = function (isSelected) {
if (_this.props.onSelectionChange)
_this.props.onSelectionChange(isSelected);
};
_this.onSortChange = function (c, dir) {
var columns = [];
var sortedColumn = c;
sortedColumn.sortDir = dir;
_this.state.columns.map(function (value, index) {
value.isSorted = (c.field == value.field);
if (value.isSorted)
value.sortDir = dir;
else
value.sortDir = null;
columns.push(value);
});
_this.setState({ columns: columns }, function () {
if (_this.props.onSortChange)
_this.props.onSortChange(sortedColumn, dir);
});
};
_this.state = {
isSelected: false,
columns: _this.props.columns
};
return _this;
}
UpDataGridRowHeader.prototype.componentWillReceiveProps = function (nextProps) {
this.setState({ isSelected: false, columns: nextProps.columns });
};
UpDataGridRowHeader.prototype.render = function () {
var _this = this;
var selection = React.createElement(UpCheckBox_1.default, { options: [{ name: "", value: "", onChange: this.onSelectionChange }] });
var isActionEnabled = this.props.actions && this.props.actions.length > 0;
return (React.createElement("thead", { className: "up-data-grid-header" },
React.createElement("tr", null,
this.props.isSelectionEnabled &&
React.createElement(UpDataGridCellHeader_1.default, { key: "header-selection", column: { label: selection, isSortable: false } }),
this.props.columns.map(function (value, index) {
return React.createElement(UpDataGridCellHeader_1.default, { key: "header-" + index, onSortChange: _this.onSortChange.bind(_this), column: value });
}),
isActionEnabled &&
React.createElement(UpDataGridCellHeader_1.default, { key: "header-actions", width: this.props.actions.length * 46 + "px", column: { label: "", isSortable: false } }))));
};
UpDataGridRowHeader.defaultProps = {
isSelectionEnabled: true,
columns: [],
actions: []
};
return UpDataGridRowHeader;
}(React.Component));
exports.default = UpDataGridRowHeader;
//# sourceMappingURL=UpDataGridRowHeader.js.map
;