import { MlBaseFromList } from '../ml-base-form-list';
import { usePipeline } from './extensions';
import type { MlFormListProps } from './types';

export function MlFormList(props: MlFormListProps) {
  const defaultFormListData = props.defaultFormListData;
  const columns = props.columns;
  const extensions = props.extensions;

  const headerLeftSlot = props.headerLeftSlot;
  const headerRightSlot = props.headerRightSlot;
  const footerLeftSlot = props.footerLeftSlot;
  const footerRightSlot = props.footerRightSlot;

  const pipeline = usePipeline({
    defaultFormListData,
    columns,
    extensions,

    headerLeftSlot,
    headerRightSlot,
    footerLeftSlot,
    footerRightSlot,
  });

  return <MlBaseFromList {...props} {...pipeline.buildProps()} />;
}
