@6thquake/react-material
Version:
React components that implement Google's Material Design.
79 lines (67 loc) • 1.68 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import { withStyles } from '../../styles';
import classNames from 'classnames';
import ThCell from './ThCell';
const styles = theme => ({
root: {}
});
/**
* @ignore - internal component.
*/
class Cell extends React.Component {
constructor() {
super();
this.handleDoubleClick = e => {
const {
disableClickToFixColumn
} = this.props;
if (disableClickToFixColumn) {
return;
}
this.setState({
show: true
});
};
this.handleClick = (index, fixed) => {
const {
onColumnFixChange
} = this.props;
this.setState({
show: false
});
onColumnFixChange && onColumnFixChange(index, fixed);
};
this.state = {
show: false,
topRight: false,
topLeft: false
};
}
render() {
const _this$props = this.props,
{
children,
classes,
fixed,
index
} = _this$props,
other = _objectWithoutPropertiesLoose(_this$props, ["children", "classes", "fixed", "index"]);
const {
show
} = this.state;
return React.createElement("th", _extends({
onDoubleClick: this.handleDoubleClick,
className: classes.root
}, other), children, React.createElement(ThCell, {
fixed: fixed,
index: index,
show: show,
onColumnFixChange: this.handleClick
}));
}
}
export default withStyles(styles)(Cell);