linkmore-design
Version:
π πlmη»δ»ΆεΊγπ
76 lines (74 loc) β’ 2.48 kB
JavaScript
import React, { useMemo } from 'react';
import cn from 'classnames';
import LmCardTableBodyCell from "./TableBodyCell";
var LmCardTableBodyRow = /*#__PURE__*/React.memo(function (_ref) {
var row = _ref.row,
rowIndex = _ref.rowIndex,
table = _ref.table;
var state = table.state,
rowConfig = table.rowConfig,
height = table.cellConfig.height,
cellKey = table.cellKey;
// ζ£ζ΅ζ―ε¦ζεζ«θ‘
var isLastRow = useMemo(function () {
return state.rows.length === rowIndex + 1;
}, [state.rows, rowIndex]);
var style = {
height: isLastRow ? height : height + rowConfig.gap,
width: '100%',
minWidth: '100%',
gridGap: rowConfig.gap,
gridTemplateColumns: "repeat(".concat(state.columnCount, ", 1fr)"),
paddingBottom: isLastRow ? 0 : rowConfig.gap
};
return /*#__PURE__*/React.createElement("div", {
className: cn('lm_card_table_body_row', isLastRow && 'last_row'),
style: style
}, row.map(function (cell, index) {
return /*#__PURE__*/React.createElement(LmCardTableBodyCell, {
key: (cell === null || cell === void 0 ? void 0 : cell[cellKey]) || index,
index: index,
cell: cell,
table: table
});
}));
});
var LmCardTableBodyRowVirtual = /*#__PURE__*/React.memo(function (_ref2) {
var row = _ref2.row,
start = _ref2.start,
rowIndex = _ref2.rowIndex,
table = _ref2.table;
var state = table.state,
rowConfig = table.rowConfig,
height = table.cellConfig.height,
cellKey = table.cellKey;
// ζ£ζ΅ζ―ε¦ζεζ«θ‘
var isLastRow = useMemo(function () {
return state.rows.length === rowIndex + 1;
});
var style = {
position: "absolute",
top: 0,
left: 0,
height: isLastRow ? height : height + rowConfig.gap,
width: '100%',
minWidth: '100%',
transform: "translateY(".concat(start, "px)"),
gridGap: rowConfig.gap,
gridTemplateColumns: "repeat(".concat(state.columnCount, ", 1fr)"),
paddingBottom: isLastRow ? 0 : rowConfig.gap
};
return /*#__PURE__*/React.createElement("div", {
className: cn('lm_card_table_body_row', isLastRow && 'last_row'),
style: style
}, row.map(function (cell, index) {
return /*#__PURE__*/React.createElement(LmCardTableBodyCell, {
key: (cell === null || cell === void 0 ? void 0 : cell[cellKey]) || index,
index: index,
cell: cell,
table: table
});
}));
});
export default LmCardTableBodyRow;
export { LmCardTableBodyRowVirtual };