DocSpace-client/packages/components/table-container/StyledTableContainer.js

531 lines
12 KiB
JavaScript
Raw Normal View History

import styled, { css } from "styled-components";
import Base from "../themes/base";
import { mobile, tablet } from "../utils/device";
import IconButton from "../icon-button";
import Scrollbar from "../scrollbar";
2023-10-08 04:48:46 +00:00
2023-11-10 07:20:02 +00:00
import { ColorTheme } from "../ColorTheme";
import {
getCorrectBorderRadius,
getCorrectFourValuesStyle,
} from "../utils/rtlUtils";
2021-07-09 08:59:20 +00:00
const reactWindowContainerStyles = css`
height: 100%;
display: block;
`;
const reactWindowBodyStyles = css`
display: block;
height: 100%;
`;
2021-07-15 07:57:06 +00:00
const StyledTableContainer = styled.div`
2023-02-09 11:28:01 +00:00
user-select: none;
2022-04-06 11:34:00 +00:00
width: 100%;
2021-07-13 08:07:50 +00:00
max-width: 100%;
margin-top: -25px;
2021-07-15 07:57:06 +00:00
display: grid;
2021-07-09 08:59:20 +00:00
.table-column {
user-select: none;
position: relative;
min-width: 10%;
}
.resize-handle {
display: block;
cursor: ew-resize;
height: 10px;
margin: ${({ theme }) =>
getCorrectFourValuesStyle("14px 0px 0 auto", theme.interfaceDirection)};
2021-07-09 08:59:20 +00:00
z-index: 1;
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `border-left: ${theme.tableContainer.borderRight};`
: `border-right: ${theme.tableContainer.borderRight};`}
&:hover {
border-color: ${(props) => props.theme.tableContainer.hoverBorderColor};
}
2021-07-09 08:59:20 +00:00
}
.table-container_group-menu,
.table-container_header {
z-index: 200;
2022-02-24 08:20:32 +00:00
padding: 0 20px;
border-bottom: 1px solid;
border-image-slice: 1;
border-image-source: ${(props) =>
props.theme.tableContainer.header.borderImageSource};
border-top: 0;
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `border-right: 0;`
: `border-left: 0;`}
}
@media (hover: hover) {
&:has(#table-container_caption-header:not(.hotkeys-lengthen-header)):has(
.table-list-item:first-child .table-container_row:hover
) {
.table-container_header,
.table-container_group-menu {
border-image-source: ${(props) =>
props.theme.tableContainer.header.borderHoverImageSource};
}
}
}
2023-10-06 12:59:00 +00:00
.lengthen-header {
border-image-slice: 1;
border-image-source: ${(props) =>
props.theme.tableContainer.header.lengthenBorderImageSource};
}
.hotkeys-lengthen-header {
border-bottom: ${(props) =>
props.theme.tableContainer.header.hotkeyBorderBottom};
border-image-source: none;
}
2021-07-09 08:59:20 +00:00
.content-container {
overflow: hidden;
}
.children-wrap {
display: flex;
flex-direction: column;
}
.table-cell {
height: 47px;
border-bottom: ${(props) => props.theme.tableContainer.tableCellBorder};
2021-07-09 08:59:20 +00:00
}
.table-container_group-menu {
.table-container_group-menu-checkbox {
width: 22px;
}
}
${({ useReactWindow }) => useReactWindow && reactWindowContainerStyles}
2021-07-09 08:59:20 +00:00
`;
StyledTableContainer.defaultProps = {
theme: Base,
};
const StyledTableGroupMenu = styled.div`
position: relative;
background: ${(props) => props.theme.tableContainer.groupMenu.background};
border-bottom: ${(props) =>
props.theme.tableContainer.groupMenu.borderBottom};
box-shadow: ${(props) => props.theme.tableContainer.groupMenu.boxShadow};
border-radius: ${({ theme }) =>
getCorrectBorderRadius("0px 0px 6px 6px", theme.interfaceDirection)};
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
height: 100%;
z-index: 199;
margin: 0;
.table-container_group-menu-checkbox {
${(props) =>
props.theme.interfaceDirection === "rtl"
? `
margin-right: 28px;
${props.checkboxMargin && `margin-right: ${props.checkboxMargin};`}`
: `
margin-left: 28px;
${props.checkboxMargin && `margin-left: ${props.checkboxMargin};`}`}
@media ${tablet} {
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `margin-right: 24px;`
: `margin-left: 24px;`}
}
}
.table-container_group-menu-separator {
${(props) =>
props.theme.interfaceDirection === "rtl"
? `border-left: ${props.theme.tableContainer.groupMenu.borderRight};`
: `border-right: ${props.theme.tableContainer.groupMenu.borderRight};`}
width: 1px;
height: 21px;
margin: ${({ theme }) =>
getCorrectFourValuesStyle("0 16px 0 20px", theme.interfaceDirection)};
@media ${tablet} {
height: 36px;
}
@media ${mobile} {
height: 20px;
}
}
.table-container_group-menu_button {
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `margin-left: 8px;`
: `margin-right: 8px;`}
}
.table-container_group-menu-combobox {
height: 24px;
width: 16px;
margin: ${({ theme }) =>
getCorrectFourValuesStyle("7px 2px 0px 9px", theme.interfaceDirection)};
background: transparent;
.combo-button {
.combo-buttons_arrow-icon {
margin: ${({ theme }) =>
getCorrectFourValuesStyle("1px 16px 0 0", theme.interfaceDirection)};
}
}
}
2023-08-15 14:42:35 +00:00
.scroll-body {
display: flex;
}
2021-07-15 07:57:06 +00:00
`;
StyledTableGroupMenu.defaultProps = { theme: Base };
const StyledInfoPanelToggleColorThemeWrapper = styled(ColorTheme)`
display: flex;
2022-05-12 14:16:57 +00:00
align-items: center;
align-self: center;
justify-content: center;
margin: ${({ theme }) =>
2023-10-08 04:48:46 +00:00
getCorrectFourValuesStyle("0 20px 0 auto", theme.interfaceDirection)};
height: 100%;
width: auto;
.info-panel-toggle {
margin-inline-end: 8px;
}
${(props) =>
props.isInfoPanelVisible &&
css`
.info-panel-toggle-bg {
height: 30px;
width: 30px;
background: ${props.theme.backgroundAndSubstrateColor};
border: 1px solid ${props.theme.backgroundAndSubstrateColor};
border-radius: 50%;
.info-panel-toggle {
margin: auto;
margin-top: 25%;
}
}
`}
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `
padding-right: 20px;
padding-left: 0;`
: `
padding-left: 20px;
padding-right: 0;`}
@media ${tablet} {
display: none;
margin: ${({ theme }) =>
getCorrectFourValuesStyle("0 16px 0 auto", theme.interfaceDirection)};
}
2022-05-12 14:16:57 +00:00
margin-top: 1px;
.info-panel-toggle-bg {
2022-04-11 08:11:44 +00:00
margin-bottom: 1px;
}
.info-panel-toggle svg {
${({ theme }) =>
theme.interfaceDirection === "rtl" && `transform: scaleX(-1);`}
}
`;
StyledInfoPanelToggleColorThemeWrapper.defaultProps = {
theme: Base,
};
2021-07-15 07:57:06 +00:00
const StyledTableHeader = styled.div`
position: fixed;
background: ${(props) => props.theme.tableContainer.header.background};
2021-07-15 07:57:06 +00:00
display: grid;
z-index: 1;
height: 39px;
border-bottom: ${(props) => props.theme.tableContainer.header.borderBottom};
2021-10-22 12:01:43 +00:00
margin: 0 -20px;
padding: 0 20px;
.table-container_header-checkbox {
${(props) =>
props.checkboxMargin &&
(props.interfaceDirection === "rtl"
? `margin-right: ${props.checkboxMargin}`
: `margin-left: ${props.checkboxMargin}`)}
}
.table-container_header-cell {
overflow: hidden;
}
2021-07-15 07:57:06 +00:00
`;
StyledTableHeader.defaultProps = {
theme: Base,
};
const StyledTableHeaderCell = styled.div`
cursor: ${(props) =>
props.showIcon && props.sortingVisible ? "pointer" : "default"};
.header-container-text-icon {
padding: ${({ theme }) =>
getCorrectFourValuesStyle("13px 0 0 4px", theme.interfaceDirection)};
display: ${(props) =>
props.isActive && props.showIcon ? "block" : "none"};
${(props) =>
props.sorted &&
css`
transform: scale(1, -1);
padding: ${getCorrectFourValuesStyle(
"14px 0 14px 4px",
props.theme.interfaceDirection
)};
`}
svg {
width: 12px;
height: 12px;
path {
fill: ${(props) =>
props.isActive
? props.theme.tableContainer.header.activeIconColor
: props.theme.tableContainer.header.iconColor} !important;
}
}
&:hover {
path {
fill: ${(props) =>
props.theme.tableContainer.header.hoverIconColor} !important;
}
}
}
:hover {
.header-container-text-icon {
${(props) =>
props.showIcon &&
css`
display: block;
`};
}
}
2021-07-27 12:22:51 +00:00
.table-container_header-item {
display: grid;
grid-template-columns: 1fr 22px;
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `margin-left: 8px;`
: `margin-right: 8px;`}
user-select: none;
}
.header-container-text-wrapper {
display: flex;
}
.header-container-text {
height: 38px;
display: flex;
align-items: center;
color: ${(props) =>
props.isActive
? props.theme.tableContainer.header.activeTextColor
: props.theme.tableContainer.header.textColor};
&:hover {
color: ${(props) =>
props.theme.tableContainer.header.hoverTextColor} !important;
}
}
`;
StyledTableHeaderCell.defaultProps = {
theme: Base,
};
2021-07-15 07:57:06 +00:00
const StyledTableBody = styled.div`
display: contents;
${({ useReactWindow }) => useReactWindow && reactWindowBodyStyles}
2021-07-15 07:57:06 +00:00
`;
const StyledTableRow = styled.div`
display: contents;
.table-container_header-checkbox {
svg {
margin: 0;
}
}
.table-container_header-settings {
justify-self: flex-end;
}
.droppable-hover {
background: ${(props) =>
props.dragging
? `${props.theme.dragAndDrop.acceptBackground} !important`
: "none"};
}
.table-container_row-loader {
display: inline-flex;
}
`;
2021-07-15 07:57:06 +00:00
const StyledTableCell = styled.div`
/* padding-right: 8px; */
height: 48px;
max-height: 48px;
border-bottom: ${(props) => props.theme.tableContainer.tableCell.border};
overflow: hidden;
2021-07-15 07:57:06 +00:00
display: flex;
align-items: center;
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `padding-left: 30px;`
: `padding-right: 30px;`}
2021-07-15 07:57:06 +00:00
.react-svg-icon svg {
margin-top: 2px;
}
.table-container_element {
display: ${(props) => (props.checked ? "none" : "flex")};
}
.table-container_row-checkbox {
display: ${(props) => (props.checked ? "flex" : "none")};
2023-03-31 12:57:15 +00:00
padding: 16px;
${({ theme }) =>
theme.interfaceDirection === "rtl"
? `margin-right: -4px;`
: `margin-left: -4px;`}
}
${(props) =>
props.hasAccess &&
css`
:hover {
.table-container_element {
display: none;
}
.table-container_row-checkbox {
display: flex;
}
}
`}
2021-07-09 08:59:20 +00:00
`;
StyledTableCell.defaultProps = {
theme: Base,
};
const StyledTableSettings = styled.div`
margin: ${({ theme }) =>
getCorrectFourValuesStyle("14px 2px 0px 0px", theme.interfaceDirection)};
display: inline-block;
position: relative;
cursor: pointer;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
.table-container_settings-checkbox {
padding: 8px 16px;
}
2021-07-15 07:57:06 +00:00
`;
2021-07-13 08:07:50 +00:00
2021-07-20 13:01:54 +00:00
const StyledEmptyTableContainer = styled.div`
grid-column-start: 1;
grid-column-end: -1;
height: 40px;
`;
const StyledScrollbar = styled(Scrollbar)`
.scroller {
display: flex;
}
.nav-thumb-vertical {
display: none !important;
}
.nav-thumb-horizontal {
2023-10-08 04:48:46 +00:00
@media ${tablet} {
display: none !important;
}
}
`;
StyledTableRow.defaultProps = { theme: Base };
const StyledSettingsIcon = styled(IconButton)`
${(props) =>
props.isDisabled &&
css`
svg {
path {
fill: ${props.theme.tableContainer.header
.settingsIconDisableColor} !important;
}
}
`}
`;
StyledSettingsIcon.defaultProps = {
theme: Base,
};
2021-07-13 08:07:50 +00:00
export {
StyledTableContainer,
StyledTableRow,
StyledTableBody,
StyledTableHeader,
StyledTableHeaderCell,
2021-07-13 08:07:50 +00:00
StyledTableCell,
StyledTableSettings,
StyledTableGroupMenu,
StyledInfoPanelToggleColorThemeWrapper,
2021-07-20 13:01:54 +00:00
StyledEmptyTableContainer,
StyledScrollbar,
StyledSettingsIcon,
2021-07-13 08:07:50 +00:00
};