PromucFlow_constructor/app/client/src/widgets/TableWidget/component/TableStyledWrappers.tsx

582 lines
14 KiB
TypeScript
Raw Normal View History

import styled, { css } from "styled-components";
import { TableSizes, CellLayoutProperties, CellAlignment } from "./Constants";
import { Colors, Color } from "constants/Colors";
import { hideScrollbar } from "constants/DefaultTheme";
import { FontStyleTypes, TEXT_SIZES } from "constants/WidgetConstants";
2020-06-03 10:50:10 +00:00
export const TableWrapper = styled.div<{
width: number;
height: number;
tableSizes: TableSizes;
backgroundColor?: Color;
triggerRowSelection: boolean;
isHeaderVisible?: boolean;
}>`
width: 100%;
height: 100%;
2020-06-03 10:50:10 +00:00
background: white;
border: 1px solid ${Colors.GEYSER_LIGHT};
box-sizing: border-box;
display: flex;
justify-content: space-between;
flex-direction: column;
Fix-Open image in new tab on clicking it in table widget. (#119) * Added Button component in Table widget for actions * Action button state loading added for Table widget * Action button font-weight made as normal * Created header for common functionalities in Table Widget * Client side searching added in Table Widget. Action created for server side searching also. * Columns visibility feature initial commit * Column visibility list added in Table Widget * Changed pagination designs in accordance with new layout. This enable user to jump page as well. * Using colors values from constants * Table widget pagination, numeric input page number clamped between 1 and total pages * Adding tool tip to truncated values in table widget. Added AutoToolTipComponent that adds tooltip when text is truncated. * Table data download changes. Added downlaod icon and button to table widget. * Table data download changes * Table button loading state fixed. Table code refactored, rendering from props instead of state in ReactTableComponent * Table widget action button alignment fixed * Handled actions column changes * added proper keys to useMemo for react table widget * Download table data as CSV implemented * table data download, unused code removed * Code refactors and added dependency map with meta props and table data for computing columns * Table UI breakages on scroll and empty cells fixed * Handled empty rows in table widget * Fixed last row cut issue * Code review changes * Code review changes * Added table widget component heights as enum * code review changes * Search component in Table widget updated with support for clearing data, renamed properties * Opening image in new tab on clicking in table widget * Fixed table craching due to empty data filtering * Empty extra space on loading removed in table widget * Removed stopping of event propagation on table widget action button click * Table header UI overflow fixed * Clearing selected row on searching data in table widget * fix for cypress test Co-authored-by: Arpit Mohan <me@arpitmohan.com>
2020-07-24 10:32:31 +00:00
overflow: hidden;
2020-06-03 10:50:10 +00:00
.tableWrap {
2020-06-16 07:37:39 +00:00
height: 100%;
2020-06-03 10:50:10 +00:00
display: block;
2021-03-18 05:37:16 +00:00
position: relative;
width: ${(props) => props.width - 8}px;
overflow-x: auto;
${hideScrollbar};
2021-04-15 05:01:06 +00:00
.thumb-horizontal {
height: 4px !important;
border-radius: ${(props) => props.theme.radii[3]}px;
background: ${(props) => props.theme.colors.scrollbarLight} !important;
&:hover {
height: 6px !important;
}
}
2020-06-03 10:50:10 +00:00
}
.table {
border-spacing: 0;
color: ${Colors.THUNDER};
2020-06-03 10:50:10 +00:00
position: relative;
background: ${Colors.ATHENS_GRAY_DARKER};
display: table;
width: 100%;
${hideScrollbar};
.thead,
2020-06-03 10:50:10 +00:00
.tbody {
overflow: hidden;
2020-06-03 10:50:10 +00:00
}
.tbody {
height: ${(props) =>
props.isHeaderVisible ? props.height - 80 : props.height - 40}px;
width: 100%;
overflow-y: auto;
${hideScrollbar};
}
2020-06-03 10:50:10 +00:00
.tr {
overflow: hidden;
cursor: ${(props) => props.triggerRowSelection && "pointer"};
background: ${Colors.WHITE};
2020-06-03 10:50:10 +00:00
&.selected-row {
background: ${Colors.NARVIK_GREEN}!important;
2020-06-03 10:50:10 +00:00
}
&:hover {
background: ${Colors.NARVIK_GREEN};
2020-06-03 10:50:10 +00:00
}
}
.th,
.td {
margin: 0;
border-bottom: 1px solid ${Colors.GEYSER_LIGHT};
border-right: 1px solid ${Colors.GEYSER_LIGHT};
position: relative;
2020-12-24 04:32:25 +00:00
font-size: ${(props) => props.tableSizes.ROW_FONT_SIZE}px;
line-height: ${(props) => props.tableSizes.ROW_FONT_SIZE}px;
2020-06-03 10:50:10 +00:00
:last-child {
border-right: 0;
}
.resizer {
display: inline-block;
width: 10px;
height: 100%;
position: absolute;
right: 0;
top: 0;
transform: translateX(50%);
z-index: 1;
${"" /* prevents from scrolling while dragging on touch devices */}
touch-action:none;
&.isResizing {
cursor: isResizing;
}
}
}
.th {
padding: 0 10px 0 0;
height: ${(props) =>
props.isHeaderVisible ? props.tableSizes.COLUMN_HEADER_HEIGHT : 40}px;
line-height: ${(props) =>
props.isHeaderVisible ? props.tableSizes.COLUMN_HEADER_HEIGHT : 40}px;
2020-06-03 10:50:10 +00:00
background: ${Colors.ATHENS_GRAY_DARKER};
}
.td {
2020-12-24 04:32:25 +00:00
height: ${(props) => props.tableSizes.ROW_HEIGHT}px;
line-height: ${(props) => props.tableSizes.ROW_HEIGHT}px;
padding: 0;
2020-06-03 10:50:10 +00:00
}
.thead {
position: sticky;
top: 0;
z-index: 1;
}
2020-11-06 05:21:29 +00:00
.thead {
position: sticky;
top: 0;
z-index: 1;
}
2020-06-03 10:50:10 +00:00
}
.draggable-header,
.hidden-header {
width: 100%;
text-overflow: ellipsis;
overflow: hidden;
color: ${Colors.OXFORD_BLUE};
font-weight: 500;
padding-left: 10px;
&.sorted {
padding-left: 5px;
}
2020-06-03 10:50:10 +00:00
}
.draggable-header {
cursor: pointer;
display: inline-block;
width: 100%;
height: 32px;
2020-06-03 10:50:10 +00:00
&.reorder-line {
width: 1px;
height: 100%;
}
}
.hidden-header {
opacity: 0.6;
}
.column-menu {
cursor: pointer;
2020-12-24 04:32:25 +00:00
height: ${(props) => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
line-height: ${(props) => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
2020-06-03 10:50:10 +00:00
}
.th {
display: flex !important;
2020-06-03 10:50:10 +00:00
justify-content: space-between;
&.highlight-left {
border-left: 2px solid ${Colors.GREEN};
}
&.highlight-right {
border-right: 2px solid ${Colors.GREEN};
}
}
.input-group {
2020-12-24 04:32:25 +00:00
height: ${(props) => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
line-height: ${(props) => props.tableSizes.COLUMN_HEADER_HEIGHT}px;
2020-06-03 10:50:10 +00:00
padding: 0 5px;
}
`;
export const DropDownWrapper = styled.div`
display: flex;
flex-direction: column;
background: white;
z-index: 1;
padding: 10px;
border-radius: 4px;
border: 1px solid ${Colors.ATHENS_GRAY};
box-shadow: 0px 2px 4px rgba(67, 70, 74, 0.14);
`;
export const OptionWrapper = styled.div<{
selected: boolean;
isHeader?: boolean;
}>`
2020-06-03 10:50:10 +00:00
display: flex;
width: 100%;
justify-content: space-between;
height: 32px;
box-sizing: border-box;
padding: 8px;
2020-12-24 04:32:25 +00:00
color: ${(props) => (props.selected ? Colors.WHITE : Colors.OXFORD_BLUE)};
2020-06-03 10:50:10 +00:00
font-size: 14px;
min-width: 200px;
2020-12-24 04:32:25 +00:00
cursor: ${(props) => (!props.isHeader ? "pointer" : "default")};
2020-06-03 10:50:10 +00:00
border-radius: 4px;
margin: 3px 0;
2020-12-24 04:32:25 +00:00
background: ${(props) => (props.selected ? Colors.GREEN : Colors.WHITE)};
2020-06-03 10:50:10 +00:00
&:hover {
2020-12-24 04:32:25 +00:00
background: ${(props) => (props.selected ? Colors.GREEN : Colors.POLAR)};
2020-06-03 10:50:10 +00:00
}
.column-type {
width: 100%;
}
&.non-selectable {
2020-12-24 04:32:25 +00:00
background: ${(props) =>
!props.isHeader ? Colors.WHITE_SMOKE : Colors.WHITE_CLOUD};
2020-06-03 10:50:10 +00:00
}
`;
export const IconOptionWrapper = styled.div`
display: flex;
justify-content: space-between;
width: 100%;
cursor: pointer;
`;
export const PaginationWrapper = styled.div`
box-sizing: border-box;
display: flex;
width: 100%;
justify-content: flex-end;
align-items: center;
padding: 8px 20px;
2021-05-10 11:24:50 +00:00
color: ${Colors.GRAY};
2020-06-03 10:50:10 +00:00
`;
export const PaginationItemWrapper = styled.div<{
disabled?: boolean;
selected?: boolean;
}>`
2021-05-10 11:24:50 +00:00
background: ${(props) => (props.disabled ? Colors.MERCURY : Colors.WHITE)};
border: 1px solid ${Colors.ALTO2};
2020-06-03 10:50:10 +00:00
box-sizing: border-box;
width: 24px;
height: 24px;
2020-06-03 10:50:10 +00:00
display: flex;
justify-content: center;
align-items: center;
margin: 0 4px;
2020-12-24 04:32:25 +00:00
pointer-events: ${(props) => props.disabled && "none"};
2020-06-03 10:50:10 +00:00
cursor: pointer;
&:hover {
border-color: ${Colors.GREEN};
}
.bp3-icon svg {
fill: ${(props) => (props.disabled ? Colors.GREY_4 : "")};
}
2020-06-03 10:50:10 +00:00
`;
export const MenuColumnWrapper = styled.div<{ selected: boolean }>`
display: flex;
justify-content: flex-start;
align-items: center;
width: 100%;
2020-12-24 04:32:25 +00:00
background: ${(props) => props.selected && Colors.GREEN};
2020-06-03 10:50:10 +00:00
position: relative;
.title {
2020-12-24 04:32:25 +00:00
color: ${(props) => (props.selected ? Colors.WHITE : Colors.OXFORD_BLUE)};
2020-06-03 10:50:10 +00:00
margin-left: 10px;
}
.sub-menu {
position: absolute;
right: 0;
}
`;
export const ActionWrapper = styled.div<{
background: string;
buttonLabelColor: string;
}>`
margin: 0 5px 0 0;
&&&&&& {
.bp3-button {
background: ${(props) => props.background};
color: ${(props) => props.buttonLabelColor};
border: none;
}
.bp3-button span {
font-weight: 400;
text-decoration: none;
}
&&& .bp3-disabled {
background: ${Colors.GREY_1};
color: ${Colors.GREY_4};
}
}
2020-06-03 10:50:10 +00:00
`;
const JUSTIFY_CONTENT = {
LEFT: "flex-start",
CENTER: "center",
RIGHT: "flex-end",
};
const TEXT_ALIGN = {
LEFT: "left",
CENTER: "center",
RIGHT: "right",
};
const ALIGN_ITEMS = {
TOP: "flex-start",
CENTER: "center",
BOTTOM: "flex-end",
};
const IMAGE_HORIZONTAL_ALIGN = {
LEFT: "left",
CENTER: "center",
RIGHT: "right",
};
const IMAGE_VERTICAL_ALIGN = {
TOP: "top",
CENTER: "center",
BOTTOM: "bottom",
};
export const TableStyles = css<{
cellProperties?: CellLayoutProperties;
isTextType?: boolean;
}>`
font-weight: ${(props) =>
props?.cellProperties?.fontStyle?.includes(FontStyleTypes.BOLD)
? "bold"
: "normal"};
color: ${(props) => props?.cellProperties?.textColor};
font-style: ${(props) =>
props?.cellProperties?.fontStyle?.includes(FontStyleTypes.ITALIC)
? "italic"
: ""};
text-decoration: ${(props) =>
props?.cellProperties?.fontStyle?.includes(FontStyleTypes.UNDERLINE) &&
props.isTextType
? "underline"
: ""};
justify-content: ${(props) =>
props?.cellProperties?.horizontalAlignment &&
JUSTIFY_CONTENT[props?.cellProperties?.horizontalAlignment]};
align-items: ${(props) =>
props?.cellProperties?.verticalAlignment &&
ALIGN_ITEMS[props?.cellProperties?.verticalAlignment]};
background: ${(props) => props?.cellProperties?.cellBackground};
font-size: ${(props) =>
props?.cellProperties?.textSize &&
TEXT_SIZES[props?.cellProperties?.textSize]};
`;
export const DraggableHeaderWrapper = styled.div<{
horizontalAlignment?: CellAlignment;
}>`
text-align: ${(props) =>
props?.horizontalAlignment && TEXT_ALIGN[props?.horizontalAlignment]};
`;
export const CellWrapper = styled.div<{
isHidden?: boolean;
isPadding?: boolean;
cellProperties?: CellLayoutProperties;
isHyperLink?: boolean;
useLinkToolTip?: boolean;
isCellVisible?: boolean;
isTextType?: boolean;
}>`
display: ${(props) => (props.isCellVisible !== false ? "flex" : "none")};
align-items: ${(props) => (props.isPadding ? "center" : "flex-start")};
2020-06-03 10:50:10 +00:00
justify-content: flex-start;
width: ${(props) => (props.isPadding ? "100%" : "calc(100% - 10px)")};
height: 100%;
2020-06-03 10:50:10 +00:00
overflow: hidden;
text-overflow: ellipsis;
2020-06-16 07:37:39 +00:00
white-space: nowrap;
2020-12-24 04:32:25 +00:00
opacity: ${(props) => (props.isHidden ? "0.6" : "1")};
${TableStyles};
padding: ${(props) => (props.isPadding ? "0 10px" : " 0px")};
line-height: 28px;
.image-cell-wrapper {
width: 100%;
height: 100%;
}
2020-06-03 10:50:10 +00:00
.image-cell {
width: 100%;
height: 100%;
2020-06-03 10:50:10 +00:00
margin: 0 5px 0 0;
border-radius: 4px;
background-position-x: ${(props) =>
props?.cellProperties?.horizontalAlignment &&
IMAGE_HORIZONTAL_ALIGN[props?.cellProperties?.horizontalAlignment]};
background-position-y: ${(props) =>
props?.cellProperties?.verticalAlignment &&
IMAGE_VERTICAL_ALIGN[props?.cellProperties?.verticalAlignment]};
2020-06-03 10:50:10 +00:00
background-repeat: no-repeat;
background-size: contain;
2020-06-03 10:50:10 +00:00
}
video {
border-radius: 4px;
}
${(props) =>
props.isHyperLink &&
`
cursor: pointer;
&:hover {
color: ${Colors.ROYAL_BLUE};
text-decoration: underline;
}`};
2020-06-16 07:37:39 +00:00
&.video-cell {
height: 100%;
iframe {
border: none;
border-radius: 4px;
}
}
.link-text {
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: ${(props) =>
props?.cellProperties?.horizontalAlignment &&
TEXT_ALIGN[props?.cellProperties?.horizontalAlignment]};
}
.hidden-icon {
display: none;
}
&:hover {
.hidden-icon {
display: inline;
}
}
2020-06-03 10:50:10 +00:00
`;
export const CellCheckboxWrapper = styled(CellWrapper)<{ isChecked?: boolean }>`
justify-content: center;
width: 40px;
& > div {
${(props) =>
props.isChecked
? `
background: ${Colors.FERN_GREEN};
&:hover {
background: linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
${Colors.FERN_GREEN};
}
`
: `
border: 1px solid ${Colors.GREY_3};
&:hover {
border: 1px solid ${Colors.GREY_5};
}
`};
}
`;
export const CellCheckbox = styled.div`
height: 14px;
width: 14px;
background: ${Colors.WHITE};
cursor: pointer;
position: relative;
.th-svg {
display: block;
position: absolute;
left: 2px;
top: 2px;
}
`;
export const TableHeaderWrapper = styled.div<{
serverSidePaginationEnabled: boolean;
width: number;
tableSizes: TableSizes;
backgroundColor?: Color;
}>`
2021-03-18 19:09:13 +00:00
position: relative;
display: flex;
2021-03-18 19:09:13 +00:00
width: ${(props) => props.width - 8}px;
.show-page-items {
2020-12-24 04:32:25 +00:00
display: ${(props) => (props.width < 700 ? "none" : "flex")};
}
2020-12-24 04:32:25 +00:00
height: ${(props) => props.tableSizes.TABLE_HEADER_HEIGHT}px;
min-height: ${(props) => props.tableSizes.TABLE_HEADER_HEIGHT}px;
2021-04-15 05:01:06 +00:00
overflow-x: auto;
${hideScrollbar};
2021-04-15 05:01:06 +00:00
.thumb-horizontal {
height: 4px !important;
border-radius: ${(props) => props.theme.radii[3]}px;
background: ${(props) => props.theme.colors.scrollbarLight};
&:hover {
height: 6px !important;
}
}
`;
export const TableHeaderInnerWrapper = styled.div<{
serverSidePaginationEnabled: boolean;
width: number;
tableSizes: TableSizes;
backgroundColor?: Color;
}>`
position: relative;
display: flex;
width: 100%;
height: 100%;
border-bottom: 1px solid ${Colors.GEYSER_LIGHT};
`;
export const CommonFunctionsMenuWrapper = styled.div<{
tableSizes: TableSizes;
}>`
display: flex;
align-items: center;
2020-12-24 04:32:25 +00:00
height: ${(props) => props.tableSizes.TABLE_HEADER_HEIGHT}px;
`;
export const RowWrapper = styled.div`
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
line-height: 20px;
2021-05-10 11:24:50 +00:00
color: ${Colors.GRAY};
margin: 0 4px;
white-space: nowrap;
`;
export const TableIconWrapper = styled.div<{
selected?: boolean;
disabled?: boolean;
}>`
2020-12-24 04:32:25 +00:00
background: ${(props) =>
props.selected ? Colors.ATHENS_GRAY : "transparent"};
box-shadow: ${(props) =>
props.selected ? `inset 0px 4px 0px ${Colors.GREEN}` : "none"};
width: 48px;
height: 38px;
display: flex;
align-items: center;
justify-content: center;
2020-12-24 04:32:25 +00:00
opacity: ${(props) => (props.disabled ? 0.6 : 1)};
cursor: ${(props) => !props.disabled && "pointer"};
position: relative;
&:hover {
background: ${Colors.ATHENS_GRAY};
}
`;
export const RenderOptionWrapper = styled.div<{ selected: boolean }>`
display: flex;
justify-content: space-between;
align-items: center;
width: 150px;
position: relative;
.title {
feat: Property pane dropdown overflow issues (#8236) * * hide subtext for date picker fix * EE clicking on entity, unfolding/folding added * * bug fixes in action dropdown * bug fix for cursor * fix: 8190 background api request and welcome helper button (#8281) * chore: Move action/js debugger tabs related logic to a common component (#8199) * removed background of api request textbox and added hover text on "no thanks" button Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> * fix: added scrolling in invited users more popup (#8226) * added scrolling in invited users more popup * always scrollbar displaying on invited users pan * fixed issue related with 8190 * updated cursor of invited users more * replace edit data source icon with remix icon (#8192) * * active text color * fix: dropdownlist props issue (#8322) * Commented failing JS tests (#8276) Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> * docs: Update ServerSetup.md (#8255) * Make port customizable from env variable (#8288) * fix: issue with string templates (#7848) * Remove bracket highlight on error * fix string template issue * using string template to join strings * fix breaking tests * fixed props pass issue Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Vinod <4994565+vnodecg@users.noreply.github.com> * * bug fixes * * bug fix * * test cases fix * - test case fix * * test fixes * * bug fix in test case Co-authored-by: haojin111 <63215848+haojin111@users.noreply.github.com> Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Vinod <4994565+vnodecg@users.noreply.github.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2021-10-11 06:01:05 +00:00
color: ${Colors.GREY_10};
width: 120px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.type {
position: absolute;
left: 135px;
font-size: 12px !important;
feat: Property pane dropdown overflow issues (#8236) * * hide subtext for date picker fix * EE clicking on entity, unfolding/folding added * * bug fixes in action dropdown * bug fix for cursor * fix: 8190 background api request and welcome helper button (#8281) * chore: Move action/js debugger tabs related logic to a common component (#8199) * removed background of api request textbox and added hover text on "no thanks" button Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> * fix: added scrolling in invited users more popup (#8226) * added scrolling in invited users more popup * always scrollbar displaying on invited users pan * fixed issue related with 8190 * updated cursor of invited users more * replace edit data source icon with remix icon (#8192) * * active text color * fix: dropdownlist props issue (#8322) * Commented failing JS tests (#8276) Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> * docs: Update ServerSetup.md (#8255) * Make port customizable from env variable (#8288) * fix: issue with string templates (#7848) * Remove bracket highlight on error * fix string template issue * using string template to join strings * fix breaking tests * fixed props pass issue Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Vinod <4994565+vnodecg@users.noreply.github.com> * * bug fixes * * bug fix * * test cases fix * - test case fix * * test fixes * * bug fix in test case Co-authored-by: haojin111 <63215848+haojin111@users.noreply.github.com> Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com> Co-authored-by: Yatin Chaubal <yatin.chaubal@gmail.com> Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Vinod <4994565+vnodecg@users.noreply.github.com> Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2021-10-11 06:01:05 +00:00
color: ${Colors.GREY_10};
}
`;
export const MenuCategoryWrapper = styled.div`
display: flex;
width: 100%;
align-items: center;
justify-content: space-between;
color: ${Colors.RIVER_BED};
`;
export const MenuStyledOptionHeader = styled.div`
font-weight: 600;
`;
export const ColumnWrapper = styled.div`
display: flex;
align-items: center;
`;