UNPKG

slickgrid-react

Version:
209 lines (208 loc) 12.1 kB
import { type BackendService, type BackendServiceApi, type BasePaginationComponent, type Column, type EventSubscription, type ExtensionList, type ExternalResource, type Metrics, type Pagination, type PaginationMetadata, SlickDataView, SlickEventHandler, SlickGrid, BackendUtilityService, CollectionService, ExtensionService, ExtensionUtility, FilterFactory, FilterService, GridEventService, GridService, GridStateService, HeaderGroupingService, PaginationService, ResizerService, type RxJsFacade, SharedService, SlickGroupItemMetadataProvider, SortService, TreeDataService } from '@slickgrid-universal/common'; import { EventPubSubService } from '@slickgrid-universal/event-pub-sub'; import { SlickFooterComponent } from '@slickgrid-universal/custom-footer-component'; import { SlickEmptyWarningComponent } from '@slickgrid-universal/empty-warning-component'; import React from 'react'; import type { Subscription } from 'rxjs'; import { I18nextContext } from '../contexts/i18nextContext.js'; import type { GridOption, I18Next, SlickgridReactInstance } from '../models/index.js'; import { TranslaterI18NextService } from '../services/translaterI18Next.service.js'; import type { SlickgridReactProps } from './slickgridReactProps.js'; interface State { _options: GridOption; paginationService: PaginationService; showPagination: boolean; } export declare class SlickgridReact<TData = any> extends React.Component<SlickgridReactProps, State> { readonly props: SlickgridReactProps; static contextType: React.Context<I18Next | null>; context: React.ContextType<typeof I18nextContext>; protected _mounted: boolean; protected setStateValue(key: string, value: any, callback?: () => void): void; protected _columns: Column<TData>[]; protected _currentDatasetLength: number; protected _dataset: any[] | null; protected _options: GridOption; protected _elm?: HTMLDivElement | null; protected _collectionObservers: Array<null | { disconnect: () => void; }>; protected _eventHandler: SlickEventHandler; protected _eventPubSubService: EventPubSubService; protected _hideHeaderRowAfterPageLoad: boolean; protected _i18next: I18Next | null; protected _isAutosizeColsCalled: boolean; protected _isGridInitialized: boolean; protected _isDatasetInitialized: boolean; protected _isDatasetHierarchicalInitialized: boolean; protected _isPaginationInitialized: boolean; protected _isLocalGrid: boolean; protected _paginationOptions: Pagination | undefined; protected _registeredResources: ExternalResource[]; protected _scrollEndCalled: boolean; protected get options(): GridOption; protected set options(options: GridOption); groupItemMetadataProvider?: SlickGroupItemMetadataProvider; backendServiceApi: BackendServiceApi | undefined; metrics?: Metrics; showPagination: boolean; serviceList: any[]; subscriptions: Array<EventSubscription | Subscription>; slickEmptyWarning: SlickEmptyWarningComponent | undefined; slickFooter: SlickFooterComponent | undefined; slickPagination: BasePaginationComponent | undefined; backendUtilityService: BackendUtilityService; collectionService: CollectionService; extensionService: ExtensionService; extensionUtility: ExtensionUtility; filterFactory: FilterFactory; filterService: FilterService; gridEventService: GridEventService; gridService: GridService; gridStateService: GridStateService; groupingService: HeaderGroupingService; headerGroupingService: HeaderGroupingService; resizerService: ResizerService; rxjs?: RxJsFacade; sharedService: SharedService; sortService: SortService; treeDataService: TreeDataService; dataView: SlickDataView<TData>; grid: SlickGrid; totalItems: number; extensions: ExtensionList<any>; instances: SlickgridReactInstance | null; static defaultProps: { containerService: import("../services/container.service.js").ContainerService; translaterService: TranslaterI18NextService; gridId: string; dataset: never[]; columns: never[]; options: {}; }; get dataset(): any[]; set dataset(newDataset: any[]); get datasetHierarchical(): any[] | undefined; set datasetHierarchical(newHierarchicalDataset: any[] | undefined); protected get paginationService(): PaginationService; protected set paginationService(value: PaginationService); constructor(props: SlickgridReactProps); get backendService(): BackendService | undefined; get eventHandler(): SlickEventHandler; get isDatasetInitialized(): boolean; set isDatasetInitialized(isInitialized: boolean); set isDatasetHierarchicalInitialized(isInitialized: boolean); get registeredResources(): ExternalResource[]; componentDidMount(): void; initialization(eventHandler: SlickEventHandler): void; componentWillUnmount(shouldEmptyDomElementContainer?: boolean): void; emptyGridContainerElm(): void; dispose(shouldEmptyDomElementContainer?: boolean): void; disposeExternalResources(): void; componentDidUpdate(prevProps: SlickgridReactProps): void; columnsChanged(columns?: Column[]): void; /** * Define our internal Post Process callback, it will execute internally after we get back result from the Process backend call * Currently ONLY available with the GraphQL Backend Service. * The behavior is to refresh the Dataset & Pagination without requiring the user to create his own PostProcess every time */ createBackendApiInternalPostProcessCallback(gridOptions: GridOption): void; bindDifferentHooks(grid: SlickGrid, gridOptions: GridOption, dataView: SlickDataView): void; bindBackendCallbackFunctions(gridOptions: GridOption): void; protected addBackendInfiniteScrollCallback(): void; bindResizeHook(grid: SlickGrid, options: GridOption): void; executeAfterDataviewCreated(_grid: SlickGrid, gridOptions: GridOption): void; /** * On a Pagination changed, we will trigger a Grid State changed with the new pagination info * Also if we use Row Selection or the Checkbox Selector with a Backend Service (Odata, GraphQL), we need to reset any selection */ paginationChanged(pagination: PaginationMetadata): void; paginationOptionsChanged(newPaginationOptions: Pagination): void; /** * When dataset changes, we need to refresh the entire grid UI & possibly resize it as well * @param dataset */ refreshGridData(dataset: any[], totalCount?: number): void; /** * Show the filter row displayed on first row, we can optionally pass false to hide it. * @param showing */ showHeaderRow(showing?: boolean): boolean; /** * Check if there's any Pagination Presets defined in the Grid Options, * if there are then load them in the paginationOptions object */ protected setPaginationOptionsWhenPresetDefined(gridOptions: GridOption, paginationOptions: Pagination): Pagination; setDarkMode(dark?: boolean): void; /** * Dynamically change or update the column definitions list. * We will re-render the grid so that the new header and data shows up correctly. * If using i18n, we also need to trigger a re-translate of the column headers */ updateColumnsList(newColumns: Column<TData>[]): void; /** * assignment changes are not triggering on the column definitions, for that * we can use our internal array observer for any changes done via (push, pop, shift, ...) */ protected observeColumns(): void; /** * Loop through all column definitions and copy the original optional `width` properties optionally provided by the user. * We will use this when doing a resize by cell content, if user provided a `width` it won't override it. */ protected copyColumnWidthsReference(columns: Column<TData>[]): void; protected displayEmptyDataWarning(showWarning?: boolean): void; /** When data changes in the DataView, we'll refresh the metrics and/or display a warning if the dataset is empty */ protected handleOnItemCountChanged(currentPageRowItemCount: number, totalItemCount: number): void; /** Initialize the Pagination Service once */ protected initializePaginationService(paginationOptions: Pagination): void; /** * Render (or dispose) the Pagination Component, user can optionally provide False (to not show it) which will in term dispose of the Pagination, * also while disposing we can choose to omit the disposable of the Pagination Service (if we are simply toggling the Pagination, we want to keep the Service alive) * @param {Boolean} showPagination - show (new render) or not (dispose) the Pagination * @param {Boolean} shouldDisposePaginationService - when disposing the Pagination, do we also want to dispose of the Pagination Service? (defaults to True) */ protected renderPagination(showPagination?: boolean): Promise<void>; /** Load the Editor Collection asynchronously and replace the "collection" property when Promise resolves */ protected loadEditorCollectionAsync(column: Column): void; protected insertDynamicPresetColumns(columnId: string, gridPresetColumns: Column<TData>[]): void; /** Load any possible Columns Grid Presets */ protected loadColumnPresetsWhenDatasetInitialized(): void; /** Load any possible Filters Grid Presets */ protected loadFilterPresetsWhenDatasetInitialized(): void; /** * local grid, check if we need to show the Pagination * if so then also check if there's any presets and finally initialize the PaginationService * a local grid with Pagination presets will potentially have a different total of items, we'll need to get it from the DataView and update our total */ protected loadLocalGridPagination(dataset?: any[]): void; /** Load any Row Selections into the DataView that were presets by the user */ protected loadRowSelectionPresetWhenExists(): void; hasBackendInfiniteScroll(gridOptions?: GridOption): boolean; protected mergeGridOptions(gridOptions: GridOption): GridOption; /** Add a register a new external resource, user could also optional dispose all previous resources before pushing any new resources to the resources array list. */ registerExternalResources(resources: ExternalResource[], disposePreviousResources?: boolean): void; resetExternalResources(): void; /** Pre-Register any Resource that don't require SlickGrid to be instantiated (for example RxJS Resource & RowDetail) */ protected preRegisterResources(): void; protected initializeExternalResources(resources: ExternalResource[]): void; protected registerResources(): void; /** Register the RxJS Resource in all necessary services which uses */ protected registerRxJsResource(resource: RxJsFacade): void; /** * Takes a flat dataset with parent/child relationship, sort it (via its tree structure) and return the sorted flat array * @param {Array<Object>} flatDatasetInput - flat dataset input * @param {Boolean} forceGridRefresh - optionally force a full grid refresh * @returns {Array<Object>} sort flat parent/child dataset */ protected sortTreeDataset<U>(flatDatasetInput: U[], forceGridRefresh?: boolean): U[]; /** Prepare and load all SlickGrid editors, if an async editor is found then we'll also execute it. */ protected loadSlickGridEditors(columns: Column<TData>[]): Column<TData>[]; protected suggestDateParsingWhenHelpful(): void; /** * When the Editor(s) has a "editor.collection" property, we'll load the async collection. * Since this is called after the async call resolves, the pointer will not be the same as the "column" argument passed. */ protected updateEditorCollection<U extends TData = any>(column: Column<U>, newCollection: U[]): void; render(): import("react/jsx-runtime").JSX.Element; } export {};