import React from "react";

import { styled } from "../theme";

import type * as WPDS from "../theme";

import { DropdownMenu as ActionMenuPrimitive } from "radix-ui";
import { Divider } from "../divider";

const NAME = "ActionMenuGroup";

export const StyledGroup = styled(ActionMenuPrimitive.Group, {});

export type ActionMenuGroupProps = {
  /** Any React node may be used as a child to allow for formatting */
  children?: React.ReactNode;
  /** Override CSS */
  css?: WPDS.CSS;
} & ActionMenuPrimitive.DropdownMenuGroupProps;

export const ActionMenuGroup = React.forwardRef<
  HTMLDivElement,
  ActionMenuGroupProps
>(({ children, ...props }: ActionMenuGroupProps, ref) => {
  return (
    <StyledGroup {...props} ref={ref}>
      {children}
      <Divider />
    </StyledGroup>
  );
});

ActionMenuGroup.displayName = NAME;
