import * as React from 'react';
import { RowHeight } from '../../lib/row-height.js';
import { ColumnDef, SortDir } from './types.js';
import { SortRule, ActiveFilter } from '../../lib/table-properties-types.js';

declare function useTableState<TData extends Record<string, unknown>>(data: TData[], columns: ColumnDef<TData>[], defaultSort?: {
    key: string;
    dir: SortDir;
}, paginationOverride?: {
    page: number;
    pageSize: number;
}, 
/**
 * When defined (including `""`), toolbar search is synced from the URL (`?q=`).
 * Use `searchParams.get("q") ?? ""` on library list routes; omit for other hubs.
 */
syncedSearchFromUrl?: string): {
    sortRules: SortRule[];
    setSortRules: React.Dispatch<React.SetStateAction<SortRule[]>>;
    sortKey: string;
    sortDir: SortDir;
    addSortRule: (fieldKey: string) => void;
    removeSortRule: (id: string) => void;
    toggleSortDir: (id: string) => void;
    handleSortByKey: (colKey: string) => void;
    search: string;
    setSearch: React.Dispatch<React.SetStateAction<string>>;
    searchOpen: boolean;
    setSearchOpen: React.Dispatch<React.SetStateAction<boolean>>;
    searchRef: React.RefObject<HTMLInputElement | null>;
    activeFilters: ActiveFilter[];
    setActiveFilters: React.Dispatch<React.SetStateAction<ActiveFilter[]>>;
    filterConnectors: Record<string, "and" | "or">;
    setFilterConnectors: React.Dispatch<React.SetStateAction<Record<string, "and" | "or">>>;
    toggleConnector: (leftId: string) => void;
    getConnector: (leftId: string) => "and" | "or";
    openFilterId: string | null;
    setOpenFilterId: React.Dispatch<React.SetStateAction<string | null>>;
    filterBarVisible: boolean;
    setFilterBarVisible: React.Dispatch<React.SetStateAction<boolean>>;
    drawerExpandedFilters: Set<string>;
    setDrawerExpandedFilters: React.Dispatch<React.SetStateAction<Set<string>>>;
    addFilter: (fieldKey: string, fromDrawer?: boolean) => void;
    updateFilter: (id: string, patch: Partial<ActiveFilter>) => void;
    removeFilter: (id: string) => void;
    groupBy: string | null;
    setGroupBy: React.Dispatch<React.SetStateAction<string | null>>;
    colMenuSearch: Record<string, string>;
    setColMenuSearch: React.Dispatch<React.SetStateAction<Record<string, string>>>;
    selected: Set<string | number>;
    setSelected: React.Dispatch<React.SetStateAction<Set<string | number>>>;
    toggleRow: (id: string | number) => void;
    toggleAll: (allRowIds: (string | number)[]) => void;
    getRowId: (row: TData, index: number, getIdFn?: (r: TData, i: number) => string | number) => string | number;
    colWidths: Record<string, number>;
    setColWidths: React.Dispatch<React.SetStateAction<Record<string, number>>>;
    resizeRef: React.RefObject<{
        key: string;
        startX: number;
        startW: number;
    } | null>;
    startResize: (key: string, e: React.MouseEvent) => void;
    colOrder: string[];
    setColOrder: React.Dispatch<React.SetStateAction<string[]>>;
    moveCol: (key: string, dir: "up" | "down") => void;
    colPins: Record<string, "left" | "right">;
    setColPins: React.Dispatch<React.SetStateAction<Record<string, "left" | "right">>>;
    lockedPins: Record<string, "left" | "right">;
    LOCKED_KEYS: Set<string>;
    pinColumn: (key: string, pin: "left" | "right") => void;
    unpinColumn: (key: string) => void;
    colWrap: Record<string, boolean>;
    setColWrap: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
    toggleWrap: (key: string) => void;
    draggedKey: React.RefObject<string | null>;
    dragOverKey: string | null;
    handleDragStart: (key: string, e: React.DragEvent<HTMLTableCellElement>) => void;
    handleDragOver: (key: string, e: React.DragEvent<HTMLTableCellElement>) => void;
    handleDrop: (key: string) => void;
    handleDragEnd: () => void;
    scrollRef: React.RefObject<HTMLDivElement | null>;
    scrolled: boolean;
    scrollEnd: boolean;
    isOverflowing: boolean;
    checkOverflow: () => void;
    handleScroll: () => void;
    hoveredRow: string | number | null;
    setHoveredRow: React.Dispatch<React.SetStateAction<string | number | null>>;
    rows: TData[];
    pagedRows: TData[];
    groupedRows: {
        groupKey: string | null;
        groupLabel: string | null;
        rows: TData[];
    }[];
    effectivePins: Record<string, "left" | "right">;
    displayCols: ColumnDef<TData>[];
    isReflowViewport: boolean;
    getStickyLeft: (key: string) => number;
    getStickyRight: (key: string) => number;
    stickyStyle: (key: string, isHeader?: boolean) => React.CSSProperties;
    totalWidth: number;
    sheetOpen: boolean;
    setSheetOpen: React.Dispatch<React.SetStateAction<boolean>>;
    sheetInitialPanel: string | null;
    setSheetInitialPanel: React.Dispatch<React.SetStateAction<string | null>>;
    showGridlines: boolean;
    setShowGridlines: React.Dispatch<React.SetStateAction<boolean>>;
    rowHeight: RowHeight;
    setRowHeight: React.Dispatch<React.SetStateAction<RowHeight>>;
    hiddenCols: Set<string>;
    setHiddenCols: React.Dispatch<React.SetStateAction<Set<string>>>;
    toggleColVisibility: (key: string) => void;
};

export { useTableState };
