UNPKG

@uiw/react-table

Version:
69 lines (68 loc) 3.16 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = TheadComponent; var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2")); var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _react = _interopRequireDefault(require("react")); var _utils = require("@uiw/utils"); var _ThComponent = _interopRequireDefault(require("./ThComponent")); var _jsxRuntime = require("react/jsx-runtime"); var _excluded = ["prefixCls", "className", "data", "onCellHead", "locationWidth", "updateLocation"], _excluded2 = ["title", "key", "render", "children", "ellipsis", "fixed"]; function TheadComponent() { var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var _props$prefixCls = props.prefixCls, prefixCls = _props$prefixCls === void 0 ? 'w-table' : _props$prefixCls, className = props.className, _props$data = props.data, data = _props$data === void 0 ? [] : _props$data, _props$onCellHead = props.onCellHead, onCellHead = _props$onCellHead === void 0 ? _utils.noop : _props$onCellHead, locationWidth = props.locationWidth, updateLocation = props.updateLocation, other = (0, _objectWithoutProperties2["default"])(props, _excluded); var rightFixedNum = 0; return /*#__PURE__*/(0, _jsxRuntime.jsx)("thead", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({ className: [prefixCls, className].filter(Boolean).join(' ').trim() }, other), {}, { children: data && data.length > 0 && data.map(function (tds, rowNum) { return /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", { children: (tds || []).map(function (item, colNum) { var title = item.title, key = item.key, render = item.render, children = item.children, ellipsis = item.ellipsis, _item$fixed = item.fixed, fixed = _item$fixed === void 0 ? false : _item$fixed, thProps = (0, _objectWithoutProperties2["default"])(item, _excluded2); var titleNode = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", { className: ellipsis ? "".concat(thProps.className || '', " ").concat(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__*/(0, _jsxRuntime.jsx)(_ThComponent["default"], { colNum: colNum, rightNum: rightFixedNum, item: item, prefixCls: prefixCls, onCellHead: onCellHead, rowNum: rowNum, titleNode: titleNode, locationWidth: locationWidth, updateLocation: updateLocation }, colNum); }) }, rowNum); }) })); } module.exports = exports.default;