@itwin/components-react 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts +1 -0
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -2
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/components-react/tree/controlled/TreeEventHandler.d.ts +1 -0
- package/lib/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
- package/lib/components-react/tree/controlled/TreeEventHandler.js +11 -2
- package/lib/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Change Log - @itwin/components-react
|
|
2
2
|
|
|
3
|
+
## 5.6.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a4b74f9: Fix potential infinite recursion in dispose methods of `TreeEventHandler` and `FilteringPropertyDataProvider` classes.
|
|
8
|
+
- @itwin/core-react@5.6.0
|
|
9
|
+
|
|
3
10
|
## 5.5.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -29,6 +29,7 @@ export interface FilteredPropertyData extends PropertyData {
|
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
31
|
export declare class FilteringPropertyDataProvider implements IPropertyDataProvider, Disposable {
|
|
32
|
+
#private;
|
|
32
33
|
private _dataProvider;
|
|
33
34
|
private _filterer;
|
|
34
35
|
onDataChanged: PropertyDataChangeEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/dataproviders/FilteringDataProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,iCAAiC,CAAC;AAIzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,KAAK,EACV,qBAAqB,EAErB,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EAEtB,MAAM,yCAAyC,CAAC;AAWjD;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IAE/D,qDAAqD;IACrD,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,6BACX,YAAW,qBAAqB,EAAE,UAAU
|
|
1
|
+
{"version":3,"file":"FilteringDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/dataproviders/FilteringDataProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,iCAAiC,CAAC;AAIzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,KAAK,EACV,qBAAqB,EAErB,YAAY,EACb,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EAEtB,MAAM,yCAAyC,CAAC;AAWjD;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IAE/D,qDAAqD;IACrD,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,6BACX,YAAW,qBAAqB,EAAE,UAAU;;IAS1C,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IARZ,aAAa,0BAAiC;IACrD,OAAO,CAAC,qBAAqB,CACjB;IACZ,OAAO,CAAC,6BAA6B,CAA0B;IAC/D,OAAO,CAAC,2BAA2B,CAA0B;gBAGnD,aAAa,EAAE,qBAAqB,EACpC,SAAS,EAAE,qBAAqB;IAmB1C,+CAA+C;IACxC,CAAC,MAAM,CAAC,OAAO,CAAC;IAIvB,4DAA4D;IACrD,OAAO,IAAI,IAAI;IAIT,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;YAgBvC,kBAAkB;CA0CjC"}
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module PropertyGrid
|
|
7
7
|
*/
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _FilteringPropertyDataProvider_instances, _FilteringPropertyDataProvider_dispose;
|
|
8
14
|
import "../../common/DisposePolyfill.js";
|
|
9
15
|
import { PropertyValueFormat } from "@itwin/appui-abstract";
|
|
10
16
|
import { PropertyDataChangeEvent } from "../PropertyDataProvider.js";
|
|
@@ -14,6 +20,7 @@ import { PropertyDataChangeEvent } from "../PropertyDataProvider.js";
|
|
|
14
20
|
*/
|
|
15
21
|
export class FilteringPropertyDataProvider {
|
|
16
22
|
constructor(_dataProvider, _filterer) {
|
|
23
|
+
_FilteringPropertyDataProvider_instances.add(this);
|
|
17
24
|
this._dataProvider = _dataProvider;
|
|
18
25
|
this._filterer = _filterer;
|
|
19
26
|
this.onDataChanged = new PropertyDataChangeEvent();
|
|
@@ -30,13 +37,15 @@ export class FilteringPropertyDataProvider {
|
|
|
30
37
|
});
|
|
31
38
|
}
|
|
32
39
|
/** Destructor. Must be called to clean up. */
|
|
33
|
-
[
|
|
40
|
+
[(_FilteringPropertyDataProvider_instances = new WeakSet(), _FilteringPropertyDataProvider_dispose = function _FilteringPropertyDataProvider_dispose() {
|
|
34
41
|
this._disposeDataChangedListener();
|
|
35
42
|
this._disposeFilterChangedListener();
|
|
43
|
+
}, Symbol.dispose)]() {
|
|
44
|
+
__classPrivateFieldGet(this, _FilteringPropertyDataProvider_instances, "m", _FilteringPropertyDataProvider_dispose).call(this);
|
|
36
45
|
}
|
|
37
46
|
/** @deprecated in 5.5.0. Use `[Symbol.dispose]` instead. */
|
|
38
47
|
dispose() {
|
|
39
|
-
this
|
|
48
|
+
__classPrivateFieldGet(this, _FilteringPropertyDataProvider_instances, "m", _FilteringPropertyDataProvider_dispose).call(this);
|
|
40
49
|
}
|
|
41
50
|
async getData() {
|
|
42
51
|
if (this._filteredPropertyData) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringDataProvider.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/dataproviders/FilteringDataProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,iCAAiC,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAQ5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAqCrE;;;GAGG;AACH,MAAM,OAAO,6BAA6B;IASxC,YACU,aAAoC,EACpC,SAAgC;QADhC,kBAAa,GAAb,aAAa,CAAuB;QACpC,cAAS,GAAT,SAAS,CAAuB;QARnC,kBAAa,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAC7C,0BAAq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C1B,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,sBAAsB,CAC7B,KAAoB,EACpB,WAA6B;IAE7B,QAAQ,KAAK,CAAC,WAAW,EAAE,CAAC;QAC1B,KAAK,mBAAmB,CAAC,SAAS;YAChC,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;QACtB,KAAK,mBAAmB,CAAC,KAAK;YAC5B,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,KAAK;gBACtC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,KAAK,EAAE,WAAW;aACnB,CAAC;QACJ,KAAK,mBAAmB,CAAC,MAAM;YAC7B,MAAM,OAAO,GAAuC,EAAE,CAAC;YACvD,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YACvE,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,MAAM;gBACvC,OAAO;aACR,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport \"../../common/DisposePolyfill.js\";\n\nimport type { PropertyRecord, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { HighlightInfo } from \"../../common/HighlightingComponentProps.js\";\nimport type { CategoryRecordsDict } from \"../internal/flat-items/MutableGridCategory.js\";\nimport type {\n IPropertyDataProvider,\n PropertyCategory,\n PropertyData,\n} from \"../PropertyDataProvider.js\";\nimport { PropertyDataChangeEvent } from \"../PropertyDataProvider.js\";\nimport type {\n FilteredType,\n IPropertyDataFilterer,\n PropertyDataFilterResult,\n} from \"./filterers/PropertyDataFiltererBase.js\";\n\ninterface FilteredRecords {\n filteredRecords: PropertyRecord[];\n shouldExpandNodeParents: boolean;\n matchesCount: number;\n activeMatch?: HighlightInfo;\n filteredResultMatches: { id: string; matchesCount: number }[];\n filteredTypes: FilteredType[];\n}\n\n/**\n * Data returned by [[FilteringPropertyDataProvider]]\n * @public\n */\nexport interface FilteredPropertyData extends PropertyData {\n /**\n * Shows how many matches were found when filtering data.\n * `undefined` when filterer is not active\n */\n matchesCount?: number;\n\n /**\n * Function used for getting [[HighlightInfo]] by index from all the filtered matches.\n * `undefined` when filterer is not active\n */\n getMatchByIndex?: (index: number) => HighlightInfo | undefined;\n\n /** Types of objects that were used for filtering. */\n filteredTypes?: FilteredType[];\n}\n\n/**\n * [[IPropertyDataProvider]] implementation which filters wrapped provider [[PropertyData]] using passed [[IPropertyDataFilterer]].\n * @public\n */\nexport class FilteringPropertyDataProvider\n implements IPropertyDataProvider, Disposable\n{\n public onDataChanged = new PropertyDataChangeEvent();\n private _filteredPropertyData: Promise<FilteredPropertyData> | undefined =\n undefined;\n private _disposeFilterChangedListener: (...args: any[]) => any;\n private _disposeDataChangedListener: (...args: any[]) => any;\n\n public constructor(\n private _dataProvider: IPropertyDataProvider,\n private _filterer: IPropertyDataFilterer\n ) {\n this._disposeFilterChangedListener =\n this._filterer.onFilterChanged.addListener(() => {\n this._filteredPropertyData = undefined;\n this.onDataChanged.raiseEvent();\n });\n this._disposeDataChangedListener =\n this._dataProvider.onDataChanged.addListener(() => {\n this._filteredPropertyData = undefined;\n this.onDataChanged.raiseEvent();\n });\n }\n\n /** Destructor. Must be called to clean up. */\n public [Symbol.dispose]() {\n this._disposeDataChangedListener();\n this._disposeFilterChangedListener();\n }\n\n /** @deprecated in 5.5.0. Use `[Symbol.dispose]` instead. */\n public dispose(): void {\n this[Symbol.dispose]();\n }\n\n public async getData(): Promise<FilteredPropertyData> {\n if (this._filteredPropertyData) {\n return this._filteredPropertyData;\n }\n\n this._filteredPropertyData = this._dataProvider\n .getData()\n .then(async (propertyData) => {\n return this._filterer.isActive\n ? this.filterPropertyData(propertyData)\n : propertyData;\n });\n\n return this._filteredPropertyData;\n }\n\n private async filterPropertyData(propertyData: PropertyData) {\n const { categories, records, label, description } = { ...propertyData };\n const {\n filteredCategories,\n filteredRecords,\n matchesCount,\n filteredResultMatches,\n filteredTypes,\n } = await matchHierarchy(this._filterer, categories, records, undefined);\n\n const uniqueTypes = [...new Set(filteredTypes)];\n const getMatchByIndex = (index: number) => {\n let activeMatch: HighlightInfo | undefined;\n if (index <= 0) return undefined;\n\n let i = 1;\n for (const record of filteredResultMatches) {\n const fullMatchesCount = record.matchesCount;\n if (index < i + fullMatchesCount) {\n activeMatch = {\n highlightedItemIdentifier: record.id,\n highlightIndex: index - i,\n };\n break;\n }\n\n i += fullMatchesCount;\n }\n return activeMatch;\n };\n\n return {\n label,\n description,\n categories: filteredCategories,\n records: filteredRecords,\n reusePropertyDataState: false,\n matchesCount,\n getMatchByIndex,\n filteredTypes: uniqueTypes,\n };\n }\n}\n\nasync function matchHierarchy(\n filterer: IPropertyDataFilterer,\n categories: PropertyCategory[],\n records: CategoryRecordsDict,\n newRecords?: CategoryRecordsDict,\n parentMatchInfo?: PropertyDataFilterResult\n) {\n const newCategories: PropertyCategory[] = [];\n newRecords = newRecords ?? {};\n let matchesCount = 0;\n let allFilteredResultMatches: { id: string; matchesCount: number }[] = [];\n let allFilteredTypes: FilteredType[] = [];\n\n for (const category of categories) {\n const matchInfo = await filterer.categoryMatchesFilter(category, []);\n\n if (matchInfo.matchesFilter) {\n allFilteredResultMatches.push({\n id: category.name,\n matchesCount: matchInfo.matchesCount ?? 0,\n });\n allFilteredTypes = allFilteredTypes.concat(matchInfo.filteredTypes ?? []);\n matchesCount += matchInfo.matchesCount ?? 0;\n }\n\n const childRecords = records[category.name] ?? [];\n const {\n filteredRecords,\n matchesCount: count,\n filteredResultMatches,\n filteredTypes,\n } = await matchRecordHierarchy(filterer, childRecords, []);\n allFilteredResultMatches = allFilteredResultMatches.concat(\n filteredResultMatches\n );\n allFilteredTypes = allFilteredTypes.concat(filteredTypes);\n matchesCount += count;\n\n const parentInfo = parentMatchInfo?.matchesFilter\n ? parentMatchInfo\n : matchInfo;\n\n const childCategories = category.childCategories ?? [];\n const {\n filteredCategories,\n matchesCount: childCount,\n filteredResultMatches: childFilteredResultMatches,\n filteredTypes: childFilteredTypes,\n } = await matchHierarchy(\n filterer,\n childCategories,\n records,\n newRecords,\n parentInfo\n );\n allFilteredResultMatches = allFilteredResultMatches.concat(\n childFilteredResultMatches\n );\n allFilteredTypes = allFilteredTypes.concat(childFilteredTypes);\n matchesCount += childCount;\n\n let expand = !(count === 0 && childCount === 0);\n if (\n matchInfo.matchesFilter ||\n (parentMatchInfo?.matchesFilter &&\n parentMatchInfo.shouldForceIncludeDescendants)\n ) {\n newRecords[category.name] = records[category.name];\n if (matchInfo.matchesFilter) {\n expand = true;\n }\n const newCategory = copyPropertyCategory(\n category,\n filteredCategories,\n expand\n );\n newCategories.push(newCategory);\n }\n\n if (\n (filteredRecords.length !== 0 || filteredCategories.length !== 0) &&\n !matchInfo.matchesFilter &&\n !(\n parentMatchInfo?.shouldExpandNodeParents &&\n parentMatchInfo.matchesFilter\n )\n ) {\n const newCategory = copyPropertyCategory(\n category,\n filteredCategories,\n expand\n );\n newRecords[newCategory.name] = filteredRecords;\n newCategories.push(newCategory);\n }\n }\n\n return {\n filteredCategories: newCategories,\n filteredRecords: newRecords,\n matchesCount,\n filteredResultMatches: allFilteredResultMatches,\n filteredTypes: allFilteredTypes,\n };\n}\n\nasync function matchRecordHierarchy(\n filterer: IPropertyDataFilterer,\n records: PropertyRecord[],\n parents: PropertyRecord[],\n forceIncludeItem: boolean = false\n): Promise<FilteredRecords> {\n const newMatchedRecords: PropertyRecord[] = [];\n let expandParent = false; // property passed back to parent to indicate whether it should be expanded\n let matchesCount = 0;\n let filteredResultMatches: { id: string; matchesCount: number }[] = [];\n let filteredTypes: FilteredType[] = [];\n\n for (const record of records) {\n const matchInfo = await filterer.recordMatchesFilter(record, parents);\n const shouldForceIncludeDescendants =\n forceIncludeItem || matchInfo.shouldForceIncludeDescendants;\n const {\n filteredRecords: filteredChildren,\n shouldExpandNodeParents,\n matchesCount: childrenMatchesCount,\n filteredResultMatches: childrenResultMatches,\n filteredTypes: childrenFilteredTypes,\n } = await matchRecordHierarchy(\n filterer,\n record.getChildrenRecords(),\n [...parents, record],\n shouldForceIncludeDescendants\n );\n filteredResultMatches = filteredResultMatches.concat(childrenResultMatches);\n filteredTypes = [...filteredTypes, ...childrenFilteredTypes];\n matchesCount += childrenMatchesCount;\n // if child hierarchy indicates parents should be expanded, then it should be passed back up to the top parent\n expandParent = expandParent || shouldExpandNodeParents;\n\n let newRecord: PropertyRecord | undefined;\n if (matchInfo.matchesFilter) {\n filteredTypes = [...filteredTypes, ...(matchInfo.filteredTypes ?? [])];\n const recordMatchesCount = matchInfo.matchesCount ?? 0;\n matchesCount += recordMatchesCount;\n // Item is included if it matches filter\n // If at least one matched record from records list needs its parent expanded,\n // then `expandParent` should be set to true\n expandParent = expandParent || !!matchInfo.shouldExpandNodeParents;\n newRecord = copyPropertyRecord(\n record,\n filteredChildren,\n shouldExpandNodeParents\n );\n filteredResultMatches.push({\n id: newRecord.property.name,\n matchesCount: recordMatchesCount,\n });\n } else if (filteredChildren.length !== 0 || forceIncludeItem) {\n // Item is also included if it has at least one matched child or is forcefully included by its parent\n newRecord = copyPropertyRecord(\n record,\n filteredChildren,\n shouldExpandNodeParents\n );\n }\n\n if (newRecord) newMatchedRecords.push(newRecord);\n }\n\n return {\n filteredRecords: newMatchedRecords,\n shouldExpandNodeParents: expandParent,\n matchesCount,\n filteredResultMatches,\n filteredTypes,\n };\n}\n\nfunction copyPropertyCategory(\n propertyCategory: PropertyCategory,\n newChildren: PropertyCategory[],\n expand: boolean\n): PropertyCategory {\n return {\n ...propertyCategory,\n childCategories: newChildren,\n expand,\n };\n}\n\nfunction copyPropertyRecord(\n record: PropertyRecord,\n newChildren: PropertyRecord[],\n autoExpand: boolean\n) {\n const r = record.copyWithNewValue(\n createNewPropertyValue(record.value, newChildren)\n );\n r.autoExpand = autoExpand;\n return r;\n}\n\nfunction createNewPropertyValue(\n value: PropertyValue,\n newChildren: PropertyRecord[]\n): PropertyValue {\n switch (value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return { ...value };\n case PropertyValueFormat.Array:\n return {\n valueFormat: PropertyValueFormat.Array,\n itemsTypeName: value.itemsTypeName,\n items: newChildren,\n };\n case PropertyValueFormat.Struct:\n const members: { [name: string]: PropertyRecord } = {};\n newChildren.forEach((child) => (members[child.property.name] = child));\n return {\n valueFormat: PropertyValueFormat.Struct,\n members,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FilteringDataProvider.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/dataproviders/FilteringDataProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;AAEH,OAAO,iCAAiC,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAQ5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAqCrE;;;GAGG;AACH,MAAM,OAAO,6BAA6B;IASxC,YACU,aAAoC,EACpC,SAAgC;;QADhC,kBAAa,GAAb,aAAa,CAAuB;QACpC,cAAS,GAAT,SAAS,CAAuB;QARnC,kBAAa,GAAG,IAAI,uBAAuB,EAAE,CAAC;QAC7C,0BAAqB,GAC3B,SAAS,CAAC;QAQV,IAAI,CAAC,6BAA6B;YAChC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,WAAW,CAAC,GAAG,EAAE;gBAC9C,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;gBACvC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;YAClC,CAAC,CAAC,CAAC;QACL,IAAI,CAAC,2BAA2B;YAC9B,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,WAAW,CAAC,GA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EAAE,mBAAmB,CAAC,KAAK;gBACtC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,KAAK,EAAE,WAAW;aACnB,CAAC;QACJ,KAAK,mBAAmB,CAAC,MAAM;YAC7B,MAAM,OAAO,GAAuC,EAAE,CAAC;YACvD,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YACvE,OAAO;gBACL,WAAW,EAAE,mBAAmB,CAAC,MAAM;gBACvC,OAAO;aACR,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport \"../../common/DisposePolyfill.js\";\n\nimport type { PropertyRecord, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { HighlightInfo } from \"../../common/HighlightingComponentProps.js\";\nimport type { CategoryRecordsDict } from \"../internal/flat-items/MutableGridCategory.js\";\nimport type {\n IPropertyDataProvider,\n PropertyCategory,\n PropertyData,\n} from \"../PropertyDataProvider.js\";\nimport { PropertyDataChangeEvent } from \"../PropertyDataProvider.js\";\nimport type {\n FilteredType,\n IPropertyDataFilterer,\n PropertyDataFilterResult,\n} from \"./filterers/PropertyDataFiltererBase.js\";\n\ninterface FilteredRecords {\n filteredRecords: PropertyRecord[];\n shouldExpandNodeParents: boolean;\n matchesCount: number;\n activeMatch?: HighlightInfo;\n filteredResultMatches: { id: string; matchesCount: number }[];\n filteredTypes: FilteredType[];\n}\n\n/**\n * Data returned by [[FilteringPropertyDataProvider]]\n * @public\n */\nexport interface FilteredPropertyData extends PropertyData {\n /**\n * Shows how many matches were found when filtering data.\n * `undefined` when filterer is not active\n */\n matchesCount?: number;\n\n /**\n * Function used for getting [[HighlightInfo]] by index from all the filtered matches.\n * `undefined` when filterer is not active\n */\n getMatchByIndex?: (index: number) => HighlightInfo | undefined;\n\n /** Types of objects that were used for filtering. */\n filteredTypes?: FilteredType[];\n}\n\n/**\n * [[IPropertyDataProvider]] implementation which filters wrapped provider [[PropertyData]] using passed [[IPropertyDataFilterer]].\n * @public\n */\nexport class FilteringPropertyDataProvider\n implements IPropertyDataProvider, Disposable\n{\n public onDataChanged = new PropertyDataChangeEvent();\n private _filteredPropertyData: Promise<FilteredPropertyData> | undefined =\n undefined;\n private _disposeFilterChangedListener: (...args: any[]) => any;\n private _disposeDataChangedListener: (...args: any[]) => any;\n\n public constructor(\n private _dataProvider: IPropertyDataProvider,\n private _filterer: IPropertyDataFilterer\n ) {\n this._disposeFilterChangedListener =\n this._filterer.onFilterChanged.addListener(() => {\n this._filteredPropertyData = undefined;\n this.onDataChanged.raiseEvent();\n });\n this._disposeDataChangedListener =\n this._dataProvider.onDataChanged.addListener(() => {\n this._filteredPropertyData = undefined;\n this.onDataChanged.raiseEvent();\n });\n }\n\n #dispose() {\n this._disposeDataChangedListener();\n this._disposeFilterChangedListener();\n }\n\n /** Destructor. Must be called to clean up. */\n public [Symbol.dispose]() {\n this.#dispose();\n }\n\n /** @deprecated in 5.5.0. Use `[Symbol.dispose]` instead. */\n public dispose(): void {\n this.#dispose();\n }\n\n public async getData(): Promise<FilteredPropertyData> {\n if (this._filteredPropertyData) {\n return this._filteredPropertyData;\n }\n\n this._filteredPropertyData = this._dataProvider\n .getData()\n .then(async (propertyData) => {\n return this._filterer.isActive\n ? this.filterPropertyData(propertyData)\n : propertyData;\n });\n\n return this._filteredPropertyData;\n }\n\n private async filterPropertyData(propertyData: PropertyData) {\n const { categories, records, label, description } = { ...propertyData };\n const {\n filteredCategories,\n filteredRecords,\n matchesCount,\n filteredResultMatches,\n filteredTypes,\n } = await matchHierarchy(this._filterer, categories, records, undefined);\n\n const uniqueTypes = [...new Set(filteredTypes)];\n const getMatchByIndex = (index: number) => {\n let activeMatch: HighlightInfo | undefined;\n if (index <= 0) return undefined;\n\n let i = 1;\n for (const record of filteredResultMatches) {\n const fullMatchesCount = record.matchesCount;\n if (index < i + fullMatchesCount) {\n activeMatch = {\n highlightedItemIdentifier: record.id,\n highlightIndex: index - i,\n };\n break;\n }\n\n i += fullMatchesCount;\n }\n return activeMatch;\n };\n\n return {\n label,\n description,\n categories: filteredCategories,\n records: filteredRecords,\n reusePropertyDataState: false,\n matchesCount,\n getMatchByIndex,\n filteredTypes: uniqueTypes,\n };\n }\n}\n\nasync function matchHierarchy(\n filterer: IPropertyDataFilterer,\n categories: PropertyCategory[],\n records: CategoryRecordsDict,\n newRecords?: CategoryRecordsDict,\n parentMatchInfo?: PropertyDataFilterResult\n) {\n const newCategories: PropertyCategory[] = [];\n newRecords = newRecords ?? {};\n let matchesCount = 0;\n let allFilteredResultMatches: { id: string; matchesCount: number }[] = [];\n let allFilteredTypes: FilteredType[] = [];\n\n for (const category of categories) {\n const matchInfo = await filterer.categoryMatchesFilter(category, []);\n\n if (matchInfo.matchesFilter) {\n allFilteredResultMatches.push({\n id: category.name,\n matchesCount: matchInfo.matchesCount ?? 0,\n });\n allFilteredTypes = allFilteredTypes.concat(matchInfo.filteredTypes ?? []);\n matchesCount += matchInfo.matchesCount ?? 0;\n }\n\n const childRecords = records[category.name] ?? [];\n const {\n filteredRecords,\n matchesCount: count,\n filteredResultMatches,\n filteredTypes,\n } = await matchRecordHierarchy(filterer, childRecords, []);\n allFilteredResultMatches = allFilteredResultMatches.concat(\n filteredResultMatches\n );\n allFilteredTypes = allFilteredTypes.concat(filteredTypes);\n matchesCount += count;\n\n const parentInfo = parentMatchInfo?.matchesFilter\n ? parentMatchInfo\n : matchInfo;\n\n const childCategories = category.childCategories ?? [];\n const {\n filteredCategories,\n matchesCount: childCount,\n filteredResultMatches: childFilteredResultMatches,\n filteredTypes: childFilteredTypes,\n } = await matchHierarchy(\n filterer,\n childCategories,\n records,\n newRecords,\n parentInfo\n );\n allFilteredResultMatches = allFilteredResultMatches.concat(\n childFilteredResultMatches\n );\n allFilteredTypes = allFilteredTypes.concat(childFilteredTypes);\n matchesCount += childCount;\n\n let expand = !(count === 0 && childCount === 0);\n if (\n matchInfo.matchesFilter ||\n (parentMatchInfo?.matchesFilter &&\n parentMatchInfo.shouldForceIncludeDescendants)\n ) {\n newRecords[category.name] = records[category.name];\n if (matchInfo.matchesFilter) {\n expand = true;\n }\n const newCategory = copyPropertyCategory(\n category,\n filteredCategories,\n expand\n );\n newCategories.push(newCategory);\n }\n\n if (\n (filteredRecords.length !== 0 || filteredCategories.length !== 0) &&\n !matchInfo.matchesFilter &&\n !(\n parentMatchInfo?.shouldExpandNodeParents &&\n parentMatchInfo.matchesFilter\n )\n ) {\n const newCategory = copyPropertyCategory(\n category,\n filteredCategories,\n expand\n );\n newRecords[newCategory.name] = filteredRecords;\n newCategories.push(newCategory);\n }\n }\n\n return {\n filteredCategories: newCategories,\n filteredRecords: newRecords,\n matchesCount,\n filteredResultMatches: allFilteredResultMatches,\n filteredTypes: allFilteredTypes,\n };\n}\n\nasync function matchRecordHierarchy(\n filterer: IPropertyDataFilterer,\n records: PropertyRecord[],\n parents: PropertyRecord[],\n forceIncludeItem: boolean = false\n): Promise<FilteredRecords> {\n const newMatchedRecords: PropertyRecord[] = [];\n let expandParent = false; // property passed back to parent to indicate whether it should be expanded\n let matchesCount = 0;\n let filteredResultMatches: { id: string; matchesCount: number }[] = [];\n let filteredTypes: FilteredType[] = [];\n\n for (const record of records) {\n const matchInfo = await filterer.recordMatchesFilter(record, parents);\n const shouldForceIncludeDescendants =\n forceIncludeItem || matchInfo.shouldForceIncludeDescendants;\n const {\n filteredRecords: filteredChildren,\n shouldExpandNodeParents,\n matchesCount: childrenMatchesCount,\n filteredResultMatches: childrenResultMatches,\n filteredTypes: childrenFilteredTypes,\n } = await matchRecordHierarchy(\n filterer,\n record.getChildrenRecords(),\n [...parents, record],\n shouldForceIncludeDescendants\n );\n filteredResultMatches = filteredResultMatches.concat(childrenResultMatches);\n filteredTypes = [...filteredTypes, ...childrenFilteredTypes];\n matchesCount += childrenMatchesCount;\n // if child hierarchy indicates parents should be expanded, then it should be passed back up to the top parent\n expandParent = expandParent || shouldExpandNodeParents;\n\n let newRecord: PropertyRecord | undefined;\n if (matchInfo.matchesFilter) {\n filteredTypes = [...filteredTypes, ...(matchInfo.filteredTypes ?? [])];\n const recordMatchesCount = matchInfo.matchesCount ?? 0;\n matchesCount += recordMatchesCount;\n // Item is included if it matches filter\n // If at least one matched record from records list needs its parent expanded,\n // then `expandParent` should be set to true\n expandParent = expandParent || !!matchInfo.shouldExpandNodeParents;\n newRecord = copyPropertyRecord(\n record,\n filteredChildren,\n shouldExpandNodeParents\n );\n filteredResultMatches.push({\n id: newRecord.property.name,\n matchesCount: recordMatchesCount,\n });\n } else if (filteredChildren.length !== 0 || forceIncludeItem) {\n // Item is also included if it has at least one matched child or is forcefully included by its parent\n newRecord = copyPropertyRecord(\n record,\n filteredChildren,\n shouldExpandNodeParents\n );\n }\n\n if (newRecord) newMatchedRecords.push(newRecord);\n }\n\n return {\n filteredRecords: newMatchedRecords,\n shouldExpandNodeParents: expandParent,\n matchesCount,\n filteredResultMatches,\n filteredTypes,\n };\n}\n\nfunction copyPropertyCategory(\n propertyCategory: PropertyCategory,\n newChildren: PropertyCategory[],\n expand: boolean\n): PropertyCategory {\n return {\n ...propertyCategory,\n childCategories: newChildren,\n expand,\n };\n}\n\nfunction copyPropertyRecord(\n record: PropertyRecord,\n newChildren: PropertyRecord[],\n autoExpand: boolean\n) {\n const r = record.copyWithNewValue(\n createNewPropertyValue(record.value, newChildren)\n );\n r.autoExpand = autoExpand;\n return r;\n}\n\nfunction createNewPropertyValue(\n value: PropertyValue,\n newChildren: PropertyRecord[]\n): PropertyValue {\n switch (value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return { ...value };\n case PropertyValueFormat.Array:\n return {\n valueFormat: PropertyValueFormat.Array,\n itemsTypeName: value.itemsTypeName,\n items: newChildren,\n };\n case PropertyValueFormat.Struct:\n const members: { [name: string]: PropertyRecord } = {};\n newChildren.forEach((child) => (members[child.property.name] = child));\n return {\n valueFormat: PropertyValueFormat.Struct,\n members,\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeEventHandler.d.ts","sourceRoot":"","sources":["../../../../src/components-react/tree/controlled/TreeEventHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,iCAAiC,CAAC;AAIzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACV,iBAAiB,EACjB,kCAAkC,EAClC,iCAAiC,EAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,aAAa,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAChE;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,WAAW,EAAE,eAAe,CAAC;IAC7B,+DAA+D;IAC/D,UAAU,EAAE,eAAe,CAAC;IAC5B,0FAA0F;IAC1F,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,wCAAwC;IACxC,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,UAAU,EAAE,UAAU
|
|
1
|
+
{"version":3,"file":"TreeEventHandler.d.ts","sourceRoot":"","sources":["../../../../src/components-react/tree/controlled/T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,EAAE,EAAE,iBAAiB;IAIpD,kHAAkH;IAC3G,mBAAmB,CAAC,EACzB,aAAa,GACd,EAAE,kCAAkC,GAAG,YAAY,GAAG,SAAS;IAahE,gIAAgI;IACzH,mBAAmB,CAAC,EACzB,YAAY,GACb,EAAE,iCAAiC,GAAG,YAAY,GAAG,SAAS;IAkB/D,qCAAqC;IAC9B,sBAAsB,CAAC,EAC5B,YAAY,GACb,EAAE,gCAAgC,GAAG,YAAY,GAAG,SAAS;IAM9D,sFAAsF;IAC/E,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,iBAAiB;IAIvD,4FAA4F;IACrF,iBAAiB,CAAC,CAAC,EAAE,iBAAiB;IAE7C,sFAAsF;IAC/E,qBAAqB,CAAC,EAAE,MAAM,EAAE,EAAE,iBAAiB;IAI1D,sFAAsF;IACtF,OAAO,CAAC,cAAc;CAQvB"}
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Tree
|
|
7
7
|
*/
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _TreeEventHandler_instances, _TreeEventHandler_dispose;
|
|
8
14
|
import "../../common/DisposePolyfill.js";
|
|
9
15
|
import { Subject, takeUntil } from "rxjs";
|
|
10
16
|
import { TreeModelMutator } from "./internal/TreeModelMutator.js";
|
|
@@ -15,20 +21,23 @@ import { toRxjsObservable } from "./Observable.js";
|
|
|
15
21
|
*/
|
|
16
22
|
export class TreeEventHandler {
|
|
17
23
|
constructor(params) {
|
|
24
|
+
_TreeEventHandler_instances.add(this);
|
|
18
25
|
this._disposed = new Subject();
|
|
19
26
|
this._selectionReplaced = new Subject();
|
|
20
27
|
this._modelMutator = new TreeModelMutator(params.modelSource, params.nodeLoader, !!params.collapsedChildrenDisposalEnabled);
|
|
21
28
|
this._editingParams = params.editingParams;
|
|
22
29
|
}
|
|
23
30
|
/** Destructor. Must be called to clean up. */
|
|
24
|
-
[
|
|
31
|
+
[(_TreeEventHandler_instances = new WeakSet(), _TreeEventHandler_dispose = function _TreeEventHandler_dispose() {
|
|
25
32
|
this._disposed.next();
|
|
33
|
+
}, Symbol.dispose)]() {
|
|
34
|
+
__classPrivateFieldGet(this, _TreeEventHandler_instances, "m", _TreeEventHandler_dispose).call(this);
|
|
26
35
|
}
|
|
27
36
|
/** Disposes tree event handler.
|
|
28
37
|
* @deprecated in 5.5.0. Use `[Symbol.dispose]` instead.
|
|
29
38
|
*/
|
|
30
39
|
dispose() {
|
|
31
|
-
this
|
|
40
|
+
__classPrivateFieldGet(this, _TreeEventHandler_instances, "m", _TreeEventHandler_dispose).call(this);
|
|
32
41
|
}
|
|
33
42
|
get modelSource() {
|
|
34
43
|
return this._modelMutator.modelSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeEventHandler.js","sourceRoot":"","sources":["../../../../src/components-react/tree/controlled/TreeEventHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG
|
|
1
|
+
{"version":3,"file":"TreeEventHandler.js","sourceRoot":"","sources":["../../../../src/components-react/tree/controlled/TreeEventHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;AAEH,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAoCnD;;;GAGG;AACH,MAAM,OAAO,gB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C,cAAc,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,sFAAsF;IAC9E,cAAc,CAAC,MAAc;QACnC,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS;YAAE,OAAO;QAE9C,IAAI,CAAC,aAAa,CAAC,eAAe,CAChC,MAAM,EACN,IAAI,CAAC,cAAc,CAAC,aAAa,CAClC,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"../../common/DisposePolyfill.js\";\n\nimport { Subject, takeUntil } from \"rxjs\";\nimport { TreeModelMutator } from \"./internal/TreeModelMutator.js\";\nimport type { Subscription } from \"./Observable.js\";\nimport { toRxjsObservable } from \"./Observable.js\";\nimport type {\n TreeCheckboxStateChangeEventArgs,\n TreeEvents,\n TreeNodeEventArgs,\n TreeSelectionModificationEventArgs,\n TreeSelectionReplacementEventArgs,\n} from \"./TreeEvents.js\";\nimport type { TreeModelNode } from \"./TreeModel.js\";\nimport type { TreeModelSource } from \"./TreeModelSource.js\";\nimport type { ITreeNodeLoader } from \"./TreeNodeLoader.js\";\n\n/**\n * Params used for tree node editing.\n * @public\n */\nexport interface TreeEditingParams {\n /** Callback that is called when node is updated. */\n onNodeUpdated: (node: TreeModelNode, newValue: string) => void;\n}\n\n/**\n * Data structure that describes tree event handler params.\n * @public\n */\nexport interface TreeEventHandlerParams {\n /** Model source used to modify tree model while handling events. */\n modelSource: TreeModelSource;\n /** Node loader used to load children when node is expanded. */\n nodeLoader: ITreeNodeLoader;\n /** Specifies whether children should be disposed when parent node is collapsed or not. */\n collapsedChildrenDisposalEnabled?: boolean;\n /** Parameters used for node editing. */\n editingParams?: TreeEditingParams;\n}\n\n/**\n * Default tree event handler.\n * @public\n */\nexport class TreeEventHandler implements TreeEvents, Disposable {\n private _modelMutator: TreeModelMutator;\n private _editingParams?: TreeEditingParams;\n\n private _disposed = new Subject<void>();\n private _selectionReplaced = new Subject<void>();\n\n constructor(params: TreeEventHandlerParams) {\n this._modelMutator = new TreeModelMutator(\n params.modelSource,\n params.nodeLoader,\n !!params.collapsedChildrenDisposalEnabled\n );\n this._editingParams = params.editingParams;\n }\n\n #dispose() {\n this._disposed.next();\n }\n\n /** Destructor. Must be called to clean up. */\n public [Symbol.dispose]() {\n this.#dispose();\n }\n\n /** Disposes tree event handler.\n * @deprecated in 5.5.0. Use `[Symbol.dispose]` instead.\n */\n public dispose() {\n this.#dispose();\n }\n\n public get modelSource() {\n return this._modelMutator.modelSource;\n }\n\n /** Expands node and starts loading children. */\n public onNodeExpanded({ nodeId }: TreeNodeEventArgs) {\n toRxjsObservable(this._modelMutator.expandNode(nodeId))\n .pipe(takeUntil(this._disposed))\n .subscribe();\n }\n\n /** Collapses node */\n public onNodeCollapsed({ nodeId }: TreeNodeEventArgs) {\n this._modelMutator.collapseNode(nodeId);\n }\n\n /** Selects and deselects nodes until event is handled, handler is disposed or selection replaced event occurs. */\n public onSelectionModified({\n modifications,\n }: TreeSelectionModificationEventArgs): Subscription | undefined {\n return toRxjsObservable(modifications)\n .pipe(takeUntil(this._disposed), takeUntil(this._selectionReplaced))\n .subscribe({\n next: ({ selectedNodeItems, deselectedNodeItems }) => {\n this._modelMutator.modifySelection(\n selectedNodeItems,\n deselectedNodeItems\n );\n },\n });\n }\n\n /** Replaces currently selected nodes until event is handled, handler is disposed or another selection replaced event occurs. */\n public onSelectionReplaced({\n replacements,\n }: TreeSelectionReplacementEventArgs): Subscription | undefined {\n this._selectionReplaced.next();\n\n let firstEmission = true;\n return toRxjsObservable(replacements)\n .pipe(takeUntil(this._disposed), takeUntil(this._selectionReplaced))\n .subscribe({\n next: ({ selectedNodeItems }) => {\n if (firstEmission) {\n firstEmission = false;\n this._modelMutator.replaceSelection(selectedNodeItems);\n }\n\n this._modelMutator.modifySelection(selectedNodeItems, []);\n },\n });\n }\n\n /** Changes nodes checkbox states. */\n public onCheckboxStateChanged({\n stateChanges,\n }: TreeCheckboxStateChangeEventArgs): Subscription | undefined {\n return stateChanges.subscribe((changes) =>\n this._modelMutator.setCheckboxStates(changes)\n );\n }\n\n /** Activates node editing if editing parameters are supplied and node is editable. */\n public onDelayedNodeClick({ nodeId }: TreeNodeEventArgs) {\n this.activateEditor(nodeId);\n }\n\n /** This method is declared here to be overridden by classes that extend TreeEventHandler */\n public onNodeDoubleClick(_: TreeNodeEventArgs) {}\n\n /** Activates node editing if editing parameters are supplied and node is editable. */\n public onNodeEditorActivated({ nodeId }: TreeNodeEventArgs) {\n this.activateEditor(nodeId);\n }\n\n /** Activates node editing if editing parameters are supplied and node is editable. */\n private activateEditor(nodeId: string) {\n if (this._editingParams === undefined) return;\n\n this._modelMutator.activateEditing(\n nodeId,\n this._editingParams.onNodeUpdated\n );\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/components-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "A react component library of iTwin.js UI data-oriented components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./lib/components-react.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@itwin/itwinui-react": "^3.15.0",
|
|
41
41
|
"react": "^18.0.0",
|
|
42
42
|
"react-dom": "^18.0.0",
|
|
43
|
-
"@itwin/core-react": "5.
|
|
43
|
+
"@itwin/core-react": "5.6.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@itwin/appui-abstract": "rc",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"typescript": "~5.6.2",
|
|
77
77
|
"upath": "^2.0.1",
|
|
78
78
|
"vitest": "^3.0.6",
|
|
79
|
-
"@itwin/core-react": "5.
|
|
79
|
+
"@itwin/core-react": "5.6.0"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@itwin/itwinui-icons-react": "^2.8.0",
|