-
Notifications
You must be signed in to change notification settings - Fork 2
/
PropertyGridEventHandler.ts
36 lines (32 loc) · 1.14 KB
/
PropertyGridEventHandler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module PropertyGrid
*/
import type { IPropertyGridModelSource } from "./PropertyGridModelSource";
/**
* Handles events and changes on PropertyGridModel data.
* @public
*/
export interface IPropertyGridEventHandler {
onExpansionToggled: (selectionKey: string) => void;
}
/**
* Handles events and changes on PropertyGridModel data.
* @public
*/
export class PropertyGridEventHandler {
public constructor(private _modelSource: IPropertyGridModelSource) {}
/**
* Flips isExpand on item by given selectionKey
* @param selectionKey item to be modified
*/
public onExpansionToggled = (selectionKey: string) => {
this._modelSource.modifyModel((draftModel) => {
const item = draftModel.getItem(selectionKey);
item.isExpanded = !item.isExpanded;
});
};
}