import { FiltersMap } from '@wix/bex-core';
import { CustomColumnsState } from './CustomColumnsState';
import { ToolbarCollectionState } from './ToolbarCollectionState';
import { CustomColumnsDragAndDrop } from '../components/CustomColumns/CustomColumnsDragAndDrop';

export function setCustomColumnsState<T, F extends FiltersMap>(props: {
  toolbar: ToolbarCollectionState<T, F>;
  customColumnsProps?: {
    readonly dragAndDrop?: typeof CustomColumnsDragAndDrop;
  };
  modalsContainerRef: {
    current: HTMLElement | null | undefined;
  };
}) {
  const { toolbar, customColumnsProps, modalsContainerRef } = props;
  toolbar.customColumnsState ??= new CustomColumnsState({
    table: toolbar,
    container: toolbar.container,
    dragAndDrop: customColumnsProps?.dragAndDrop,
    modalsContainerRef,
  });
}
