import { EventSubscription } from "@mongez/events"; import { RestfulEndpoint } from "@mongez/http"; import { FormInterface } from "@mongez/react-form"; import { AxiosResponse } from "axios"; import React from "react"; import type { Column } from "../Column"; import { ColumnSortBy, SortDirection, SuperTableShortKeys, TableCreateButton, TableFilter, TableProps } from "../TableProps"; import { BulkSelectionRow, HoveredRow, LoadMode, PaginationInfo, RegisteredBulkSelectionRow, TableEvent } from "./SuperTable.types"; export declare class SuperTable { lazyTable: boolean; /** * Table Pagination settings */ paginationInfo: PaginationInfo; /** * Default record data * Used with create form usually */ protected defaultRecord: any; /** * Delay time before starting to search */ searchDelay: any; /** * Table data */ data: any[]; /** * Table title */ title: string; /** * Table description */ description: string; /** * Table Columns */ columns: Column[]; /** * Table name */ tableName: string; /** * Table Service */ service?: RestfulEndpoint; /** * Default params to be sent with each list request */ defaultParams?: any; /** * Determine if table is being loaded */ isLoading: boolean; /** * Is resetting filter */ protected isResettingFilter: boolean; /** * Loading mode */ loadMode: LoadMode; /** * Table Component props */ props: Record; /** * Table filters */ filters: TableFilter[]; /** * Filter options */ filterOptions: TableProps["filterOptions"]; /** * Table error */ error: any; /** * Table header buttons */ createButtons: TableCreateButton[]; /** * Whether to fetch data when editing or cloning documents when using the buttons */ fetchRecord: any; /** * Determine whether to display the table header */ displayHeader: any; /** * Table base form */ baseForm?: React.FC; /** * Table filter form id */ tableFilterFromId: string; /** * Request query params */ queryParams: Record; /** * Determine whether to update url query string */ updateQueryString: boolean; /** * Table id */ tableId: string; /** * Table root id */ rootId: string; /** * Displayed columns keys */ displayedColumns: Column[]; /** * Table role */ role: string; /** * Permissions list */ permissions: TableProps["permissions"]; /** * Table cache key */ cacheKey: string; /** * Bulk Actions list */ bulkActions: React.ComponentType[]; /** * Determine whether to enable bulk selection */ bulkSelection: any; /** * Cache displayed columns with bulk selection */ protected displayedColumnsWithBulkSelection: Column[]; /** * Registered bulk selection */ protected registeredBulkSelection: BulkSelectionRow[]; /** * Current query string to be cached so we can use it again when resetting form */ protected currentQueryString: Record; /** * Base route for the table */ route: string; /** * Sort by options */ sortByOptions: ColumnSortBy; /** * Sort by keys that will be used in the api */ orderByKeys: Record<"key" | "direction", string>; /** * Determine whether to enable helmet title */ withHelmet: boolean; /** * Limit options */ limitOptions: number[] | false; /** * Pagination info cast callback */ protected paginationInfoCast: (response: AxiosResponse) => PaginationInfo; /** * Determine if pagination is enabled */ protected paginationEnabled: boolean; /** * Cache handler */ cacheHandler: any; /** * Determine if shortcuts are enabled */ shortcuts: any; /** * Determine if columns selections should be displayed */ columnsSelections: any; /** * Registered shortcuts for this table */ keyboardShortcuts: SuperTableShortKeys[]; /** * Determine if table has too many filters */ hasTooManyFilters: boolean; /** * Max filters to be displayed before hiding the rest */ maxFilters: number; /** * Whether to scroll to top when table is filtered, sorted, or page changed */ scrollTo: any; /** * Keys names for records and record */ protected keysList: { records: string; record: string; createRecord: string; updateRecord: string; }; /** * Determine the current hovered row */ hoveredRow: HoveredRow; /** * Constructor */ constructor(lazyTable?: boolean, name?: string); /** * Set table base route */ setRoute(route: string): this; /** * Register keyboard shortcut */ registerKeyboardShortcut(shortcut: SuperTableShortKeys): void; /** * Get keyboard shortcuts in ascending order using `order` key if exists */ getKeyboardShortcuts(): SuperTableShortKeys[]; /** * Set current hovered row */ hovering(row: HoveredRow): this; /** * Listen to hovered row event */ onRowHovered(rowId: number, callback: (isHovered: boolean) => void): EventSubscription; /** * Merge keys */ mergeKeys(keys: any): this; /** * Get name of the given key */ getKey(key: string, defaultValue?: any): any; /** * Set default record */ setDefaultRecord(record: any): this; /** * Get default record */ getDefaultRecord(): any; /** * Set limit options */ setLimitOptions(options: number[] | false): this; /** * Listen to table page change */ onPageChange(callback?: (page: number, paramsList: any) => void): EventSubscription; /** * Listen to table filter change */ onFilterChange(callback?: (filter: any) => void): EventSubscription; /** * Listen to table sort change */ onSortChange(callback?: (sortingColumn: string, sortDirection: SortDirection, column: Column) => void): EventSubscription; /** * Listen to table size change */ onPageSizeChange(callback?: (size: number) => void): EventSubscription; /** * Set if pagination is enabled */ pagination(enabled?: boolean): this; /** * Determine if pagination is enabled */ isPaginationEnabled(): boolean; /** * Cast pagination info */ castPaginationInfo(callback: (response: AxiosResponse) => PaginationInfo): this; /** * Determine whether to enable or disable bulk selection */ enableBulkSelection(bulkSelection: boolean): this; /** * Set table role */ setRole(role: string): this; /** * Set table permissions */ setPermissions(permissions: TableProps["permissions"]): this; /** * Check if table has role */ hasRole(): boolean; /** * Check if table has role permission */ hasPermission(permission: string): any; /** * Get current user */ get user(): any; /** * Check if table allows the given permission * This should be used with actions, that needs to get the row and row index * Otherwise, use hasPermission */ allows(permission: string, ...args: any[]): any; /** * Determine if table forbids the given permission * This should be used with actions, that needs to get the row and row index * Otherwise, use hasPermission */ forbids(permission: string, ...args: any[]): boolean; /** * Get bulk selection status */ getBulkSelection(): boolean; /** * Set filter options */ setFilterOptions(filterOptions: TableProps["filterOptions"]): this; /** * Register bulk selection */ registerBulkSelection(bulkSelectionRow: BulkSelectionRow): RegisteredBulkSelectionRow; /** * Toggle check state for selected bulk rows */ toggleSelectedBulkRows(): this; /** * Unregister bulk selection */ unregisterBulkSelection(row: any, rowIndex: any): this; /** * Toggle all bulk selection */ toggleAllBulkSelection(checked: boolean): this; /** * Get selected bulk rows */ getSelectedBulkRows(): BulkSelectionRow[]; /** * Remove the given bulk rows */ removeBulkRows(rows: BulkSelectionRow[]): this; /** * Set bulk actions */ setBulkActions(bulkActions: React.ComponentType[]): this; /** * Get Bulk Actions */ getBulkActions(): React.ComponentType[]; /** * Get create buttons */ getCreateButtons(): TableCreateButton[]; /** * Set table id */ setId(tableId: string): this; /** * Determine whether to update url query string */ setUpdateQueryString(updateQueryString: boolean): this; /** * Initialize table manager */ init(): void; /** * Load Data from service */ load(params?: any, loadMode?: LoadMode): Promise; /** * Update data from response */ updateDataFromResponse(response: AxiosResponse): void; /** * Update sort by options */ updateSortByOptions({ key, direction, }: { key: string; direction: SortDirection; }): void; /** * Set pagination info */ setPaginationInfo(paginationInfo: PaginationInfo): this; /** * Update table loading state */ setLoading(loading: boolean): this; /** * Go to the given page number */ goToPage(pageNumber: number, moreParams?: any): this | Promise; /** * Set table name */ setName(tableName: string): this; /** * Set table title */ setTitle(title: string): this; /** * Set table description */ setDescription(description: string): this; /** * Get column by key */ getColumn(key: string): Column; /** * Set table columns */ setColumns(columns: Column[]): this; /** * Reset displayed columns */ resetDisplayedColumns(): this; /** * Get the given cached key */ getCached(key: string, defaultValue?: any): any; /** * Set displayed columns */ setDisplayedColumns(displayedColumns: string[]): this; /** * Cache the given value */ cache(key: string, value: any): void; /** * Get only the columns that are marked as displayed */ getDisplayedColumns(): Column[]; /** * Set table service */ setService(service: RestfulEndpoint): this; /** * Set default params to be used when loading records */ setDefaultParams(params: any): this; /** * Set table props */ setProps(props: any): this; /** * Set table data */ setData(data: any[]): this; /** * Listen to loading event */ onLoading(callback: (loading: boolean) => void): EventSubscription; /** * Listen to the given event */ on(event: TableEvent, callback: (...args: any[]) => void): EventSubscription; /** * Trigger the given event with the given data */ trigger(event: TableEvent, ...args: any[]): this; /** * Set create buttons */ setCreateButtons(buttons: TableCreateButton[]): this; /** * Set base form */ setBaseForm(baseForm: React.FC): this; /** * Delete table row */ deleteRow(row: any, _rowIndex: number): void; /** * Update table row */ updateRow(row: any, rowIndex: number): void; /** * Push new row to the end of table */ pushRow(row: any): void; /** * Add row to the start of the table */ unshiftRow(row: any): void; /** * Increase pagination info with the given number of rows */ increasePaginationInfoRow(numberOfRows: number): void; /** * Decrease pagination info with the given number of rows */ decreasePaginationInfoRow(numberOfRows: number): void; /** * Reset the table properties */ reset(): void; /** * Sort callback */ protected sortCallback: any; /** * Original data */ protected originalData: any[] | undefined; /** * Set sort callback */ setSortMethod(callback: any): this; /** * Set table original data * Works only when the table is not using a service */ setOriginalData(data?: any[]): this; /** * Set table filters */ setFilters(filters: TableFilter[]): this; /** * Manager table filters to return it properly */ getFilters(): TableFilter[]; /** * Listen to the input change */ get onFilterInputChange(): (this: unknown, _e: any) => void; /** * Submit filter form for filtering table data */ submitFilter({ form }: { form: any; }): void; /** * Load filter for the given form */ loadFilter(form: FormInterface): void; /** * Get initial filter open state */ isFiltersOpened(): any; /** * Update filter state in cache */ updateFiltersState(state: boolean): this; /** * Reset table filters */ resetFilters(): void; /** * Sort by the given name and order */ sortBy(name: string, order?: "asc" | "desc"): this; /** * Update limit */ updateLimit(limit: number): void; } //# sourceMappingURL=SuperTable.d.ts.map