import * as React from "react";
import * as Constants from "~/common/constants";
import { css } from "@emotion/react";
import { P1 } from "~/components/system/components/Typography";
const TABLE_COLUMN_WIDTH_DEFAULTS = {
1: "100%",
2: "50%",
3: "33.333%",
4: "25%",
5: "20%",
6: "16.666%",
7: "14.28%",
8: "12.5%",
};
const STYLES_CONTAINER = css`
border: 1px solid ${Constants.semantic.borderGrayLight};
box-shadow: ${Constants.shadow.lightSmall};
`;
const STYLES_TABLE_ROW = css`
position: relative;
box-sizing: border-box;
border-bottom: 1px solid ${Constants.semantic.borderGrayLight};
display: flex;
align-items: center;
width: 100%;
transition: 200ms ease all;
:last-child {
border: 0;
}
`;
const STYLES_TABLE_TOP_ROW = css`
box-sizing: border-box;
font-family: ${Constants.font.semiBold};
border-bottom: 1px solid ${Constants.semantic.borderGrayLight};
display: flex;
width: 100%;
align-items: center;
background-color: ${Constants.semantic.bgLight};
`;
export class Table extends React.Component {
tableWrapperEl = React.createRef();
componentDidMount() {
if (this.tableWrapperEl.current) {
this.tableWrapperEl.current.addEventListener("selectstart", this._handleSelectStart);
}
}
componentWillUnmount() {
if (this.tableWrapperEl.current) {
this.tableWrapperEl.current.removeEventListener("selectstart", this._handleSelectStart);
}
}
_handleSelectStart = (e) => {
if (this.props.isShiftDown) {
e.preventDefault();
}
};
render() {
const { data } = this.props;
const ac = {};
if (!data || !data.rows || data.rows.length === 0) {
return