@itwin/components-react 3.0.0-dev.77 → 3.0.0-dev.78
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/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts +8 -0
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.d.ts.map +1 -1
- package/lib/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
- package/lib/public/locales/en/UiComponents.json +1 -8
- package/package.json +12 -12
|
@@ -10,7 +10,15 @@ import { FilteredType, IPropertyDataFilterer } from "./filterers/PropertyDataFil
|
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
export interface FilteredPropertyData extends PropertyData {
|
|
13
|
+
/**
|
|
14
|
+
* Shows how many matches were found when filtering data.
|
|
15
|
+
* `undefined` when filterer is not active
|
|
16
|
+
*/
|
|
13
17
|
matchesCount?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Function used for getting [[HighlightInfo]] by index from all the filtered matches.
|
|
20
|
+
* `undefined` when filterer is not active
|
|
21
|
+
*/
|
|
14
22
|
getMatchByIndex?: (index: number) => HighlightInfo | undefined;
|
|
15
23
|
/** Types of objects that were used for filtering. */
|
|
16
24
|
filteredTypes?: FilteredType[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/dataproviders/FilteringDataProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAoB,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACzH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAA4B,MAAM,sCAAsC,CAAC;AAWrH;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;
|
|
1
|
+
{"version":3,"file":"FilteringDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/dataproviders/FilteringDataProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAoB,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACzH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAA4B,MAAM,sCAAsC,CAAC;AAWrH;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD;;;MAGE;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;MAGE;IACF,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,6BAA8B,YAAW,qBAAqB,EAAE,WAAW;IAMnE,OAAO,CAAC,aAAa;IAAyB,OAAO,CAAC,SAAS;IAL3E,aAAa,0BAAiC;IACrD,OAAO,CAAC,qBAAqB,CAAwD;IACrF,OAAO,CAAC,6BAA6B,CAAW;IAChD,OAAO,CAAC,2BAA2B,CAAW;gBAEnB,aAAa,EAAE,qBAAqB,EAAU,SAAS,EAAE,qBAAqB;IAKlG,OAAO,IAAI,IAAI;IAKT,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;YAavC,kBAAkB;CAqCjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteringDataProvider.js","sourceRoot":"","sources":["../../../../src/components-react/propertygrid/dataproviders/FilteringDataProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0DAA2F;AAI3F,kEAAyH;AAiC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B,CAAC,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC;IAC1B,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAoB,EAAE,WAA6B;IACjF,QAAQ,KAAK,CAAC,WAAW,EAAE;QACzB,KAAK,oCAAmB,CAAC,SAAS;YAChC,yBAAY,KAAK,EAAG;QACtB,KAAK,oCAAmB,CAAC,KAAK;YAC5B,OAAO;gBACL,WAAW,EAAE,oCAAmB,CAAC,KAAK;gBACtC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,KAAK,EAAE,WAAW;aACnB,CAAC;QACJ,KAAK,oCAAmB,CAAC,MAAM;YAC7B,MAAM,OAAO,GAAuC,EAAE,CAAC;YACvD,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;YACrE,OAAO;gBACL,WAAW,EAAE,oCAAmB,CAAC,MAAM;gBACvC,OAAO;aACR,CAAC;KACL;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 { PropertyRecord, PropertyValue, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { IDisposable } from \"@itwin/core-bentley\";\nimport { HighlightInfo } from \"../../common/HighlightingComponentProps\";\nimport { CategoryRecordsDict } from \"../internal/flat-items/MutableGridCategory\";\nimport { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from \"../PropertyDataProvider\";\nimport { FilteredType, IPropertyDataFilterer, PropertyDataFilterResult } from \"./filterers/PropertyDataFiltererBase\";\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 implements IPropertyDataProvider, IDisposable {\n public onDataChanged = new PropertyDataChangeEvent();\n private _filteredPropertyData: Promise<FilteredPropertyData> | undefined = undefined;\n private _disposeFilterChangedListener: Function;\n private _disposeDataChangedListener: Function;\n\n public constructor(private _dataProvider: IPropertyDataProvider, private _filterer: IPropertyDataFilterer) {\n this._disposeFilterChangedListener = this._filterer.onFilterChanged.addListener(() => { this._filteredPropertyData = undefined; this.onDataChanged.raiseEvent(); });\n this._disposeDataChangedListener = this._dataProvider.onDataChanged.addListener(() => { this._filteredPropertyData = undefined; this.onDataChanged.raiseEvent(); });\n }\n\n public dispose(): void {\n this._disposeDataChangedListener();\n this._disposeFilterChangedListener();\n }\n\n public async getData(): Promise<FilteredPropertyData> {\n if (this._filteredPropertyData) {\n return this._filteredPropertyData;\n }\n\n this._filteredPropertyData = this._dataProvider.getData().then(async (propertyData) => {\n return ((this._filterer.isActive) ?\n this.filterPropertyData(propertyData) : propertyData);\n });\n\n return this._filteredPropertyData;\n }\n\n private async filterPropertyData(propertyData: PropertyData) {\n const { categories, records, label, description } = { ...propertyData };\n const { filteredCategories, filteredRecords, matchesCount, filteredResultMatches, filteredTypes } = 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)\n 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(filterer: IPropertyDataFilterer, categories: PropertyCategory[], records: CategoryRecordsDict, newRecords?: CategoryRecordsDict, parentMatchInfo?: PropertyDataFilterResult) {\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({ id: category.name, matchesCount: matchInfo.matchesCount ?? 0 });\n allFilteredTypes = allFilteredTypes.concat(matchInfo.filteredTypes ?? []);\n matchesCount += matchInfo.matchesCount ?? 0;\n }\n\n const childRecords = records[category.name] ?? [];\n const { filteredRecords, matchesCount: count, filteredResultMatches, filteredTypes } = await matchRecordHierarchy(filterer, childRecords, []);\n allFilteredResultMatches = allFilteredResultMatches.concat(filteredResultMatches);\n allFilteredTypes = allFilteredTypes.concat(filteredTypes);\n matchesCount += count;\n\n const parentInfo = parentMatchInfo?.matchesFilter ? parentMatchInfo : matchInfo;\n\n const childCategories = category.childCategories ?? [];\n const { filteredCategories, matchesCount: childCount, filteredResultMatches: childFilteredResultMatches, filteredTypes: childFilteredTypes } = await matchHierarchy(filterer, childCategories, records, newRecords, parentInfo);\n allFilteredResultMatches = allFilteredResultMatches.concat(childFilteredResultMatches);\n allFilteredTypes = allFilteredTypes.concat(childFilteredTypes);\n matchesCount += childCount;\n\n let expand = !(count === 0 && childCount === 0);\n if (matchInfo.matchesFilter || (parentMatchInfo?.matchesFilter && parentMatchInfo.shouldForceIncludeDescendants)) {\n newRecords[category.name] = records[category.name];\n if (matchInfo.matchesFilter) {\n expand = true;\n }\n const newCategory = copyPropertyCategory(category, filteredCategories, expand);\n newCategories.push(newCategory);\n }\n\n if ((filteredRecords.length !== 0 || filteredCategories.length !== 0) && !matchInfo.matchesFilter && !(parentMatchInfo?.shouldExpandNodeParents && parentMatchInfo.matchesFilter)) {\n const newCategory = copyPropertyCategory(category, filteredCategories, expand);\n newRecords[newCategory.name] = filteredRecords;\n newCategories.push(newCategory);\n }\n }\n\n return { filteredCategories: newCategories, filteredRecords: newRecords, matchesCount, filteredResultMatches: allFilteredResultMatches, filteredTypes: allFilteredTypes };\n}\n\nasync function matchRecordHierarchy(filterer: IPropertyDataFilterer, records: PropertyRecord[], parents: PropertyRecord[], forceIncludeItem: boolean = false): 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 = forceIncludeItem || matchInfo.shouldForceIncludeDescendants;\n const { filteredRecords: filteredChildren, shouldExpandNodeParents, matchesCount: childrenMatchesCount, filteredResultMatches: childrenResultMatches, filteredTypes: childrenFilteredTypes } = await matchRecordHierarchy(filterer, record.getChildrenRecords(), [...parents, record], shouldForceIncludeDescendants);\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(record, filteredChildren, shouldExpandNodeParents);\n filteredResultMatches.push({ id: newRecord.property.name, matchesCount: recordMatchesCount });\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(record, filteredChildren, shouldExpandNodeParents);\n }\n\n if (newRecord)\n newMatchedRecords.push(newRecord);\n }\n\n return { filteredRecords: newMatchedRecords, shouldExpandNodeParents: expandParent, matchesCount, filteredResultMatches, filteredTypes };\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(record: PropertyRecord, newChildren: PropertyRecord[], autoExpand: boolean) {\n const r = record.copyWithNewValue(createNewPropertyValue(record.value, newChildren));\n r.autoExpand = autoExpand;\n return r;\n}\n\nfunction createNewPropertyValue(value: PropertyValue, newChildren: PropertyRecord[]): 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;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0DAA2F;AAI3F,kEAAyH;AAiCzH;;;GAGG;AACH,MAAa,6BAA6B;IAMxC,YAA2B,aAAoC,EAAU,SAAgC;QAA9E,kBAAa,GAAb,aAAa,CAAuB;QAAU,cAAS,GAAT,SAAS,CAAuB;QALlG,kBAAa,GAAG,IAAI,8CAAuB,EAAE,CAAC;QAC7C,0BAAqB,GAA8C,SAAS,CAAC;QAKnF,IAAI,CAAC,6BAA6B,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACpK,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACtK,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACnC,IAAI,CAAC,6BAA6B,EAAE,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,IAAI,IAAI,CAAC,qBAAqB,EAAE;YAC9B,OAAO,IAAI,CAAC,qBAAqB,CAAC;SACnC;QAED,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;YACpF,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACjC,IAAI,CAAC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f,uCACK,gBAAgB,KACnB,eAAe,EAAE,WAAW,EAC5B,MAAM,IACN;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAsB,EAAE,WAA6B,EAAE,UAAmB;IACpG,MAAM,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC;IAC1B,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAoB,EAAE,WAA6B;IACjF,QAAQ,KAAK,CAAC,WAAW,EAAE;QACzB,KAAK,oCAAmB,CAAC,SAAS;YAChC,yBAAY,KAAK,EAAG;QACtB,KAAK,oCAAmB,CAAC,KAAK;YAC5B,OAAO;gBACL,WAAW,EAAE,oCAAmB,CAAC,KAAK;gBACtC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,KAAK,EAAE,WAAW;aACnB,CAAC;QACJ,KAAK,oCAAmB,CAAC,MAAM;YAC7B,MAAM,OAAO,GAAuC,EAAE,CAAC;YACvD,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;YACrE,OAAO;gBACL,WAAW,EAAE,oCAAmB,CAAC,MAAM;gBACvC,OAAO;aACR,CAAC;KACL;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 { PropertyRecord, PropertyValue, PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { IDisposable } from \"@itwin/core-bentley\";\nimport { HighlightInfo } from \"../../common/HighlightingComponentProps\";\nimport { CategoryRecordsDict } from \"../internal/flat-items/MutableGridCategory\";\nimport { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from \"../PropertyDataProvider\";\nimport { FilteredType, IPropertyDataFilterer, PropertyDataFilterResult } from \"./filterers/PropertyDataFiltererBase\";\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 implements IPropertyDataProvider, IDisposable {\n public onDataChanged = new PropertyDataChangeEvent();\n private _filteredPropertyData: Promise<FilteredPropertyData> | undefined = undefined;\n private _disposeFilterChangedListener: Function;\n private _disposeDataChangedListener: Function;\n\n public constructor(private _dataProvider: IPropertyDataProvider, private _filterer: IPropertyDataFilterer) {\n this._disposeFilterChangedListener = this._filterer.onFilterChanged.addListener(() => { this._filteredPropertyData = undefined; this.onDataChanged.raiseEvent(); });\n this._disposeDataChangedListener = this._dataProvider.onDataChanged.addListener(() => { this._filteredPropertyData = undefined; this.onDataChanged.raiseEvent(); });\n }\n\n public dispose(): void {\n this._disposeDataChangedListener();\n this._disposeFilterChangedListener();\n }\n\n public async getData(): Promise<FilteredPropertyData> {\n if (this._filteredPropertyData) {\n return this._filteredPropertyData;\n }\n\n this._filteredPropertyData = this._dataProvider.getData().then(async (propertyData) => {\n return ((this._filterer.isActive) ?\n this.filterPropertyData(propertyData) : propertyData);\n });\n\n return this._filteredPropertyData;\n }\n\n private async filterPropertyData(propertyData: PropertyData) {\n const { categories, records, label, description } = { ...propertyData };\n const { filteredCategories, filteredRecords, matchesCount, filteredResultMatches, filteredTypes } = 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)\n 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(filterer: IPropertyDataFilterer, categories: PropertyCategory[], records: CategoryRecordsDict, newRecords?: CategoryRecordsDict, parentMatchInfo?: PropertyDataFilterResult) {\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({ id: category.name, matchesCount: matchInfo.matchesCount ?? 0 });\n allFilteredTypes = allFilteredTypes.concat(matchInfo.filteredTypes ?? []);\n matchesCount += matchInfo.matchesCount ?? 0;\n }\n\n const childRecords = records[category.name] ?? [];\n const { filteredRecords, matchesCount: count, filteredResultMatches, filteredTypes } = await matchRecordHierarchy(filterer, childRecords, []);\n allFilteredResultMatches = allFilteredResultMatches.concat(filteredResultMatches);\n allFilteredTypes = allFilteredTypes.concat(filteredTypes);\n matchesCount += count;\n\n const parentInfo = parentMatchInfo?.matchesFilter ? parentMatchInfo : matchInfo;\n\n const childCategories = category.childCategories ?? [];\n const { filteredCategories, matchesCount: childCount, filteredResultMatches: childFilteredResultMatches, filteredTypes: childFilteredTypes } = await matchHierarchy(filterer, childCategories, records, newRecords, parentInfo);\n allFilteredResultMatches = allFilteredResultMatches.concat(childFilteredResultMatches);\n allFilteredTypes = allFilteredTypes.concat(childFilteredTypes);\n matchesCount += childCount;\n\n let expand = !(count === 0 && childCount === 0);\n if (matchInfo.matchesFilter || (parentMatchInfo?.matchesFilter && parentMatchInfo.shouldForceIncludeDescendants)) {\n newRecords[category.name] = records[category.name];\n if (matchInfo.matchesFilter) {\n expand = true;\n }\n const newCategory = copyPropertyCategory(category, filteredCategories, expand);\n newCategories.push(newCategory);\n }\n\n if ((filteredRecords.length !== 0 || filteredCategories.length !== 0) && !matchInfo.matchesFilter && !(parentMatchInfo?.shouldExpandNodeParents && parentMatchInfo.matchesFilter)) {\n const newCategory = copyPropertyCategory(category, filteredCategories, expand);\n newRecords[newCategory.name] = filteredRecords;\n newCategories.push(newCategory);\n }\n }\n\n return { filteredCategories: newCategories, filteredRecords: newRecords, matchesCount, filteredResultMatches: allFilteredResultMatches, filteredTypes: allFilteredTypes };\n}\n\nasync function matchRecordHierarchy(filterer: IPropertyDataFilterer, records: PropertyRecord[], parents: PropertyRecord[], forceIncludeItem: boolean = false): 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 = forceIncludeItem || matchInfo.shouldForceIncludeDescendants;\n const { filteredRecords: filteredChildren, shouldExpandNodeParents, matchesCount: childrenMatchesCount, filteredResultMatches: childrenResultMatches, filteredTypes: childrenFilteredTypes } = await matchRecordHierarchy(filterer, record.getChildrenRecords(), [...parents, record], shouldForceIncludeDescendants);\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(record, filteredChildren, shouldExpandNodeParents);\n filteredResultMatches.push({ id: newRecord.property.name, matchesCount: recordMatchesCount });\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(record, filteredChildren, shouldExpandNodeParents);\n }\n\n if (newRecord)\n newMatchedRecords.push(newRecord);\n }\n\n return { filteredRecords: newMatchedRecords, shouldExpandNodeParents: expandParent, matchesCount, filteredResultMatches, filteredTypes };\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(record: PropertyRecord, newChildren: PropertyRecord[], autoExpand: boolean) {\n const r = record.copyWithNewValue(createNewPropertyValue(record.value, newChildren));\n r.autoExpand = autoExpand;\n return r;\n}\n\nfunction createNewPropertyValue(value: PropertyValue, newChildren: PropertyRecord[]): 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"]}
|
|
@@ -45,13 +45,6 @@
|
|
|
45
45
|
"expand": "See more",
|
|
46
46
|
"collapse": "See less"
|
|
47
47
|
},
|
|
48
|
-
"signIn": {
|
|
49
|
-
"prompt": "Please sign in to access your Bentley services.",
|
|
50
|
-
"signInButton": "Sign In",
|
|
51
|
-
"profilePrompt": "Don't have a profile?",
|
|
52
|
-
"register": "Register",
|
|
53
|
-
"offlineButton": "Work Offline?"
|
|
54
|
-
},
|
|
55
48
|
"timepicker": {
|
|
56
49
|
"day-period-am": "AM",
|
|
57
50
|
"day-period-pm": "PM"
|
|
@@ -127,4 +120,4 @@
|
|
|
127
120
|
"text": "Text Editor",
|
|
128
121
|
"textarea": "Textarea Editor"
|
|
129
122
|
}
|
|
130
|
-
}
|
|
123
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/components-react",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.78",
|
|
4
4
|
"description": "iModel.js UI complex components",
|
|
5
5
|
"main": "lib/components-react.js",
|
|
6
6
|
"typings": "lib/components-react",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"url": "http://www.bentley.com"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@itwin/core-bentley": "^3.0.0-dev.
|
|
24
|
-
"@itwin/core-i18n": "^3.0.0-dev.
|
|
25
|
-
"@itwin/appui-abstract": "^3.0.0-dev.
|
|
26
|
-
"@itwin/core-react": "^3.0.0-dev.
|
|
23
|
+
"@itwin/core-bentley": "^3.0.0-dev.78",
|
|
24
|
+
"@itwin/core-i18n": "^3.0.0-dev.78",
|
|
25
|
+
"@itwin/appui-abstract": "^3.0.0-dev.78",
|
|
26
|
+
"@itwin/core-react": "^3.0.0-dev.78",
|
|
27
27
|
"react": "^16.8.6 || ^17.0.0",
|
|
28
28
|
"react-dom": "^16.8.6 || ^17.0.0"
|
|
29
29
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@itwin/core-bentley": "3.0.0-dev.
|
|
36
|
-
"@itwin/core-common": "3.0.0-dev.
|
|
37
|
-
"@itwin/build-tools": "3.0.0-dev.
|
|
38
|
-
"@itwin/eslint-plugin": "3.0.0-dev.
|
|
39
|
-
"@itwin/core-i18n": "3.0.0-dev.
|
|
40
|
-
"@itwin/appui-abstract": "3.0.0-dev.
|
|
41
|
-
"@itwin/core-react": "3.0.0-dev.
|
|
35
|
+
"@itwin/core-bentley": "3.0.0-dev.78",
|
|
36
|
+
"@itwin/core-common": "3.0.0-dev.78",
|
|
37
|
+
"@itwin/build-tools": "3.0.0-dev.78",
|
|
38
|
+
"@itwin/eslint-plugin": "3.0.0-dev.78",
|
|
39
|
+
"@itwin/core-i18n": "3.0.0-dev.78",
|
|
40
|
+
"@itwin/appui-abstract": "3.0.0-dev.78",
|
|
41
|
+
"@itwin/core-react": "3.0.0-dev.78",
|
|
42
42
|
"@testing-library/react": "^12.0.0",
|
|
43
43
|
"@testing-library/react-hooks": "^3.2.1",
|
|
44
44
|
"@testing-library/user-event": "^13.2.1",
|