@uiw/react-table
Version:
Table component
59 lines • 2.1 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["prefixCls", "className", "data", "onCellHead", "locationWidth", "updateLocation"],
_excluded2 = ["title", "key", "render", "children", "ellipsis", "fixed"];
import React from 'react';
import { noop } from '@uiw/utils';
import "./style/index.css";
import ThComponentProps from './ThComponent';
import { jsx as _jsx } from "react/jsx-runtime";
export default function TheadComponent(props) {
if (props === void 0) {
props = {};
}
var {
prefixCls = 'w-table',
className,
data = [],
onCellHead = noop,
locationWidth,
updateLocation
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
var rightFixedNum = 0;
return /*#__PURE__*/_jsx("thead", _extends({
className: [prefixCls, className].filter(Boolean).join(' ').trim()
}, other, {
children: data && data.length > 0 && data.map((tds, rowNum) => /*#__PURE__*/_jsx("tr", {
children: (tds || []).map((item, colNum) => {
var {
title,
ellipsis,
fixed = false
} = item,
thProps = _objectWithoutPropertiesLoose(item, _excluded2);
var titleNode = /*#__PURE__*/_jsx("span", {
className: ellipsis ? (thProps.className || '') + " " + prefixCls + "-ellipsis" : undefined,
children: typeof title === 'function' ? title(item, colNum, rowNum) : title
});
if (thProps.colSpan === 0) {
return null;
}
if (fixed === 'right') {
rightFixedNum = rightFixedNum + 1;
}
return /*#__PURE__*/_jsx(ThComponentProps, {
colNum: colNum,
rightNum: rightFixedNum,
item: item,
prefixCls: prefixCls,
onCellHead: onCellHead,
rowNum: rowNum,
titleNode: titleNode,
locationWidth: locationWidth,
updateLocation: updateLocation
}, colNum);
})
}, rowNum))
}));
}