UNPKG

chowa

Version:

UI component library based on React

61 lines (60 loc) 4.16 kB
/** * @license chowa v1.1.3 * * Copyright (c) Chowa Techonlogies Co.,Ltd.(http://www.chowa.cn). * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const React = require("react"); const classnames_1 = require("classnames"); const utils_1 = require("../utils"); const table_col_group_1 = require("./table-col-group"); const table_header_1 = require("./table-header"); const table_body_1 = require("./table-body"); class TablefFixed extends React.PureComponent { constructor(props) { super(props); this.onContentScroll = this.onContentScroll.bind(this); } componentDidUpdate(preProps) { if (preProps.scrollTop !== this.props.scrollTop) { this.bodyEle.scrollTop = this.props.scrollTop; } } onContentScroll() { this.props.updateTable({ contentScrollTop: this.bodyEle.scrollTop }); } render() { const { fixed, fixedHeader, headerHeight, footerHeight, striped, expanded, selectable, columns, columnsWidthMap, rowsHeightMap, showHeader, dataIndexs, data, globalAlign, resizeable, headerRowAttr, filterInfo, sorterInfo, onSelectAll, onDeSelectAll, onSelect, onDeSelect, selectedIndexs, expanedVisibleMap, accordion, expandedRowRender, expandedOpenNode, expandedCloseNode, onExpandedVisibleChange, rowAttr, highlightRow, highlightRowIndex, updateTable, withFooter, scrollHeight, active } = this.props; const fixedClass = classnames_1.default({ [utils_1.preClass('table-fixed')]: true, [utils_1.preClass(`table-fixed-${fixed}`)]: true, [utils_1.preClass('table-fixed-with-footer')]: withFooter, [utils_1.preClass('table-fixed-active')]: active }); const bodyClass = classnames_1.default({ [utils_1.preClass('table-fixed-body-wrapper')]: true, [utils_1.preClass('table-scroll-y')]: fixedHeader }); const bodyStyle = Object.assign({}, (fixedHeader ? { maxHeight: scrollHeight } : {})); const colGroupControl = (React.createElement(table_col_group_1.default, { fixed: fixed, dataIndexs: dataIndexs, columnsWidthMap: columnsWidthMap, selectable: selectable, expanded: expanded })); return (React.createElement("div", { className: fixedClass, style: { bottom: footerHeight } }, showHeader && React.createElement("div", { className: utils_1.preClass('table-fixed-header-wrapper') }, React.createElement("table", null, colGroupControl, React.createElement(table_header_1.default, { headerHeight: headerHeight, dataIndexs: dataIndexs, data: data, fixed: fixed, updateTable: updateTable, columns: columns, columnsWidthMap: columnsWidthMap, globalAlign: globalAlign, resizeable: resizeable, headerRowAttr: headerRowAttr, filterInfo: filterInfo, sorterInfo: sorterInfo, selectable: selectable, onSelectAll: onSelectAll, onDeSelectAll: onDeSelectAll, selectedIndexs: selectedIndexs, expanded: expanded }))), React.createElement("div", { className: bodyClass, style: bodyStyle, onScroll: this.onContentScroll, ref: (ele) => { this.bodyEle = ele; } }, React.createElement("table", null, colGroupControl, React.createElement(table_body_1.default, { data: data, fixed: fixed, rowsHeightMap: rowsHeightMap, globalAlign: globalAlign, dataIndexs: dataIndexs, columns: columns, selectable: selectable, striped: striped, expanded: expanded, selectedIndexs: selectedIndexs, onSelect: onSelect, onDeSelect: onDeSelect, updateTable: updateTable, expanedVisibleMap: expanedVisibleMap, accordion: accordion, expandedRowRender: expandedRowRender, expandedOpenNode: expandedOpenNode, expandedCloseNode: expandedCloseNode, onExpandedVisibleChange: onExpandedVisibleChange, rowAttr: rowAttr, highlightRow: highlightRow, highlightRowIndex: highlightRowIndex }))))); } } exports.default = TablefFixed;