@arche-mc2/arche-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
63 lines • 3.38 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var UpCheckBox_1 = require("../../Inputs/Checkbox/UpCheckBox");
var UpDataGridCellHeader_1 = require("./UpDataGridCellHeader");
var UpDataGrid_1 = require("./UpDataGrid");
var UpDataGridRowHeader = (function (_super) {
tslib_1.__extends(UpDataGridRowHeader, _super);
function UpDataGridRowHeader(props, context) {
var _this = _super.call(this, props, context) || this;
_this.onSelectionChange = function (event, 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: [tslib_1.__assign({ checked: this.props.isAllDataChecked, name: "", value: "", onOptionChange: this.onSelectionChange }, (!this.props.isSelectionAllEnabled && { disabled: true }))] });
return (React.createElement("thead", { className: "up-data-grid-header" },
React.createElement("tr", null,
this.props.isSelectionEnabled &&
React.createElement(UpDataGridCellHeader_1.default, { key: "header-selection", className: "up-data-grid-header-cell-selection", column: { label: selection, isSortable: false }, textAlignCells: this.props.textAlignCells, width: "" }),
this.props.columns.map(function (value, index) {
return React.createElement(UpDataGridCellHeader_1.default, { key: "header-" + index, onSortChange: _this.onSortChange.bind(_this), column: value, textAlignCells: _this.props.textAlignCells });
}),
UpDataGrid_1.isActionEnabled(this.props) &&
React.createElement(UpDataGridCellHeader_1.default, { key: "header-actions", width: this.props.actions.length * 46 + "px", column: { label: "", isSortable: false }, textAlignCells: this.props.textAlignCells }))));
};
UpDataGridRowHeader.defaultProps = {
isSelectionEnabled: true,
columns: [],
actions: null
};
return UpDataGridRowHeader;
}(React.Component));
exports.default = UpDataGridRowHeader;
//# sourceMappingURL=UpDataGridRowHeader.js.map