Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/@buffetjs/core/build/esm/components/TableHeader/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
*
* TableHeader
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { get } from 'lodash';
import { Checkbox } from '@buffetjs/styles';
import Icon from '../Icon';
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
/* eslint-disable jsx-a11y/control-has-associated-label */
function TableHeader(_ref) {
var headers = _ref.headers,
onChangeSort = _ref.onChangeSort,
onSelectAll = _ref.onSelectAll,
rows = _ref.rows,
shouldAddCell = _ref.shouldAddCell,
sortBy = _ref.sortBy,
sortOrder = _ref.sortOrder,
withBulkAction = _ref.withBulkAction;
var checked = rows.length > 0 && rows.every(function (row) {
return row._isChecked === true;
});
var shouldDisplayNotChecked = rows.some(function (row) {
return row._isChecked === true;
}) && !checked;
return /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, withBulkAction && /*#__PURE__*/React.createElement("th", {
className: "checkCell"
}, /*#__PURE__*/React.createElement(Checkbox, {
onChange: onSelectAll,
checked: checked,
someChecked: shouldDisplayNotChecked
})), headers.map(function (header) {
var isSortEnabled = header.isSortEnabled,
name = header.name,
value = header.value;
var shouldDisplaySort = isSortEnabled && sortBy === value;
var firstElementThatCanBeSorted = get(headers.filter(function (h) {
return h.isSortEnabled;
}), [0, 'value'], null);
return (
/*#__PURE__*/
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
React.createElement("th", {
key: value,
onClick: function onClick() {
onChangeSort({
sortBy: value,
firstElementThatCanBeSorted: firstElementThatCanBeSorted,
isSortEnabled: isSortEnabled
});
}
}, /*#__PURE__*/React.createElement("p", {
className: isSortEnabled ? 'clickable' : ''
}, name, shouldDisplaySort && /*#__PURE__*/React.createElement(Icon, {
icon: sortOrder || 'asc'
})))
);
}), shouldAddCell && /*#__PURE__*/React.createElement("th", null)));
}
TableHeader.defaultProps = {
headers: [],
onChangeSort: function onChangeSort() {},
onSelectAll: function onSelectAll() {},
rows: [],
shouldAddCell: false,
sortBy: null,
sortOrder: 'asc',
withBulkAction: false
};
TableHeader.propTypes = {
headers: PropTypes.arrayOf(PropTypes.shape({
isSortEnabled: PropTypes.bool,
name: PropTypes.string,
value: PropTypes.string
})),
onChangeSort: PropTypes.func,
onSelectAll: PropTypes.func,
rows: PropTypes.instanceOf(Array),
shouldAddCell: PropTypes.bool,
sortBy: PropTypes.string,
sortOrder: PropTypes.string,
withBulkAction: PropTypes.bool
};
export default TableHeader; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0045 ]-- |