from typing import TypedDict, List, Optional, Union, Any
from st_aggrid import JsCode


class ColumnDef(TypedDict, total=False):
    headerName: Optional[str]
    field: Optional[str]
    sortable: Optional[bool]
    filter: Optional[
        Union[bool, str]
    ]  # e.g., 'agTextColumnFilter', 'agNumberColumnFilter'
    editable: Optional[bool]
    resizable: Optional[bool]
    width: Optional[int]
    minWidth: Optional[int]
    maxWidth: Optional[int]
    cellRenderer: Optional[Union[str, JsCode]]
    cellEditor: Optional[Union[str, JsCode]]
    valueGetter: Optional[JsCode]
    valueSetter: Optional[Union[JsCode, bool]]
    cellStyle: Optional[Union[dict, JsCode]]
    cellClass: Optional[Union[str, List[str], JsCode]]
    pinned: Optional[str]  # 'left', 'right', or None
    hide: Optional[bool]
    tooltipField: Optional[str]
    checkboxSelection: Optional[Union[bool, JsCode]]
    headerCheckboxSelection: Optional[Union[bool, JsCode]]
    headerTooltip: Optional[str]


class GridOptions(TypedDict, total=False):
    rowData: Optional[List[dict]]
    columnDefs: Optional[List[ColumnDef]]  # Updated to use ColumnDef
    defaultColDef: Optional[ColumnDef]
    rowSelection: Optional[str]  # 'single' or 'multiple'
    pagination: Optional[bool]
    paginationPageSize: Optional[int]
    domLayout: Optional[str]  # 'normal', 'autoHeight', or 'print'
    suppressRowClickSelection: Optional[bool]
    animateRows: Optional[bool]
    onGridReady: Optional[JsCode]
    onRowClicked: Optional[JsCode]
    onCellClicked: Optional[JsCode]
    frameworkComponents: Optional[dict]
    rowHeight: Optional[int]
    headerHeight: Optional[int]
    enableSorting: Optional[bool]
    enableFilter: Optional[bool]
    suppressHorizontalScroll: Optional[bool]
    masterDetail: Optional[bool]
    detailCellRendererParams: Optional[dict]
    groupDefaultExpanded: Optional[int]
    groupSelectsChildren: Optional[bool]
    suppressAggFuncInHeader: Optional[bool]
    suppressMenuHide: Optional[bool]
    suppressColumnVirtualisation: Optional[bool]
    suppressScrollOnNewData: Optional[bool]
    tooltipShowDelay: Optional[int]
    enableRangeSelection: Optional[bool]
    enableCharts: Optional[bool]
    suppressContextMenu: Optional[bool]
    suppressMovableColumns: Optional[bool]
    suppressFieldDotNotation: Optional[bool]
    accentedSort: Optional[bool]
    rowClassRules: Optional[Union[dict, JsCode]]
    getRowStyle: Optional[JsCode]
    getRowClass: Optional[JsCode]
    suppressRowHoverHighlight: Optional[bool]
    suppressCellFocus: Optional[bool]
    suppressAnimationFrame: Optional[bool]
    suppressClipboardPaste: Optional[bool]
    suppressMultiSort: Optional[bool]
    suppressDragLeaveHidesColumns: Optional[bool]
    suppressMakeColumnVisibleAfterUnGroup: Optional[bool]
    suppressMaintainUnsortedOrder: Optional[bool]
    suppressNoRowsOverlay: Optional[bool]
    suppressLoadingOverlay: Optional[bool]
    suppressRowTransform: Optional[bool]
    suppressAutoSize: Optional[bool]
    suppressColumnMoveAnimation: Optional[bool]
    suppressPreventDefaultOnMouseWheel: Optional[bool]
    suppressBrowserResizeObserver: Optional[bool]
    suppressTouch: Optional[bool]
    suppressAsyncEvents: Optional[bool]
    suppressAggAtRootLevel: Optional[bool]
    suppressRowDrag: Optional[bool]
    suppressScrollWhenPopupsAreOpen: Optional[bool]
    suppressExcelExport: Optional[bool]
    suppressCsvExport: Optional[bool]
    suppressPropertyNamesCheck: Optional[bool]
