oneframe-react
Version:
Oneframe React ## Components, Hooks, Helper Functions & State Management
33 lines (32 loc) • 1.57 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const lodash_1 = require("lodash");
const withTable_1 = require("./withTable");
const prop_types_1 = __importDefault(require("prop-types"));
const Cell_1 = __importDefault(require("./Cell"));
const Head = (props) => {
const { className, tableState, children, stickyOffset } = props;
const renderCell = () => {
if (children && children.length) {
return children.map((item, i) => {
return (react_1.default.createElement(Cell_1.default, Object.assign({}, item.props, { key: i, className: `${item.props.className || ''} ${item.props.onClick ? 'cursor' : ''}` }), item.props.children));
});
}
return null;
};
return (react_1.default.createElement("div", { className: `custom-table-head ${className}`, style: { top: stickyOffset } },
tableState && tableState.expand ? react_1.default.createElement("div", { className: "custom-table-cell expand-icon" }) : null,
renderCell()));
};
Head.propTypes = {
stickyOffset: prop_types_1.default.number,
children: prop_types_1.default.any,
className: prop_types_1.default.string,
tableState: prop_types_1.default.any,
};
const MemoComponent = react_1.default.memo(Head, (p, n) => lodash_1.isEqual(p, n));
exports.default = withTable_1.withTable(MemoComponent);
;