packageDocumentation module import { PropertyRecord } from "@itwin/appui-abstract" ; import { PropertyCategory } from "../../PropertyDataProvider" ; import { FlatGridItemType , IMutableFlatGridItem , IMutableGridCategoryItem , MutableFlatPropertyGridItem } from "./MutableFlatGridItem" ; import { IMutableGridItemFactory } from "./MutableGridItemFactory" ; beta export interface CategoryRecordsDict { [ categoryName ] : PropertyRecord [ ] ; } beta export class MutableGridCategory extends MutableFlatPropertyGridItem implements IMutableGridCategoryItem { private _children : IMutableFlatGridItem [ ] ; private _childCategories : IMutableGridCategoryItem [ ] ; private _selectionKey : string ; private _category : PropertyCategory ; constructor ( category , recordsDict , gridItemFactory , parentSelectionKey ? , depth = 0 ) { super ( depth , parentSelectionKey , parentSelectionKey ) ; this . _category = { name : category . name , label : category . label , expand : category . expand } ; if ( parentSelectionKey !== undefined ) this . _selectionKey = `${ parentSelectionKey }_${ category . name }` ; else this . _selectionKey = category . name ; this . _isExpanded = category . expand ; const categoryRecords = recordsDict [ category . name ] ?? [ ] ; this . _children = categoryRecords . map ( ( value ) => gridItemFactory . createCategorizedProperty ( value , this . selectionKey , this . selectionKey , 0 ) ) ; const childCategories = category . childCategories ?? [ ] ; this . _childCategories = childCategories . map ( ( childCategory ) => gridItemFactory . createGridCategory ( childCategory , recordsDict , this . selectionKey , this . depth + 1 ) ) ; this . _children . push ( ... this . _childCategories ) ; this . lastInNumberOfCategories = 0 ; this . isLastInRootCategory = this . isRootCategory ; } /**
     * Category is considered to be root category if its depth is 0
     */ public get isRootCategory ( ) { return this . depth === 0 ; } public get selectionKey ( ) { return this . _selectionKey ; } public get type ( ) : FlatGridItemType . Category { return FlatGridItemType . Category ; } public get name ( ) { return this . _category . name ; } public get label ( ) { return this . _category . label ; } public get derivedCategory ( ) : PropertyCategory { return { ... this . _category , expand : this . isExpanded } ; } public getSelf ( ) { return this ; } public getChildren ( ) { return this . _children ; } public getChildCategories ( ) { return this . _childCategories ; } /**
     * Gets a flat list of all categories beneath this category and itself in depth first visiting order.
     */ public getDescendantCategoriesAndSelf ( ) { const descendants = [ ] ; this . _childCategories . forEach ( ( value ) => descendants . push ( ... value . getDescendantCategoriesAndSelf ( ) ) ) ; return [ this , ... descendants ] ; } internal public override get lastInNumberOfCategories ( ) : number { if ( this . isExpanded && this . getChildren ( ) . length > 0 ) return 0 ; return this . _lastInNumberOfCategories - 1 ; } public override set lastInNumberOfCategories ( value ) { super . lastInNumberOfCategories = value + 1 ; } }