import * as React from "react";

export type QCELLAnyObject = Record<string, any>;
export type QCELLRowData = QCELLAnyObject | any[];
export type QCELLStyle = React.CSSProperties | QCELLAnyObject;

export interface QCELLColumn {
  key?: string;
  title?: string[];
  width?: string | number;
  sort?: boolean;
  type?: string;
  format?: QCELLAnyObject;
  style?: QCELLStyle;
  [key: string]: any;
}

export interface QCELLRowHeight {
  header?: number;
  data?: number;
  footer?: number;
  [key: string]: any;
}

export interface QCELLPagination {
  unitlist?: number[];
  pageunit?: number;
  pagecount?: number;
  mode?: "simple" | "extend" | string;
  [key: string]: any;
}

export interface ObjPropertyType {
  id?: string;
  parentid?: string;
  width?: string | number;
  height?: string | number;
  data?: {
    input?: QCELLRowData[];
    [key: string]: any;
  } | QCELLRowData[];
  columns?: QCELLColumn[];
  rowheight?: QCELLRowHeight;
  rowHeight?: QCELLRowHeight;
  pagination?: QCELLPagination;
  [key: string]: any;
}

export interface QCELLInstance {
  
  [key: string]: any;
}

export interface QCELLType {
  create: (property: ObjPropertyType | QCELLAnyObject) => void;
  getInstance: (id: string) => QCELLInstance | null;
  deleteInstance: (id: string) => void;
  hasInstance?: (id: string) => boolean;
  getInstanceIDs?: () => string[];
  [key: string]: any;
}

export interface QCELLReactRef {
  getQCELLInstance: () => QCELLInstance | null;
  getQCELL: () => QCELLType;
}

export interface QCELLReactProps {
  id?: string;
  width?: string | number;
  height: string | number;
  objProperty?: ObjPropertyType;

  data?: QCELLRowData[] | { input?: QCELLRowData[]; [key: string]: any };
  columns?: QCELLColumn[];
  rowHeight?: QCELLRowHeight;
  rowheight?: QCELLRowHeight;
  pagination?: QCELLPagination;

  [key: string]: any;
}

declare const QCELLReact: React.ForwardRefExoticComponent<
  React.PropsWithoutRef<QCELLReactProps> &
    React.RefAttributes<QCELLReactRef>
>;

export default QCELLReact;
