UNPKG

@td-design/react-native

Version:

react-native UI组件库

42 lines 1.12 kB
import React, { memo, useContext, useMemo } from 'react'; import Box from '../box'; import helpers from '../helpers'; import { Cell } from './Cell'; import { ColumnContext, computeWidth } from './utils'; const { ONE_PIXEL } = helpers; export const Rows = /*#__PURE__*/memo(_ref => { let { data, rowStyle } = _ref; const { columns, cellWidth } = useContext(ColumnContext); const cellRender = useMemo(() => { if (!(columns instanceof Array)) { throw new Error('columns 需要是数组'); } return columns.map((item, index) => { const styles = computeWidth(cellWidth, item.width); return /*#__PURE__*/React.createElement(Cell, { style: styles, key: item.dataIndex || index, data: data, column: item }); }); }, [columns, data, cellWidth]); return /*#__PURE__*/React.createElement(Box, { flexDirection: "row", flexGrow: 1, borderBottomWidth: ONE_PIXEL, borderColor: "border", paddingVertical: "x4", alignItems: "center", style: rowStyle }, cellRender); }); //# sourceMappingURL=Rows.js.map