UNPKG

@hubee/hubee-ui-table

Version:

Hubee UI Table é uma biblioteca que faz abstração da implementação de data tables para o React

430 lines (378 loc) 16.6 kB
/// <reference types="react" /> import { TableProps as TableProps$1, TableRowOptions as TableRowOptions$1, TableStyleOptions as TableStyleOptions$1, TablePaginationOptions as TablePaginationOptions$1, TablePaginationProps as TablePaginationProps$1, Action as Action$1, ITableSearchService as ITableSearchService$1, IGlobalFilterComponent as IGlobalFilterComponent$1, IHeaderComponent as IHeaderComponent$1, TableEventOptions as TableEventOptions$1, LoadOnDemandOptions as LoadOnDemandOptions$1 } from '@/core/interfaces'; import { TablePaginationActionsProps as TablePaginationActionsProps$1 } from '@mui/material/TablePagination/TablePaginationActions'; import { HeaderGroup, Row, HeaderProps, SortingRule, Column } from 'react-table'; import GlobalFilterProps$1 from '@/core/interfaces/props/search-filter-props'; import { SearchModel as SearchModel$1, ColumnModel as ColumnModel$1, SearchResponseModel as SearchResponseModel$1, SearchCriteriaModel as SearchCriteriaModel$1, PaginationModel as PaginationModel$1, SearchSortModel as SearchSortModel$1, SearchConditionType as SearchConditionType$1, SearchOperatorType as SearchOperatorType$1 } from '@/core/models'; import { TableProps as TableProps$2, GlobalFilterProps as GlobalFilterProps$2, ITableSearchService as ITableSearchService$2, SearchModel as SearchModel$2 } from '@/index'; import { Sizing as Sizing$1 } from '@/core/models/common'; import { TableIcons as TableIcons$1 } from '@/core/models/table'; import React$1 from 'react'; import { SvgIcon } from '@mui/material'; interface MakeEmptyRowsProps { rows: number; } declare function MakeEmptyRows(props: MakeEmptyRowsProps): JSX.Element; declare function MaterialTable(props: TableProps$1): JSX.Element; declare namespace MaterialTable { var defaultProps: { GlobalFilterComponent: undefined; rowOptions: TableRowOptions$1; styleOptions: TableStyleOptions$1; paginationOptions: TablePaginationOptions$1; }; } declare function Pagination(props: TablePaginationProps$1): JSX.Element; declare function TablePaginationActions(props: TablePaginationActionsProps$1): JSX.Element; interface TableBodyOperationsProps { isLoading: boolean; count: number; rowsPerPage: number; } declare function TableBodyOperations(props: TableBodyOperationsProps): JSX.Element; interface TableCellSortingProps { column: HeaderGroup<any>; } declare function TableCellSorting(props: TableCellSortingProps): JSX.Element; declare function SearchDefault(props: GlobalFilterProps$1): JSX.Element; interface TableInfoResultProps { labelDisplayedResult: string; } declare function TableInfoResult(props: TableInfoResultProps): JSX.Element; interface TheadCellActionProps { label?: string; isLastCell: boolean; enableRowActions: boolean; } declare function TheadCellAction(props: TheadCellActionProps): JSX.Element; declare namespace TheadCellAction { var defaultProps: { label: string; }; } interface BodyCellActionProps { isLastCell: boolean; actions?: Action$1<any>[]; rowData?: any; } declare function BodyCellAction(props: BodyCellActionProps): JSX.Element; declare namespace BodyCellAction { var defaultProps: { actions: never[]; rowData: undefined; }; } interface TheadMapRowProps { headerGroups: HeaderGroup<any>[]; enableActions: boolean; } declare function TheadMapRow(props: TheadMapRowProps): JSX.Element; interface BodyMapRowProps { rows: Row<any>[]; prepareRow: (row: Row<any>) => void; actions?: Action$1<any>[]; rowOptions: TableRowOptions$1; } declare function BodyMapRow(props: BodyMapRowProps): JSX.Element; interface ITableSearchService { tableProps: TableProps$2; setTableProps(tableProps: TableProps$2): void; makeSearchModel(): SearchModel$1; makeColumns(): ColumnModel$1<any>[]; makeLabelDisplayedResult(response: SearchResponseModel$1<any>): string; search<T>(searchModel: SearchModel$1): Promise<SearchResponseModel$1<T>>; makeSearchResponseClientSide(values: any[], searchModel: SearchModel$1): SearchResponseModel$1<any>; verifyDisableRowSelected(data: any): boolean; } interface TablePaginationOptions { enablePagination?: boolean; pageIndex?: number; rowsPerPage?: number; withPaginationAtTop?: boolean; rowsPerPageOptions?: number[]; } declare const PaginationOptionsDefault: (options?: TablePaginationOptions) => TablePaginationOptions; interface TableRowOptions { enableRowActions?: boolean; enableRowSelected?: boolean; enableRowSelectedStyle?: boolean; enableRowTitle?: boolean; rowActions?: Action$1<any>[]; propertyNameForDisableRow?: string; propertyNameForDefaultRowSelected?: string; defaultSelectedRowIds?: Record<string, boolean>; } declare const RowOptionsDefault: (options?: TableRowOptions) => TableRowOptions; interface TableStyleOptions { withContainerBorder?: boolean; withContainerBorderSizing?: Sizing$1; globalFilterWithContainerBorder?: boolean; withTableInfoResult?: boolean; withZebraStriped?: boolean; classNameRoot?: string; borderInCell?: boolean; enableStickyHeader?: boolean; } declare const StyleOptionsDefault: (options?: TableStyleOptions) => TableStyleOptions; interface TableProps { service: ITableSearchService$1; GlobalFilterComponent?: IGlobalFilterComponent$1; HeaderComponent?: IHeaderComponent$1; paginationOptions?: TablePaginationOptions; styleOptions?: TableStyleOptions; rowOptions?: TableRowOptions; eventOptions?: TableEventOptions$1; loadOnDemandOptions?: LoadOnDemandOptions$1; } declare const TablePropsDefault: (props: TableProps) => TableProps; interface TablePaginationProps { count: number; page: number; rowsPerPage: number; rowsPerPageOptions: number[]; onRowsPerPageChange: (event: any) => void; onPageChange: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>, newPage: number) => void; } interface TablePaginationActionsProps { count: number; page: number; rowsPerPage: number; onChangePage: (event: React.MouseEvent<HTMLElement>, newPage: number) => void; } interface GlobalFilterProps { onChangeQuery: (filters: SearchCriteriaModel$1[], resetPage?: boolean) => void; } interface Action<RowData extends object> { icon: TableIcons$1 | string; tooltip?: string; tooltipDisabled?: string; isRowActionOnClick?: boolean; isButton?: boolean; buttonName?: string; onClick: (event: any, data: RowData | RowData[]) => void; hidden?: (data: RowData | RowData[]) => boolean; disabled?: (data: RowData | RowData[]) => boolean; } interface TableEventOptions { enableNavigateKeyboardEvent?: boolean; enableSearchModelRequestEvent?: boolean; } declare const EventOptionsDefault: (options?: TableEventOptions) => TableEventOptions; interface LoadOnDemandOptions { enableLoadOnDemand?: boolean; /** This is number a milliseconds for load demand interval. */ loadOnDemandInterval?: number; loadOnDemandShowLoading?: boolean; } declare const LoadOnDemandOptionsDefault: (options?: LoadOnDemandOptions) => LoadOnDemandOptions; type IGlobalFilterComponent = (props: GlobalFilterProps$2) => JSX.Element; interface HeaderCheckboxProps { /** react-table's header props */ headerProps: React.PropsWithChildren<HeaderProps<any>>; /** A predicate - based on your business logic - to determine whether a given row should be selectable */ checkIfRowIsSelectable: (row: Row<any>) => boolean; /** Whether to allow page selection. Default: true */ shouldSelectPage?: boolean; } type IHeaderComponent = () => JSX.Element; type AlignType = 'center' | 'inherit' | 'justify' | 'left' | 'right'; type RenderType<T> = (value: any, rowData: T) => JSX.Element; type RenderTypeTitle<T> = (rowData: T) => string; declare class ColumnModel<T> { name: string; property: string; sorting: boolean; align?: AlignType; render: RenderType<T>; width?: any; maxWidth?: any; renderTitleCustom?: RenderTypeTitle<T>; renderHeaderColumnCustom?: React$1.ReactNode; constructor(name: string, property: string, { sorting, align, width, maxWidth, renderHeaderColumnCustom, }: { sorting?: boolean | undefined; align?: AlignType | undefined; width?: any; maxWidth?: any; renderHeaderColumnCustom?: JSX.Element | undefined; }); static build<T>(name: string, property: string): ColumnModel<T>; withRender(render: RenderType<T>): ColumnModel<T>; withRenderTitleCustom(renderTitleCustom: RenderTypeTitle<T>): ColumnModel<T>; } declare enum Sizing { SMALL = "small", MEDIUM = "medium", LARGE = "large", EXTRALARGE = "extraLarge" } declare enum ClassNameKey { navigateToFocusActive = "navigate-to-focus-active", navigationActiveRow = "navigation-active-row" } declare enum SearchConditionType { or = "OR", and = "AND" } declare enum SearchOperatorType { equal = "EQUAL", between = "BETWEEN" } declare class SearchModel { endpoint: string; criterias: SearchCriteriaModel$1[]; pagination: PaginationModel$1; orderBy: SearchSortModel$1; enableInfiniteScroll: boolean; constructor(endpoint: string, defaultOrderByField: string, { criterias, isOrderByDesc, enableInfiniteScroll, }: { criterias?: SearchCriteriaModel$1[] | undefined; isOrderByDesc?: boolean | undefined; enableInfiniteScroll?: boolean | undefined; }); static makeEmpty(): SearchModel; updatePagination(pageIndex: number, rowsPerPage: number): void; updateOrderBy(sorting: SortingRule<any>): void; updateSearchCriteria(criterias: SearchCriteriaModel$1[]): void; hasChangeOrderBy(sorting: SortingRule<any>): boolean; } declare class SearchSortModel { field: string; defaultField: string; isOrderByDesc: boolean; constructor(defaultField: string, { isOrderByDesc }: { isOrderByDesc?: boolean | undefined; }); updateByTable(field: string, isOrderByDesc: boolean): void; } declare class SearchCriteriaModel { Key: string; Value: string; Condition: SearchConditionType$1; Operator: SearchOperatorType$1; constructor(key: string, { value, condition, operator, }: { value?: string | undefined; condition?: SearchConditionType$1 | undefined; operator?: SearchOperatorType$1 | undefined; }); setValue(value: string): void; } declare class SearchResponseModel<T> { searchModel?: SearchModel$1; page: PaginationModel$1; data: T; constructor(data: T, page: PaginationModel$1, searchModel?: SearchModel$1 | undefined); static makeEmpty(): SearchResponseModel<any>; } declare class PaginationModel { from: number; size: number; total: number; constructor({ from, size, total }: { from?: number | undefined; size?: number | undefined; total?: number | undefined; }); static makeByTable(pageIndex: number, rowsPerPage: number): PaginationModel; } interface PersonTestModel { id: any; firstName: string; lastName: string; age: number; visits: number; progress: number; status: string; } declare enum TableOperationsType { PAGE_CHANGED = "PAGE_CHANGED", PAGE_SIZE_CHANGED = "PAGE_SIZE_CHANGED", PAGE_SORT_CHANGED = "PAGE_SORT_CHANGED", PAGE_FILTER_CHANGED = "PAGE_FILTER_CHANGED", TOTAL_COUNT_CHANGED = "TOTAL_COUNT_CHANGED" } declare enum TableIcons { SEARCH = "search", DELETE = "delete", OPEN_IN_NEW = "open_in_new" } type SvgIconComponent = typeof SvgIcon; declare const TableIconsMaterial: Map<string, JSX.Element>; declare class SelectedRowsModel { ids: any[]; values: any[]; constructor(ids: any[], values: any[]); } declare class EventKey { private static baseKey; static selectedRowsEvent: string; static searchModelRequestEvent: string; static navigateBetweenRowWasChangedEvent: string; static rowNavigateWasDeletedEvent: string; static loadOnDemandFinishedEvent: string; } declare enum keyboardEventKey { ARROW_UP = "ArrowUp", ARROW_DOWN = "ArrowDown", ARROW_RIGHT = "ArrowRight", ARROW_LEFT = "ArrowLeft", DELETE = "Delete", TAB = "Tab", SPACE = "Space" } declare class NavigateBetweenRowModel { previousRowId: string; currentRowId: string; rowData: any; constructor(previousRowId: string, currentRowId: string, rowData: any); } declare abstract class TableSearchService implements ITableSearchService$1 { tableProps: TableProps$1; verifyDisableRowSelected(data: any): boolean; abstract search<T>(searchModel: SearchModel$1): Promise<SearchResponseModel$1<T>>; abstract makeSearchModel(): SearchModel$1; abstract makeColumns(): ColumnModel$1<any>[]; abstract makeLabelDisplayedResult(response: SearchResponseModel$1<any>): string; setTableProps(tableProps: TableProps$1): void; makeCriteriaToUrl(searchModel: SearchModel$1): string; makeSearchResponseClientSide(values: any[], searchModel: SearchModel$1): SearchResponseModel$1<any>; } declare abstract class TableSimpleSearchService extends TableSearchService { abstract search<T>(searchModel: SearchModel$1): Promise<SearchResponseModel$1<T>>; abstract makeSearchModel(): SearchModel$1; abstract makeColumns(): ColumnModel$1<any>[]; makeLabelDisplayedResult(response: SearchResponseModel$1<any>): string; } declare class ColumnService { static makeModelToColumn(value: ColumnModel$1<any>[]): Column<any>[]; static makeSelectionColumn(service: ITableSearchService$2): Column<any>; } declare class EventService { static dispatchSelectedRowsEvent(selectedRowIds: Record<string, boolean>, selectedFlatRows: Row<any>[]): void; static dispatchSearchModelRequestEvent(searchModel: SearchModel$2): void; static dispatchNavigateBetweenRowWasChangedEvent({ previousIndex, nextIndex, rows, }: { previousIndex?: number | undefined; nextIndex?: number | undefined; rows?: Row<any>[] | undefined; }): void; static dispatchRowNavigateWasDeletedEvent(id: string): void; static dispatchLoadOnDemandFinishedEvent(): void; static dispatchEventOnChange(value: any, input: HTMLInputElement): void; } declare class NavigatingService { static getCurrentIndex(): number; static getRowId(): string; static getRowIdByIndex(index: number): string; static isQuantityOnFocus: () => boolean; static quantityIncrement(): void; static quantityDecrement(): void; static focusToActive(onMouseDown: boolean): void; static getIndexOnMouseDown(element: any): number; static navigateToOnMouseDown(element: any): number; static makeQuerySelectorByRowIndex: (index: number) => string; static getNextInputFocus: () => HTMLInputElement; static getTabIndexByInputFocus: () => number; static navigateTo(index: number, focusToActive?: boolean, onMouseDown?: boolean): boolean; static tabNavidateTo(): void; static toggleSelectionByRowActive(): void; static remove(): void; } export { Action, AlignType, BodyCellAction, BodyMapRow, ClassNameKey, ColumnModel, ColumnService, EventKey, EventOptionsDefault, EventService, GlobalFilterProps, HeaderCheckboxProps, IGlobalFilterComponent, IHeaderComponent, ITableSearchService, LoadOnDemandOptions, LoadOnDemandOptionsDefault, MakeEmptyRows, MaterialTable, NavigateBetweenRowModel, NavigatingService, Pagination, PaginationModel, PaginationOptionsDefault, PersonTestModel, RenderType, RenderTypeTitle, RowOptionsDefault, SearchConditionType, SearchCriteriaModel, SearchDefault, SearchModel, SearchOperatorType, SearchResponseModel, SearchSortModel, SelectedRowsModel, Sizing, StyleOptionsDefault, SvgIconComponent, TableBodyOperations, TableCellSorting, TableEventOptions, TableIcons, TableIconsMaterial, TableInfoResult, TableOperationsType, TablePaginationActions, TablePaginationActionsProps, TablePaginationOptions, TablePaginationProps, TableProps, TablePropsDefault, TableRowOptions, TableSearchService, TableSimpleSearchService, TableStyleOptions, TheadCellAction, TheadMapRow, keyboardEventKey };