import { View } from '@tarojs/components'; import { arrayGroupMap, callable, classNames, deepGet } from 'mixlea-utils-js'; import { FormHeader } from './form-header'; import type { MlBaseFormColumn, MlBaseFormData, MlBaseFormProps } from './types'; import { FormFooter } from './form-footer'; import { FormBody } from './form-body'; import { FormGroupColumns } from './form-group-columns'; import safeGetCellContent from './tools/safe-get-cell-content'; import mergeCellProps from './tools/merge-cell-props'; import safeGetCellValue from './tools/safe-get-cell-value'; export type { MlBaseFormProps, MlBaseFormColumn, MlBaseFormData }; export { mergeCellProps, safeGetCellValue }; export function MlBaseFrom(props: MlBaseFormProps) { console.log('props: ', props); return ( {Array.from(arrayGroupMap(props.columns, (column) => column.grouping)).map(([groupKey, columns], index) => { return ( {columns.map((column) => { const formData = props.formData; const cellValue = deepGet(props.formData, column.field, undefined); const cellProps = column.getCellProps?.(cellValue, props.formData) ?? {}; const headerProps = column.getHeaderProps?.(cellValue, props.formData) ?? {}; const contentProps = column.getContentProps?.(cellValue, props.formData) ?? {}; const contentLeft = column.renderLeft?.({ cellValue, formData: props.formData }) ?? undefined; const contentRight = column.renderRight?.({ cellValue, formData: props.formData }) ?? undefined; const colSpanAll = callable(column.colSpanAll, { cellValue, formData, }); return ( {column.title} {contentLeft && {contentLeft}} {safeGetCellContent(column, props.formData)} {contentRight && {contentRight}} ); })} ); })} ); }