UNPKG

@bigfishtv/cockpit

Version:

56 lines (43 loc) 2.52 kB
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import React, { Component } from 'react'; import { Cell } from 'fixed-data-table'; import Checkbox from '../../input/Checkbox'; /** * Table cell for displaying a boolean value */ var FixedDataTableCheckboxSelectHeaderCell = function (_Component) { _inherits(FixedDataTableCheckboxSelectHeaderCell, _Component); function FixedDataTableCheckboxSelectHeaderCell() { _classCallCheck(this, FixedDataTableCheckboxSelectHeaderCell); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } FixedDataTableCheckboxSelectHeaderCell.prototype.render = function render() { var _props = this.props, data = _props.data, selectedIds = _props.selectedIds, onSelectionChange = _props.onSelectionChange, props = _objectWithoutProperties(_props, ['data', 'selectedIds', 'onSelectionChange']); var selectedAll = selectedIds.length === data.length && data.length > 0; return React.createElement( Cell, props, React.createElement( 'div', { className: 'table-checkbox-wrapper' }, React.createElement(Checkbox, { value: selectedAll, onChange: function onChange(value) { return onSelectionChange(selectedAll ? [] : data.map(function (item) { return item.id; })); } }) ) ); }; return FixedDataTableCheckboxSelectHeaderCell; }(Component); export { FixedDataTableCheckboxSelectHeaderCell as default };