DocSpace-buildtools/packages/components/table-container/TableHeaderCell.js

126 lines
3.4 KiB
JavaScript
Raw Normal View History

import React from "react";
import PropTypes from "prop-types";
import Text from "../text";
import IconButton from "../icon-button";
import globalColors from "../utils/globalColors";
import { StyledTableHeaderCell } from "./StyledTableContainer";
2021-07-28 14:22:50 +00:00
const TableHeaderCell = ({
column,
index,
onMouseDown,
resizable,
sortBy,
sorted,
defaultSize,
sortingVisible,
tagRef,
2021-07-28 14:22:50 +00:00
}) => {
const { title, enable, active, minWidth, withTagRef } = column;
2021-10-18 11:30:49 +00:00
const isActive = (sortBy && column.sortBy === sortBy) || active;
2021-07-27 12:22:51 +00:00
const onClick = (e) => {
if (!sortingVisible) return;
column.onClick && column.onClick(column.sortBy, e);
};
const onIconClick = (e) => {
if (!sortingVisible) return;
column.onIconClick();
e.stopPropagation();
};
return withTagRef ? (
<StyledTableHeaderCell
sorted={sorted}
isActive={isActive}
showIcon={column.onClick}
className="table-container_header-cell"
id={`column_${index}`}
data-enable={enable}
data-min-width={minWidth}
data-default-size={defaultSize}
onClick={onClick}
sortingVisible={sortingVisible}
ref={tagRef}
>
<div className="table-container_header-item">
<div className="header-container-text-wrapper">
<Text fontWeight={600} className="header-container-text">
{enable ? title : ""}
</Text>
{sortingVisible && (
<IconButton
onClick={column.onIconClick ? onIconClick : onClick}
iconName="/static/images/sort.desc.react.svg"
className="header-container-text-icon"
size="small"
color={isActive ? globalColors.grayMain : globalColors.gray}
/>
)}
</div>
{resizable && (
<div
data-column={`${index}`}
className="resize-handle not-selectable"
onMouseDown={onMouseDown}
/>
)}
</div>
</StyledTableHeaderCell>
) : (
<StyledTableHeaderCell
sorted={sorted}
2021-07-27 12:22:51 +00:00
isActive={isActive}
showIcon={column.onClick}
className="table-container_header-cell"
id={`column_${index}`}
data-enable={enable}
data-min-width={minWidth}
data-default-size={defaultSize}
onClick={onClick}
sortingVisible={sortingVisible}
>
<div className="table-container_header-item">
<div className="header-container-text-wrapper">
<Text fontWeight={600} className="header-container-text">
2021-07-27 10:51:56 +00:00
{enable ? title : ""}
</Text>
{sortingVisible && (
<IconButton
onClick={column.onIconClick ? onIconClick : onClick}
2022-02-22 13:00:26 +00:00
iconName="/static/images/sort.desc.react.svg"
className="header-container-text-icon"
size="small"
Merge branch 'master' into develop # Conflicts: # common/ASC.Core.Common/Data/DbSubscriptionService.cs # common/ASC.Core.Common/Notify/Signalr/SignalrServiceClient.cs # common/services/ASC.ElasticSearch/Engine/FactoryIndexer.cs # common/services/ASC.ElasticSearch/Service/Settings.cs # common/services/ASC.Socket.IO.Svc/ASC.Socket.IO.Svc.csproj # common/services/ASC.Socket.IO.Svc/SocketServiceLauncher.cs # packages/asc-web-components/combobox/index.js # packages/asc-web-components/table-container/StyledTableContainer.js # packages/asc-web-components/table-container/TableGroupMenu.js # packages/asc-web-components/table-container/TableHeader.js # packages/asc-web-components/table-container/TableHeaderCell.js # packages/asc-web-components/table-container/TableRow.js # products/ASC.Files/Client/public/locales/az/Home.json # products/ASC.Files/Client/public/locales/bg/Home.json # products/ASC.Files/Client/public/locales/bg/Translations.json # products/ASC.Files/Client/public/locales/cs/Home.json # products/ASC.Files/Client/public/locales/de/ConvertDialog.json # products/ASC.Files/Client/public/locales/de/Home.json # products/ASC.Files/Client/public/locales/de/Translations.json # products/ASC.Files/Client/public/locales/de/UploadPanel.json # products/ASC.Files/Client/public/locales/el/ConvertDialog.json # products/ASC.Files/Client/public/locales/el/Home.json # products/ASC.Files/Client/public/locales/en/ConvertDialog.json # products/ASC.Files/Client/public/locales/en/Home.json # products/ASC.Files/Client/public/locales/en/Translations.json # products/ASC.Files/Client/public/locales/en/UploadPanel.json # products/ASC.Files/Client/public/locales/es/ConvertDialog.json # products/ASC.Files/Client/public/locales/es/Home.json # products/ASC.Files/Client/public/locales/es/UploadPanel.json # products/ASC.Files/Client/public/locales/fi/Home.json # products/ASC.Files/Client/public/locales/fr/ConvertDialog.json # products/ASC.Files/Client/public/locales/fr/Home.json # products/ASC.Files/Client/public/locales/fr/Translations.json # products/ASC.Files/Client/public/locales/it/ConvertDialog.json # products/ASC.Files/Client/public/locales/it/Home.json # products/ASC.Files/Client/public/locales/it/Translations.json # products/ASC.Files/Client/public/locales/it/UploadPanel.json # products/ASC.Files/Client/public/locales/ja/Home.json # products/ASC.Files/Client/public/locales/ja/UploadPanel.json # products/ASC.Files/Client/public/locales/lv/Home.json # products/ASC.Files/Client/public/locales/nl/Home.json # products/ASC.Files/Client/public/locales/nl/Translations.json # products/ASC.Files/Client/public/locales/pl/Home.json # products/ASC.Files/Client/public/locales/pt-BR/ConvertDialog.json # products/ASC.Files/Client/public/locales/pt-BR/Home.json # products/ASC.Files/Client/public/locales/pt-BR/Translations.json # products/ASC.Files/Client/public/locales/ro/Home.json # products/ASC.Files/Client/public/locales/ro/UploadPanel.json # products/ASC.Files/Client/public/locales/ru/ConvertDialog.json # products/ASC.Files/Client/public/locales/ru/Home.json # products/ASC.Files/Client/public/locales/ru/Translations.json # products/ASC.Files/Client/public/locales/ru/UploadPanel.json # products/ASC.Files/Client/public/locales/sk/Home.json # products/ASC.Files/Client/public/locales/tr/Home.json # products/ASC.Files/Client/public/locales/uk/Home.json # products/ASC.Files/Client/public/locales/vi/ConvertDialog.json # products/ASC.Files/Client/public/locales/vi/Home.json # products/ASC.Files/Client/public/locales/zh-CN/Home.json # products/ASC.Files/Client/public/locales/zh-CN/UploadPanel.json # products/ASC.Files/Client/src/HOCs/withBadges.js # products/ASC.Files/Client/src/HOCs/withContent.js # products/ASC.Files/Client/src/components/Badges.js # products/ASC.Files/Client/src/components/EditingWrapperComponent.js # products/ASC.Files/Client/src/components/panels/OperationsPanel/index.js # products/ASC.Files/Client/src/components/panels/SharingPanel/index.js # products/ASC.Files/Client/src/components/panels/UploadPanel/FileRow.js # products/ASC.Files/Client/src/pages/Home/Section/Body/RowsView/SimpleFilesRow.js # products/ASC.Files/Client/src/pages/Home/Section/Body/TableView/TableHeader.js # products/ASC.Files/Client/src/pages/Home/Section/Body/TableView/TableRow.js # products/ASC.Files/Client/src/pages/Home/Section/Body/TilesView/FileTile.js # products/ASC.Files/Client/src/pages/Home/Section/Body/TilesView/sub-components/Tile.js # products/ASC.Files/Client/src/pages/Home/Section/Body/index.js # products/ASC.Files/Client/src/store/DialogsStore.js # products/ASC.Files/Client/src/store/FilesActionsStore.js # products/ASC.Files/Core/HttpHandlers/FileHandler.ashx.cs # products/ASC.Files/Core/Utils/FileConverter.cs # products/ASC.Files/Server/Helpers/FilesControllerHelper.cs # products/ASC.Files/Service/Thumbnail/Builder.cs # products/ASC.Files/Service/Thumbnail/ThumbnailSettings.cs # products/ASC.Files/Service/Thumbnail/Worker.cs # products/ASC.People/Client/src/pages/Home/Section/Body/TableView/TableRow.js # public/locales/de/Common.json
2022-02-21 19:22:38 +00:00
color={isActive ? globalColors.grayMain : globalColors.gray}
/>
)}
</div>
{resizable && (
<div
data-column={`${index}`}
className="resize-handle not-selectable"
onMouseDown={onMouseDown}
/>
)}
</div>
</StyledTableHeaderCell>
);
};
TableHeaderCell.propTypes = {
column: PropTypes.object,
index: PropTypes.number,
onMouseDown: PropTypes.func,
resizable: PropTypes.bool,
2021-07-28 14:22:50 +00:00
sorted: PropTypes.bool,
2021-07-27 12:22:51 +00:00
sortBy: PropTypes.string,
defaultSize: PropTypes.number,
sortingVisible: PropTypes.bool,
};
export default TableHeaderCell;