@procore/core-react
Version:
React library of Procore Design Guidelines
257 lines • 18.8 kB
JavaScript
import { ArrowUp, ChevronRight } from '@procore/core-icons';
import styled, { css } from 'styled-components';
import { Button } from '../Button';
import { Card } from '../Card';
import { Checkbox } from '../Checkbox';
import { StyledDateInputDelimiter, StyledDateInputIconContainer, StyledDateInputSegment } from '../DateInput/DateInput.styles';
import { DateSelect } from '../DateSelect';
import { Input } from '../Input';
import { Select } from '../Select';
import { StyledSelectArrow, StyledSelectButtonLabel, StyledSelectButtonWrapper, StyledSelectClearIcon } from '../Select/Select.styles';
import { TextArea } from '../TextArea';
import { getTypographyIntent, typographyWeights } from '../Typography/Typography.styles';
import { colors } from '../_styles/colors';
import { getFocus } from '../_styles/mixins';
import { spacing } from '../_styles/spacing';
var tableBgColor = colors.white;
var tableBorderRadius = 4;
var tableBorderStyle = 'solid';
var tableBorderWidth = 1;
var tableBorderColor = colors.gray85;
var tableBorder = "".concat(tableBorderWidth, "px ").concat(tableBorderStyle, " ").concat(tableBorderColor);
var tableGroupRowBgColor = colors.gray98;
var tableGroupBodyRowIndentation = spacing.md;
var tableGroupHeaderRowIndentation = spacing.xl;
var tableHeaderBgColor = colors.gray96;
var tableHeaderBgColorHover = colors.gray94;
var tableHeaderBgColorActive = colors.gray94;
var tableHeaderBorderColor = colors.gray90;
var tableHeaderBorderRight = "".concat(tableBorderWidth, "px ").concat(tableBorderStyle, " ").concat(tableHeaderBorderColor);
var tableHeaderFontColor = colors.gray30;
var tableHeaderFontColorActive = colors.gray15;
var tableHeaderFontWeight = typographyWeights.semibold;
var tableHeaderHeight = 48;
var tableHeaderPadding = spacing.lg;
var tableSortFontColor = colors.gray50;
var tableSortFontColorHover = colors.gray40;
var tableSortFontColorActive = colors.blue50;
var tableCellTextColor = colors.gray15;
var tableCellIconColor = colors.gray45;
var tableCellInputPlaceholderColor = colors.gray70;
var tableCellInputBorder = '1px solid transparent';
var tableCellInputRowHoverBgColor = colors.gray96;
var tableCellInputFocusBgColor = colors.white;
var tableCellInputHoverBgColor = colors.blue94;
var tableCellInputFocusBorder = "1px solid ".concat(colors.blue50);
var tableCellInputErrorBgColor = colors.red98;
var tableCellInputErrorBorder = "1px solid ".concat(colors.red50);
var tableRowBorderBottom = /*#__PURE__*/css(["border-bottom:", ";&:last-child{border-bottom:0;}"], tableBorder);
export var StyledTableHeaderCellSortableContainer = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledTableHeaderCellSortableContainer",
componentId: "core-12_44_0__sc-9c7xd-0"
})([""]);
export var StyledTableHeaderCellLabel = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledTableHeaderCellLabel",
componentId: "core-12_44_0__sc-9c7xd-1"
})(["display:inline-block;flex:1 1 auto;position:relative;"]);
export var StyledCheckbox = /*#__PURE__*/styled(Checkbox).withConfig({
displayName: "StyledCheckbox",
componentId: "core-12_44_0__sc-9c7xd-2"
})([""]);
export var StyledTableBodyCell = /*#__PURE__*/styled.td.withConfig({
displayName: "StyledTableBodyCell",
componentId: "core-12_44_0__sc-9c7xd-3"
})(["position:relative;vertical-align:middle;", ""], function (_ref) {
var $snugfit = _ref.$snugfit;
return $snugfit && css(["white-space:nowrap;width:0.1%;"]);
});
export var StyledTableHeaderCell = /*#__PURE__*/styled.th.withConfig({
displayName: "StyledTableHeaderCell",
componentId: "core-12_44_0__sc-9c7xd-4"
})(["", " font-weight:", ";border-right:", ";color:", ";height:", "px;padding:", "px;position:relative;text-align:left;transition:background-color 0.2s ease-in-out;&:last-child{border-right:0;}", "{display:flex;align-items:center;}", "{", "{min-height:14px;}}", " ", " ", " ", ""], getTypographyIntent('small'), tableHeaderFontWeight, tableHeaderBorderRight, tableHeaderFontColor, tableHeaderHeight, tableHeaderPadding, StyledTableHeaderCellSortableContainer, StyledTableHeaderCellSortableContainer, StyledTableHeaderCellLabel, function (_ref2) {
var $sortable = _ref2.$sortable;
return $sortable && css(["cursor:pointer;padding:", "px;", "{color:", ";opacity:0;transition:all 0.15s ease-in-out;position:absolute;}::before,::after{font-size:16px;}&:hover{background-color:", ";}"], spacing.lg, StyledTableHeaderCellSortIcon, tableSortFontColor, tableHeaderBgColorHover);
}, function (_ref3) {
var $sortOrder = _ref3.$sortOrder;
return ($sortOrder === 'asc' || $sortOrder === 'desc') && css(["background-color:", ";color:", ";", "{color:", ";opacity:1;}"], tableHeaderBgColorActive, tableHeaderFontColorActive, StyledTableHeaderCellSortIcon, tableSortFontColorActive);
}, function (_ref4) {
var $sortOrder = _ref4.$sortOrder;
return $sortOrder === 'desc' && css(["", "{transform:scaleY(-1);}"], StyledTableHeaderCellSortIcon);
}, function (_ref5) {
var $snugfit = _ref5.$snugfit;
return $snugfit && css(["width:0.1%;"]);
});
export var StyledTableHeaderCellIconWrapper = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledTableHeaderCellIconWrapper",
componentId: "core-12_44_0__sc-9c7xd-5"
})(["height:20px;line-height:20px;padding:0 ", "px 0 ", "px;width:20px;"], spacing.lg, spacing.sm);
export var StyledTableHeaderCellSortIcon = /*#__PURE__*/styled(ArrowUp).withConfig({
displayName: "StyledTableHeaderCellSortIcon",
componentId: "core-12_44_0__sc-9c7xd-6"
})(["height:16px;width:16px;"]);
export var StyledHead = /*#__PURE__*/styled.thead.withConfig({
displayName: "StyledHead",
componentId: "core-12_44_0__sc-9c7xd-7"
})(["background-color:", ";transition:background-color 0.2s ease-in-out;", ""], tableHeaderBgColor, tableRowBorderBottom);
export var StyledCaratWrapper = /*#__PURE__*/styled(Button).withConfig({
displayName: "StyledCaratWrapper",
componentId: "core-12_44_0__sc-9c7xd-8"
})([""]);
export var StyledCarat = /*#__PURE__*/styled(ChevronRight).withConfig({
displayName: "StyledCarat",
componentId: "core-12_44_0__sc-9c7xd-9"
})(["", ""], function (_ref6) {
var $expanded = _ref6.$expanded;
return $expanded && css(["transform:rotate(90deg);"]);
});
var cellInputCSS = /*#__PURE__*/css(["background-color:rgba(255,255,255,0);&&&{border:", ";border-radius:4px;width:100%;&::placeholder{color:", ";}&::-ms-clear{display:none;}&:hover{border-color:transparent;}&:focus{background-color:", ";border-style:solid;border-width:1px;border-color:", ";box-shadow:0 0 0 1px ", ";outline:none;}&:disabled{border:", ";color:", ";}}"], tableCellInputBorder, tableCellInputPlaceholderColor, colors.white, colors.blue40, colors.blue40, tableCellInputBorder, colors.gray70);
export var StyledTableCellSelect = /*#__PURE__*/styled(Select).withConfig({
displayName: "StyledTableCellSelect",
componentId: "core-12_44_0__sc-9c7xd-10"
})(["", ";background-color:transparent;border-color:transparent;height:auto;&:hover{background-color:transparent;}&:active:hover{border-color:", ";}&:focus,", ":focus-within &{background-color:", ";cursor:pointer;", " ", "{white-space:nowrap;}", "{opacity:1;pointer-events:all;}", " ", "}", " ", "{white-space:normal;}", ",& + ", "{opacity:0;pointer-events:none;}", " ", ""], cellInputCSS, colors.gray85, StyledSelectButtonWrapper, colors.white, getFocus(), StyledSelectButtonLabel, StyledSelectArrow, function (_ref7) {
var $hasClearIcon = _ref7.$hasClearIcon;
return $hasClearIcon && css(["& + ", "{opacity:1;pointer-events:all;}"], StyledSelectClearIcon);
}, function (_ref8) {
var _ref8$$placeholder = _ref8.$placeholder,
$placeholder = _ref8$$placeholder === void 0 ? false : _ref8$$placeholder;
return $placeholder && css(["", "{opacity:1;pointer-events:all;}"], StyledSelectButtonLabel);
}, function (_ref9) {
var $hasClearIcon = _ref9.$hasClearIcon;
return $hasClearIcon && css(["& + ", ":focus{opacity:1;pointer-events:all;}"], StyledSelectClearIcon);
}, StyledSelectButtonLabel, StyledSelectArrow, StyledSelectClearIcon, function (_ref0) {
var _ref0$$placeholder = _ref0.$placeholder,
$placeholder = _ref0$$placeholder === void 0 ? false : _ref0$$placeholder;
return $placeholder && css(["", "{opacity:0;pointer-events:none;}"], StyledSelectButtonLabel);
}, function (_ref1) {
var loading = _ref1.loading;
return loading && css(["background-color:", ";border-color:", ";", "{white-space:nowrap;}"], colors.white, colors.gray85, StyledSelectButtonLabel);
});
export var StyledTableCellInput = /*#__PURE__*/styled(Input).withConfig({
displayName: "StyledTableCellInput",
componentId: "core-12_44_0__sc-9c7xd-11"
})(["", ""], cellInputCSS);
export var StyledTableCellDateInput = /*#__PURE__*/styled(DateSelect).withConfig({
displayName: "StyledTableCellDateInput",
componentId: "core-12_44_0__sc-9c7xd-12"
})(["background-color:transparent;border-color:transparent;&:active:hover{border-color:", ";}&&&:focus-within{", ";background-color:", ";}", " ", "{opacity:0;}", "{&[data-qa-table-visible='false']{opacity:0;}}", "{&[data-placeholder='true']{opacity:0;}}&:focus-within{", "{opacity:1;}", "{&[data-qa-table-visible='false']{opacity:1;}}", "{&[data-placeholder='true']{opacity:1;}}}"], colors.gray45, getFocus(), colors.white, function (_ref10) {
var error = _ref10.error;
return error && css(["border-color:", ";"], colors.red50);
}, StyledDateInputIconContainer, StyledDateInputDelimiter, StyledDateInputSegment, StyledDateInputIconContainer, StyledDateInputDelimiter, StyledDateInputSegment);
export var StyledTableCellTextArea = /*#__PURE__*/styled(TextArea).withConfig({
displayName: "StyledTableCellTextArea",
componentId: "core-12_44_0__sc-9c7xd-13"
})(["", " &&{height:", "px;min-height:", "px;overflow:hidden;padding-top:", "px;resize:none;width:100%;", "}"], cellInputCSS, spacing.xxl, spacing.xxl, spacing.xs, function (_ref11) {
var $resizable = _ref11.$resizable;
return $resizable && css(["&:focus{min-height:64px;overflow:auto;resize:vertical;}"]);
});
export var StyledTableCellText = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledTableCellText",
componentId: "core-12_44_0__sc-9c7xd-14"
})(["margin:", "px;display:flex;color:", ";", ""], spacing.lg, tableCellTextColor, function (_ref12) {
var $percent = _ref12.$percent,
$currency = _ref12.$currency;
return ($percent || $currency) && css(["justify-content:flex-end;"]);
});
export var StyledIconCell = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledIconCell",
componentId: "core-12_44_0__sc-9c7xd-15"
})(["display:flex;color:", ";"], tableCellIconColor);
export var StyledSelectCellWrapper = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledSelectCellWrapper",
componentId: "core-12_44_0__sc-9c7xd-16"
})(["display:flex;flex-direction:column;"]);
export var StyledTableInlineEditErrorBox = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledTableInlineEditErrorBox",
componentId: "core-12_44_0__sc-9c7xd-17"
})(["", " color:", ";font-style:italic;background:", ";border-radius:0 2px 2px 2px;box-shadow:0 1px 2px rgba(0,0,0,0.2),0 1px 3px rgba(0,0,0,0.1);padding:6px ", "px;position:absolute;max-width:160px;z-index:1;", ""], getTypographyIntent('small'), colors.white, colors.red50, spacing.md, function (_ref13) {
var $size = _ref13.$size;
var sizes = {
xs: 36,
sm: 48,
md: 80,
lg: 112,
block: null,
xl: null
};
if (!$size || !sizes[$size]) {
return '';
}
return css(["min-width:", "px;"], sizes[$size]);
});
export var StyledTableInlineEditContainer = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledTableInlineEditContainer",
componentId: "core-12_44_0__sc-9c7xd-18"
})(["background-color:", ";margin:", "px ", "px;position:relative;", " ", ""], tableBgColor, spacing.sm, spacing.xs, function (_ref14) {
var $error = _ref14.$error;
return $error && css(["position:static;background-color:", ";", ",", ",", ",", "{border:", ";border-radius:4px 4px 0 0;border-bottom:none;&:hover{border-bottom:none;}&:focus{background-color:", ";border:", ";border-bottom:none;}}"], tableCellInputErrorBgColor, StyledTableCellDateInput, StyledTableCellInput, StyledTableCellSelect, StyledTableCellTextArea, tableCellInputErrorBorder, tableCellInputFocusBgColor, tableCellInputFocusBorder);
}, function (_ref15) {
var $size = _ref15.$size;
var sizes = {
xs: 36,
sm: 48,
md: 80,
lg: 112,
block: null,
xl: null
};
if ($size === 'block') {
return css(["position:relative;", "{width:100%;max-width:100%;}"], StyledTableInlineEditErrorBox);
}
if (!$size || !sizes[$size]) {
return '';
}
return css(["width:", "px;"], sizes[$size]);
});
export var StyledTableBodyRow = /*#__PURE__*/styled.tr.withConfig({
displayName: "StyledTableBodyRow",
componentId: "core-12_44_0__sc-9c7xd-19"
})(["", " ", " &:focus-within{", "{background-color:", ";&.disabled{background-color:transparent;}}", ".error{background-color:", ";}}&:hover{", "{background-color:", ";cursor:pointer;&:hover{background-color:", ";}&.disabled{&,&:hover{background-color:transparent;cursor:default;}}}", ".error{background-color:", ";&:hover{background-color:", ";}", ",", ",", "{border:", ";border-bottom:none;&:hover{border-bottom:none;}&:focus{border:", ";border-bottom:none;}}}}"], tableRowBorderBottom, function (_ref16) {
var $overdue = _ref16.$overdue;
return $overdue && css(["", ",", ",", ",", ",", "{color:", ";}"], StyledTableCellText, StyledTableCellSelect, StyledTableCellInput, StyledTableCellDateInput, StyledTableCellTextArea, colors.red50);
}, StyledTableInlineEditContainer, tableCellInputRowHoverBgColor, StyledTableInlineEditContainer, tableCellInputErrorBgColor, StyledTableInlineEditContainer, tableCellInputRowHoverBgColor, tableCellInputHoverBgColor, StyledTableInlineEditContainer, tableCellInputErrorBgColor, tableCellInputErrorBgColor, StyledTableCellInput, StyledTableCellSelect, StyledTableCellTextArea, tableCellInputErrorBorder, tableCellInputFocusBorder);
export var StyledTableGroupRowContent = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledTableGroupRowContent",
componentId: "core-12_44_0__sc-9c7xd-20"
})([""]);
export var StyledTableGroupRowHeader = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledTableGroupRowHeader",
componentId: "core-12_44_0__sc-9c7xd-21"
})([""]);
export var StyledTableGroupRowTitle = /*#__PURE__*/styled.span.withConfig({
displayName: "StyledTableGroupRowTitle",
componentId: "core-12_44_0__sc-9c7xd-22"
})([""]);
export var StyledTableGroupRow = /*#__PURE__*/styled.tr.withConfig({
displayName: "StyledTableGroupRow",
componentId: "core-12_44_0__sc-9c7xd-23"
})(["background-color:", ";", " ", "{margin-left:", "px;padding:", "px 0;display:flex;flex-direction:row;}", "{display:flex;align-items:center;}", "{font-weight:", ";padding-left:", "px;}", ""], tableGroupRowBgColor, tableRowBorderBottom, StyledTableGroupRowContent, spacing.lg, spacing.lg, StyledTableGroupRowHeader, StyledTableGroupRowTitle, tableHeaderFontWeight, spacing.lg, function (_ref17) {
var $depth = _ref17.$depth;
if (typeof $depth !== 'number') {
return '';
}
return css(["> td{padding-left:", "px !important;}~ ", "{> td:first-child{padding-left:", "px !important;}}"], $depth * tableGroupHeaderRowIndentation, StyledTableBodyRow, ($depth + 1) * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation);
});
export var StyledTableWrapper = /*#__PURE__*/styled(Card).withConfig({
displayName: "StyledTableWrapper",
componentId: "core-12_44_0__sc-9c7xd-24"
})(["border-radius:", "px;border:", ";", ",tbody{&:first-child{tr:first-child{", ",td{&:first-child{border-top-left-radius:", "px;}&:last-child{border-top-right-radius:", "px;}}}}&:last-child{tr:last-child{", ",td{&:first-child{border-bottom-left-radius:", "px;}&:last-child{border-bottom-right-radius:", "px;}}}}}", ""], tableBorderRadius, tableBorder, StyledHead, StyledTableHeaderCell, tableBorderRadius, tableBorderRadius, StyledTableHeaderCell, tableBorderRadius, tableBorderRadius, function (_ref18) {
var $withShelf = _ref18.$withShelf;
return $withShelf && css(["position:relative;height:100%;"]);
});
var BodyRow = StyledTableBodyRow;
var GroupRow = StyledTableGroupRow;
export var StyledTable = /*#__PURE__*/styled.table.withConfig({
displayName: "StyledTable",
componentId: "core-12_44_0__sc-9c7xd-25"
})(["background-color:", ";border-collapse:collapse;border-radius:", "px;", " width:100%;td:first-child ", "{padding-left:", "px;}", " ", " + ", "{margin-left:", "px;padding-left:0;}", " ", " ", " + ", " > td{padding-left:", "px;}", " + ", " + ", " > td{padding-left:", "px;}", " + ", " + ", " + ", " > td{padding-left:", "px;}", " + ", " + ", " + ", " + ", " > td{padding-left:", "px;}", " ~ ", "{", "{padding-left:0;margin:0 ", "px;}& > td:first-child{padding-left:", "px;}}", " + ", " ~ ", "{& > td:first-child{padding-left:", "px;}}", " + ", " + ", " ~ ", "{& > td:first-child{padding-left:", "px;}}", " + ", " + ", " + ", " ~ ", "{& > td:first-child{padding-left:", "px;}}", " + ", " + ", " + ", " + ", " ~ ", "{& > td:first-child{padding-left:", "px;}}"], tableBgColor, tableBorderRadius, getTypographyIntent('body'), StyledCheckbox, spacing.lg, StyledTableGroupRow, StyledCaratWrapper, StyledCheckbox, spacing.xs, function (_ref19) {
var $fixed = _ref19.$fixed;
return $fixed && css(["table-layout:fixed;"]);
}, function (_ref20) {
var $inline = _ref20.$inline;
return $inline && css(["border-top:1px solid ", ";border-bottom:1px solid ", ";"], colors.gray85, colors.gray85);
}, GroupRow, GroupRow, tableGroupHeaderRowIndentation, GroupRow, GroupRow, GroupRow, 2 * tableGroupHeaderRowIndentation, GroupRow, GroupRow, GroupRow, GroupRow, 3 * tableGroupHeaderRowIndentation, GroupRow, GroupRow, GroupRow, GroupRow, GroupRow, 4 * tableGroupHeaderRowIndentation, GroupRow, BodyRow, StyledCheckbox, spacing.xs, tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation, GroupRow, GroupRow, BodyRow, 2 * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation, GroupRow, GroupRow, GroupRow, BodyRow, 3 * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation, GroupRow, GroupRow, GroupRow, GroupRow, BodyRow, 4 * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation, GroupRow, GroupRow, GroupRow, GroupRow, GroupRow, BodyRow, 5 * tableGroupHeaderRowIndentation + tableGroupBodyRowIndentation);
export var StyledLoadingContainer = /*#__PURE__*/styled.div.withConfig({
displayName: "StyledLoadingContainer",
componentId: "core-12_44_0__sc-9c7xd-26"
})(["cursor:default;align-items:center;background:", ";display:flex;height:100%;justify-content:center;opacity:0.9;position:absolute;width:100%;z-index:2;"], colors.gray96);
//# sourceMappingURL=Table.styles.js.map