import type { BasePubSubService, EventSubscription } from '@slickgrid-universal/event-pub-sub'; import { SlickEventHandler, type SlickDataView, type SlickEventData, type SlickGrid } from '../core/index.js'; import { type ToggleStateChangeType } from '../enums/index.js'; import type { Column, ColumnSort, GridOption, OnClickEventArgs, OnKeyDownEventArgs, TreeDataOption, TreeToggledItem, TreeToggleStateChange } from '../interfaces/index.js'; import type { FilterService } from './filter.service.js'; import type { SharedService } from './shared.service.js'; import type { SortService } from './sort.service.js'; export declare class TreeDataService { protected readonly pubSubService: BasePubSubService; protected readonly filterService: FilterService; protected readonly sharedService: SharedService; protected readonly sortService: SortService; readonly pluginName = "TreeDataService"; protected _lastToggleStateChange: Omit; protected _currentToggledItems: TreeToggledItem[]; protected _grid: SlickGrid; protected _eventHandler: SlickEventHandler; protected _isLastFullToggleCollapsed: boolean; protected _isOneCpuCyclePassed: boolean; protected _isTreeDataEnabled: boolean; protected _subscriptions: EventSubscription[]; protected _timer1?: any; protected _timer2?: any; protected _treeDataRecalcHandler: (() => void) | null; constructor(pubSubService: BasePubSubService, filterService: FilterService, sharedService: SharedService, sortService: SortService); set currentToggledItems(newToggledItems: TreeToggledItem[]); get dataset(): any[]; get datasetHierarchical(): any[] | undefined; /** Getter of SlickGrid DataView object */ get dataView(): SlickDataView; /** Getter of the SlickGrid Event Handler */ get eventHandler(): SlickEventHandler; get gridOptions(): GridOption; get datasetIdPropName(): string; get treeDataOptions(): TreeDataOption | undefined; dispose(): void; init(grid: SlickGrid): void; /** init the hierarchical tree when necessary (e.g. `initiallyCollapsed` requires to collapse all items) */ initHierarchicalTree(): void; /** * Apply different tree toggle state changes (to ALL rows, the entire dataset) by providing an array of parentIds that are designated as collapsed (or not). * User will have to provide an array of `parentId` and `isCollapsed` boolean and the code will only apply the ones that are tagged as collapsed, everything else will be expanded * @param {Array} treeToggledItems - array of parentId which are tagged as changed * @param {ToggleStateChangeType} previousFullToggleType - optionally provide the previous full toggle type ('full-expand' or 'full-collapse') * @param {Boolean} shouldPreProcessFullToggle - should we pre-process a full toggle on all items? defaults to True * @param {Boolean} shouldTriggerEvent - should we trigger a toggled item event? defaults to False */ applyToggledItemStateChanges(treeToggledItems: TreeToggledItem[], previousFullToggleType?: Extract, shouldPreProcessFullToggle?: boolean, shouldTriggerEvent?: boolean): void; /** * Dynamically toggle and change state of certain parent items by providing an array of parentIds that are designated as to be collapsed (or not). * User will have to provide an array of `parentId` and `isCollapsed` boolean, only the provided list of items will be toggled and nothing else. * * NOTE: the `applyToggledItemStateChanges()` method is very similar but on top of toggling the `treeToggledItems` it WILL ALSO collapse everything else. * @param {Array} treeToggledItems - array of parentId which are tagged as changed * @param {Boolean} shouldTriggerEvent - should we trigger a toggled item event? defaults to True */ dynamicallyToggleItemState(treeToggledItems: TreeToggledItem[], shouldTriggerEvent?: boolean): void; /** * Get the current toggle state that includes the type (toggle, full-expand, full-collapse) and toggled items (only applies when it's a parent toggle) * @returns {TreeToggleStateChange} treeDataToggledItems - items that were toggled (array of `parentId` and `isCollapsed` flag) */ getCurrentToggleState(): Omit; getInitialSort(columns: Column[], gridOptions: GridOption): ColumnSort; /** * Get the full item count of the Tree. * When an optional tree level is provided, it will return the count for only that dedicated level (for example providing 0 would return the item count of all parent items) * @param {Number} [treeLevel] - optional tree level to get item count from * @returns */ getItemCount(treeLevel?: number): number; /** * Get the current list of Tree Data item(s) that got toggled in the grid (basically the parents that the user clicked on the toggle icon to expand/collapse the child) * @returns {Array} treeDataToggledItems - items that were toggled (array of `parentId` and `isCollapsed` flag) */ getToggledItems(): TreeToggledItem[]; /** Clear the sorting and set it back to initial sort */ clearSorting(): void; /** * Takes a flat dataset, converts it into a hierarchical dataset, sort it by recursion and finally return back the final and sorted flat array. * Note: for perf reasons, it mutates the array by adding extra props like `treeLevel` * @param {Array} flatDataset - parent/child flat dataset * @param {Column[]} columns - column definitions * @param {Object} gridOptions - grid options * @param {Array} [columnSorts] - optional sort columns * @returns {Array} - tree dataset */ convertFlatParentChildToTreeDatasetAndSort

(flatDataset: P[], columns: Column[], gridOptions: GridOption, columnSorts?: ColumnSort[]): { hierarchical: Array

; flat: P[]; }; /** * Takes a flat dataset, converts it into a hierarchical dataset * Note: for perf reasons, it mutates the array by adding extra props like `treeLevel` * @param {Array} flatDataset - parent/child flat dataset * @param {Object} gridOptions - grid options * @returns {Array} - tree dataset */ convertFlatParentChildToTreeDataset(flatDataset: P[], gridOptions: GridOption): T[]; /** * Dynamically enable (or disable) Tree Totals auto-recalc feature when Aggregators exists * @param {Boolean} [enableFeature=true] */ enableAutoRecalcTotalsFeature(enableFeature?: boolean): void; /** * Recalculate all Tree Data totals, this requires Aggregators to be defined. * NOTE: this does **not** take the current filters in consideration * @param gridOptions */ recalculateTreeTotals(gridOptions: GridOption): void; /** * Takes a hierarchical (tree) input array and sort it (if an `initialSort` exist, it will use that to sort) * Note: for perf reasons, it mutates the array by adding extra props like `treeLevel` * @param {Array} hierarchicalDataset - input hierarchical tree dataset * @param {ColumnSort | ColumnSort[]} [inputColumnSorts] - column sort(s) * @returns {Object} sort result object that includes both the flat & tree data arrays */ sortHierarchicalDataset(hierarchicalDataset: T[], inputColumnSorts?: ColumnSort | ColumnSort[]): { hierarchical: T[]; flat: any[]; }; /** * Toggle the collapsed values of all parent items (the ones with children), we can optionally provide a flag to force a collapse or expand * @param {Boolean} collapsing - optionally force a collapse/expand (True => collapse all, False => expand all) * @param {Boolean} shouldTriggerEvent - defaults to true, should we trigger an event? For example, we could disable this to avoid a Grid State change event. * @returns {Promise} - returns a void Promise, the reason we use a Promise is simply to make sure that when we add a spinner, it doesn't start/stop only at the end of the process */ toggleTreeDataCollapse(collapsing: boolean, shouldTriggerEvent?: boolean): Promise; protected checkIsLazyParentLoaded(item: any, collapsing: boolean, lazyLoadingPropName: string): boolean; protected handleOnCellClick(event: Event | SlickEventData, args: OnClickEventArgs): void; handleOnKeyDown(e: SlickEventData, args: OnKeyDownEventArgs): void; /** * Toggle an item in the flat dataset and update it in the grid. * NOTE: We should update the Tree Data collapse status (shouldUpdateTree=true) ONLY when toggling 1 item at a time, * however for toggle a batch (i.e. collapse all), we'll want to convert skip updating the tree but rather convert from flat to tree which is much quicker to execute. */ protected updateToggledItem(item: any, isCollapsed: boolean, shouldUpdateTree: boolean): void; /** * When using Tree Data with Aggregator and auto-recalc flag is enabled, we will define a callback handler * @return {Function | undefined} Tree Data totals recalculate callback when enabled */ protected setAutoRecalcTotalsCallbackWhenFeatEnabled(gridOptions: GridOption): (() => void) | null; /** * Toggle all items of a hierarchical (tree) dataset, user must provide the children, collapsed & lazyCollapsing property names * NOTE: this does NOT change or update the flat dataset, it only changes the collapsed flag in the hierarchical tree only without updating the grid. */ protected toggleAllHierarchicalTree(hierarchicalData: any[], collapsing: boolean, childrenPropName: string, collapsedPropName: string, lazyLoadingPropName: string): void; /** * Toggle all items of a flat dataset, user must provide the hasChildrenPropName & lazyLoadingPropName property names * NOTE: this does NOT change or update the hierarchical dataset, it only changes the collapsed flag in the flat dataset only without updating the grid. */ protected toggleAllFlatDataItems(collapsing: boolean, hasChildrenPropName: string, lazyLoadingPropName: string): void; } //# sourceMappingURL=treeData.service.d.ts.map