import { View } from '@tarojs/components'; import { callable, classNames, deepGet } from 'mixlea-utils-js'; import { Header } from './header'; import type { MlBaseFormListColumn, MlBaseFormListData, MlBaseFormListProps } from './types'; import { Footer } from './footer'; import { Body } from './body'; import { safeGetRowKey } from './tools/safe-get-row-key'; import { safeGetCellContent } from './tools/safe-get-cell-content'; import { FormItem } from './form-item'; import { mergeElementProps } from './tools/merge-element-props'; export type { MlBaseFormListProps, MlBaseFormListColumn, MlBaseFormListData }; export { mergeElementProps }; export function MlBaseFromList(props: MlBaseFormListProps) { return (
{props.formListData.map((row, rowIndex) => { const rowKey = safeGetRowKey(props.rowKeyField, row, rowIndex); return ( {props.columns.map((column, colIndex) => { const cellValue = deepGet(props.formListData, column.field, undefined); const cellProps = column.getCellProps?.(cellValue, props.formListData, { rowIndex, colIndex }) ?? {}; const headerProps = column.getHeaderProps?.(cellValue, props.formListData, { rowIndex, colIndex }) ?? {}; const contentProps = column.getContentProps?.(cellValue, props.formListData, { rowIndex, colIndex }) ?? {}; const contentLeft = column.renderLeft?.(cellValue, row, rowIndex) ?? undefined; const contentRight = column.renderRight?.(cellValue, row, rowIndex) ?? undefined; const colSpanAll = callable(column.colSpanAll, { cellValue, row, rowIndex, }); return ( {column.title} {contentLeft && {contentLeft}} {safeGetCellContent({ column, cellValue, row, rowIndex, })} {contentRight && {contentRight}} ); })} ); })}