import { PopupHandle } from "@progress/kendo-react-popup/dist/npm/Popup";

export interface PopupProps {
  dataTestId?: string;
  children?: React.ReactNode;
  anchor?: null | HTMLElement;
  anchorAlign?: Align;
  animate?: boolean | PopupAnimation;
  appendTo?: null | HTMLElement;
  className?: string | string[];
  collision?: Collision;
  id?: string;
  margin?: Margin;
  offset?: Offset;
  popupAlign?: Align;
  popupClass?: string | string[] | { [key: string]: boolean };
  positionMode?: PositionMode;
  scale?: number;
  show?: boolean;
  style?: React.CSSProperties;
  onClose?: (event: CloseEvent) => void;
  onOpen?: (event: OpenEvent) => void;
  onPosition?: (event: PositionEvent) => void;
}

export interface Align {
  horizontal: "center" | "left" | "right";
  vertical: "center" | "top" | "bottom";
}

export interface PopupAnimation {
  closeDuration?: number;
  openDuration?: number;
}

export interface Collision {
  horizontal: CollisionType;
  vertical: CollisionType;
}

export interface Margin {
  horizontal: number;
  vertical: number;
}

export interface Offset {
  left: number;
  top: number;
}

export type PositionMode = "absolute" | "fixed";

export interface CloseEvent {
  target: PopupHandle;
}

export interface OpenEvent {
  target: PopupHandle;
}

export interface PositionEvent {
  fitted: boolean;
  flipped: boolean;
  target: PopupHandle;
}

export type CollisionType = "fit" | "flip" | "none";
