UNPKG

@uiw/react-table

Version:
50 lines 1.75 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; var _excluded = ["title", "key", "render", "children", "ellipsis", "fixed"]; import React, { Component } from 'react'; import { locationFixed } from './util'; import { jsx as _jsx } from "react/jsx-runtime"; export default class ThComponent extends Component { constructor() { super(...arguments); this.wrapper = /*#__PURE__*/React.createRef(); } componentDidMount() { this.props.updateLocation({ width: this.wrapper.current.getBoundingClientRect().width }, "" + this.props.rowNum + this.props.colNum, this.props.item.key, this.props.item.colSpan); } render() { var { colNum, rightNum, prefixCls, item, titleNode, onCellHead, rowNum, locationWidth } = this.props; var { fixed = false } = item, thProps = _objectWithoutPropertiesLoose(item, _excluded); var cls = ''; if (fixed) { if (fixed === 'right') { var rightCls = rightNum === 1 ? prefixCls + "-fixed-right-first" : ''; cls = prefixCls + '-fixed-right ' + rightCls; } else { cls = prefixCls + '-fixed-true'; } } return /*#__PURE__*/_jsx("th", _extends({ ref: this.wrapper }, thProps, { style: _extends({}, thProps.style, locationFixed(fixed, locationWidth, "" + rowNum + colNum)), className: prefixCls + "-tr-children-" + ((item == null ? void 0 : item.align) || 'left') + " " + (item.className || '') + " " + cls, onClick: evn => onCellHead == null ? void 0 : onCellHead(item, colNum, rowNum, evn), children: titleNode }), colNum); } }