packageDocumentation module import { BeEvent } from "@itwin/core-bentley" ; import { PageOptions } from "../common/PageOptions" ; import { ITreeDataProvider , TreeDataChangesListener , TreeNodeItem } from "./TreeDataProvider" ; public export type SimpleTreeDataProviderHierarchy = Map < string | undefined , TreeNodeItem [ ] > ; public export class SimpleTreeDataProvider implements ITreeDataProvider { private _hierarchy : SimpleTreeDataProviderHierarchy ; public constructor ( hierarchy ) { this . _hierarchy = hierarchy ; } public onTreeNodeChanged = new BeEvent < TreeDataChangesListener > ( ) ; private getNodesByParentId ( parentId ? , pageOptions ? ) { const nodes = this . _hierarchy . get ( parentId ) ; if ( ! nodes ) return [ ] ; if ( ! pageOptions ) return [ ... nodes ] ; let pageEndIndex ; if ( pageOptions . size !== undefined && pageOptions . size !== 0 ) { pageEndIndex = pageOptions . size ; pageEndIndex += pageOptions . start ? pageOptions . start : 0 ; } return nodes . slice ( pageOptions . start , pageEndIndex ) ; } public async getNodes ( parent ? , pageOptions ? ) { return this . getNodesByParentId ( parent ? parent . id : undefined , pageOptions ) ; } public async getNodesCount ( parent ? ) { return this . getNodesByParentId ( parent ? parent . id : undefined ) . length ; } }