import { MantineThemeOverride } from "@mantine/core";
import {
  BlockSchema,
  SuggestionsMenu,
  SuggestionsMenuDynamicParams,
  SuggestionsMenuFactory,
  SuggestionsMenuStaticParams,
} from "bocknoat-core";
import { ReactElementFactory } from "../ElementFactory/components/ReactElementFactory";
import { ReactSlashMenuItem } from "./ReactSlashMenuItem";
import { SlashMenu } from "./components/SlashMenu";

export const createReactSlashMenuFactory =
  <BSchema extends BlockSchema>(
    theme: MantineThemeOverride
  ): SuggestionsMenuFactory<ReactSlashMenuItem<BSchema>> =>
  (staticParams): SuggestionsMenu<ReactSlashMenuItem<BSchema>> =>
    ReactElementFactory<
      SuggestionsMenuStaticParams<ReactSlashMenuItem<BSchema>>,
      SuggestionsMenuDynamicParams<ReactSlashMenuItem<BSchema>>
    >(staticParams, SlashMenu, theme, {
      animation: "fade",
      placement: "bottom-start",
    });
