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/src/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({
headers,
onChangeSort,
onSelectAll,
rows,
shouldAddCell,
sortBy,
sortOrder,
withBulkAction,
}) {
const checked = rows.length > 0 && rows.every(row => row._isChecked === true);
const shouldDisplayNotChecked =
rows.some(row => row._isChecked === true) && !checked;
return (
<thead>
<tr>
{withBulkAction && (
<th className="checkCell">
<Checkbox
onChange={onSelectAll}
checked={checked}
someChecked={shouldDisplayNotChecked}
/>
</th>
)}
{headers.map(header => {
const { isSortEnabled, name, value } = header;
const shouldDisplaySort = isSortEnabled && sortBy === value;
const firstElementThatCanBeSorted = get(
headers.filter(h => h.isSortEnabled),
[0, 'value'],
null
);
return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
<th
key={value}
onClick={() => {
onChangeSort({
sortBy: value,
firstElementThatCanBeSorted,
isSortEnabled,
});
}}
>
<p className={isSortEnabled ? 'clickable' : ''}>
{name}
{shouldDisplaySort && <Icon icon={sortOrder || 'asc'} />}
</p>
</th>
);
})}
{shouldAddCell && <th />}
</tr>
</thead>
);
}
TableHeader.defaultProps = {
headers: [],
onChangeSort: () => {},
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.0046 ]-- |