import { MlBaseFrom } from '../ml-base-form';
import { usePipeline } from './extensions';
import type { MlFormProps } from './types';

export function MlForm(props: MlFormProps) {
  const defaultFormData = props.defaultFormData;
  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({
    defaultFormData,
    columns,
    extensions,

    headerLeftSlot,
    headerRightSlot,
    footerLeftSlot,
    footerRightSlot,
  });

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