@itwin/presentation-hierarchies 2.0.0-alpha.2 → 2.0.0-alpha.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAkShG,4DAgCC;AAGD,gEAcC;AAjVD,+BAAoG;AAGpG,oEAAkG;AAClG,8EAAwE;AACxE,gEAA6E;AAC7E,yFAMgD;AAChD,6EAA0G;AAC1G,mFAAkF;AAClF,qEAAkE;AAClE,qEAA+D;AAU/D,gBAAgB;AAChB,MAAa,4BAA4B;IAC/B,aAAa,CAAoD;IACjE,OAAO,CAA0B;IACjC,oBAAoB,CAA2B;IAC/C,YAAY,CAAiB;IAErC,YAAmB,KAAwC;QACzD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC,mBAAmB,CAAC;QACtD,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,SAAE,EAAC,IAAA,uCAAkB,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5G,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,CAAC,IAAI,EAAE,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,SAAE,EAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CACtF,IAAA,aAAM,EAAC,CAAC,aAAa,EAAE,EAAE;gB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A2B,CAAC,aAAa,SAAS,yCAAiC;gBACpF,GAAG,CAAC,KAAK,CAAC,KAAK;OACxB;SACF;KACF,CAAC;AACJ,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\nimport { defer, filter, from, map, merge, mergeAll, mergeMap, Observable, of, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { createHierarchyFilteringHelper, HierarchyFilteringPath } from \"../HierarchyFiltering.js\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey, IModelInstanceKey } from \"../HierarchyNodeKey.js\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n} from \"../imodel/IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode } from \"../imodel/IModelHierarchyNode.js\";\nimport { NodeSelectClauseColumnNames } from \"../imodel/NodeSelectQueryFactory.js\";\nimport { defaultNodesParser } from \"../imodel/TreeNodesReader.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport { RxjsHierarchyDefinition, RxjsNodeParser, RxjsNodePostProcessor, RxjsNodePreProcessor } from \"../internal/RxjsHierarchyDefinition.js\";\n\ninterface FilteringHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n source: RxjsHierarchyDefinition;\n nodeIdentifierPaths: HierarchyFilteringPath[];\n nodesParser?: RxjsNodeParser;\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements RxjsHierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n private _source: RxjsHierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyFilteringPath[];\n private _nodesParser: RxjsNodeParser;\n\n public constructor(props: FilteringHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => of(defaultNodesParser(row)));\n }\n\n public get preProcessNode(): RxjsNodePreProcessor {\n return (node) => {\n return (this._source.preProcessNode ? this._source.preProcessNode(node) : of(node)).pipe(\n filter((processedNode) => {\n if (processedNode.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return false;\n }\n return true;\n }),\n );\n };\n }\n\n private shouldExpandGroupingNode(node: ProcessedGroupingHierarchyNode) {\n for (const child of node.children) {\n /* c8 ignore next 3 */\n if (!child.filtering) {\n continue;\n }\n\n if (child.filtering.isFilterTarget) {\n const childAutoExpand = child.filtering.filterTargetOptions?.autoExpand;\n\n // If child is a filter target and is has no `autoExpand` flag, then it's always to be expanded.\n if (childAutoExpand === true) {\n return true;\n }\n\n // If it's not an object and not `true`, then it's falsy - continue looking\n if (typeof childAutoExpand !== \"object\") {\n continue;\n }\n\n // If grouping node's child has `autoExpandUntil` flag,\n // auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.\n const nodeDepth = childAutoExpand.includeGroupingNodes\n ? node.parentKeys.length\n : node.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n const filterTargetDepth = childAutoExpand.depth;\n if (nodeDepth < filterTargetDepth) {\n return true;\n }\n }\n\n if (!child.filtering.filteredChildrenIdentifierPaths) {\n /* c8 ignore next */\n continue;\n }\n\n for (const path of child.filtering.filteredChildrenIdentifierPaths) {\n if (\"path\" in path && path.options?.autoExpand) {\n return true;\n }\n }\n }\n return false;\n }\n\n public get postProcessNode(): RxjsNodePostProcessor {\n return (node) => {\n return (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(\n map((processedNode) => {\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n if (ProcessedHierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {\n Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n }),\n );\n };\n }\n\n public get parseNode(): RxjsNodeParser {\n return (row, parentNode) => {\n return this._nodesParser(row).pipe(\n mergeMap((parsedNode) => {\n if (!row[ECSQL_COLUMN_NAME_FilterECInstanceId] || !row[ECSQL_COLUMN_NAME_FilterClassName]) {\n return of(parsedNode);\n }\n const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_FilterClassName], id: row[ECSQL_COLUMN_NAME_FilterECInstanceId] };\n const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, parentNode);\n const nodeExtraPropsPossiblyPromise = filteringHelper.createChildNodePropsAsync({\n pathMatcher: (identifier): boolean | Promise<boolean> => {\n if (identifier.id !== rowInstanceKey.id) {\n return false;\n }\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {\n return false;\n }\n if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {\n return false;\n }\n if (identifier.className === rowInstanceKey.className) {\n return true;\n }\n return Promise.all([\n this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className),\n this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo);\n },\n });\n return (nodeExtraPropsPossiblyPromise instanceof Promise ? from(nodeExtraPropsPossiblyPromise) : of(nodeExtraPropsPossiblyPromise)).pipe(\n map((nodeExtraProps) => {\n if (nodeExtraProps?.autoExpand) {\n const parentLength = !parentNode\n ? 0\n : nodeExtraProps.filtering?.includeGroupingNodes\n ? 1 + parentNode.parentKeys.length\n : 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n parsedNode.autoExpand =\n nodeExtraProps.filtering?.autoExpandDepth !== undefined && parentLength >= nodeExtraProps.filtering.autoExpandDepth ? undefined : true;\n }\n if (nodeExtraProps?.filtering) {\n parsedNode.filtering = nodeExtraProps.filtering;\n }\n return parsedNode;\n }),\n );\n }),\n );\n };\n }\n\n public defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition> {\n const sourceDefinitions = this._source.defineHierarchyLevel(props);\n\n const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, props.parentNode);\n const childNodeFilteringIdentifiers = filteringHelper.getChildNodeFilteringIdentifiers();\n if (!childNodeFilteringIdentifiers) {\n return sourceDefinitions;\n }\n\n const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions.pipe(mergeAll()), HierarchyNodesDefinition.isGenericNode);\n return merge(\n genericNodeDefinitions.pipe(\n map((definition) => {\n if (\n filteringHelper.hasFilterTargetAncestor ||\n childNodeFilteringIdentifiers.some(\n (identifier) =>\n HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&\n (!identifier.source || identifier.source === this._imodelAccess.imodelKey) &&\n identifier.id === definition.node.key,\n )\n ) {\n return {\n ...definition,\n node: {\n ...definition.node,\n ...filteringHelper.createChildNodeProps({ pathMatcher: ({ id }) => id === definition.node.key }),\n },\n };\n }\n return undefined;\n }),\n filter((def): def is GenericHierarchyNodeDefinition => !!def),\n ),\n\n instanceNodeDefinitions.pipe(\n mergeMap((definition) => {\n if (filteringHelper.hasFilterTargetAncestor) {\n // if we have a filter target ancestor, we don't need to filter the definitions - we use all of them\n return of(applyECInstanceIdsSelector(definition));\n }\n return defer(async () => {\n const imodelAccess = this._imodelAccess;\n const matches = new Map<Id64String, IModelInstanceKey[]>();\n async function getEntries(x: IModelInstanceKey) {\n let entries = matches.get(x.id);\n if (!entries) {\n entries = [];\n matches.set(x.id, entries);\n }\n // make sure that we don't have path identifiers that only differ by class name, where\n // class names are in the same class hierarchy, e.g.:\n // [{ className: \"bis.Element\", id: \"0x1\" }, { className: \"bis.Subject\", id: \"0x1\" }]\n // are actually the same instance, so we only need to keep one of them, or otherwise the query will\n // duplicate it\n for (const entry of entries) {\n if (\n entry.className === x.className ||\n (await imodelAccess.classDerivesFrom(entry.className, x.className)) ||\n (await imodelAccess.classDerivesFrom(x.className, entry.className))\n ) {\n return undefined;\n }\n }\n return entries;\n }\n for (const id of childNodeFilteringIdentifiers) {\n // take only identifiers that match the definition by type, source and class\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n continue;\n }\n if (id.imodelKey && id.imodelKey !== imodelAccess.imodelKey) {\n continue;\n }\n if (\n id.className !== definition.fullClassName &&\n !(await Promise.all([\n imodelAccess.classDerivesFrom(id.className, definition.fullClassName),\n imodelAccess.classDerivesFrom(definition.fullClassName, id.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo))\n ) {\n continue;\n }\n const entriesTargetForPathIdentifier = await getEntries(id);\n if (entriesTargetForPathIdentifier) {\n entriesTargetForPathIdentifier.push(id);\n }\n }\n return Array.from(matches.values()).flat();\n }).pipe(\n // only take definitions that have matching path identifiers\n filter((pathIdentifiers) => pathIdentifiers.length > 0),\n\n // for each definition that we're going to use, apply query-level filter\n map((pathIdentifiers) => applyECInstanceIdsFilter(definition, pathIdentifiers)),\n );\n }),\n ),\n ).pipe(toArray());\n }\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterECInstanceId = \"FilterECInstanceId\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterClassName = \"FilterClassName\";\n\nfunction getClassECInstanceIds(filteredInstanceKeys: InstanceKey[]) {\n const classNameECInstanceIds = new Map<string, Id64String[]>();\n for (const key of filteredInstanceKeys) {\n const entry = classNameECInstanceIds.get(key.className);\n if (entry === undefined) {\n classNameECInstanceIds.set(key.className, [key.id]);\n continue;\n }\n entry.push(key.id);\n }\n return classNameECInstanceIds;\n}\n\n/** @internal */\nexport function applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, filteredInstanceKeys: InstanceKey[]): InstanceNodesQueryDefinition {\n const instanceIdsByClass = getClassECInstanceIds(filteredInstanceKeys);\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n `FilteringInfo(ECInstanceId, FilterClassName) AS (\n ${Array.from(instanceIdsByClass)\n .map(\n ([className, ecInstanceIds]) => `\n SELECT ECInstanceId, '${className}' AS FilterClassName\n FROM ${className}\n WHERE ECInstanceId IN (${ecInstanceIds.join(\", \")})\n `,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n IdToHex([f].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_FilterECInstanceId}],\n [f].[FilterClassName] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n\n/** @internal */\nexport function applyECInstanceIdsSelector(def: InstanceNodesQueryDefinition): InstanceNodesQueryDefinition {\n return {\n ...def,\n query: {\n ...def.query,\n ecsql: `\n SELECT\n [q].*,\n IdToHex([q].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_FilterECInstanceId}],\n [q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (${def.query.ecsql}) [q]\n `,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"FilteringHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA+OhG,4DAgCC;AAGD,gEAcC;AA9RD,+BAAoG;AAGpG,oEAAiI;AACjI,8EAAwE;AACxE,gEAA6E;AAC7E,yFAMgD;AAChD,6EAA0G;AAC1G,mFAA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I,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjI,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,wBAAwB,CAC/B,UAAuD,EACvD,8BAAsC,EACtC,mBAA2B;IAE3B,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qFAAqF;IACrF,MAAM,SAAS,GAAG,kBAAkB,IAAI,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,8BAA8B,CAAC;IAC1G,MAAM,iBAAiB,GAAG,aAAa,IAAI,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC;IAC7G,OAAO,SAAS,GAAG,iBAAiB,CAAC;AACvC,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\nimport { defer, filter, from, map, merge, mergeAll, mergeMap, Observable, of, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { createHierarchyFilteringHelper, HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"../HierarchyFiltering.js\";\nimport { HierarchyNodeIdentifier } from \"../HierarchyNodeIdentifier.js\";\nimport { HierarchyNodeKey, IModelInstanceKey } from \"../HierarchyNodeKey.js\";\nimport {\n DefineHierarchyLevelProps,\n GenericHierarchyNodeDefinition,\n HierarchyLevelDefinition,\n HierarchyNodesDefinition,\n InstanceNodesQueryDefinition,\n} from \"../imodel/IModelHierarchyDefinition.js\";\nimport { ProcessedGroupingHierarchyNode, ProcessedHierarchyNode } from \"../imodel/IModelHierarchyNode.js\";\nimport { NodeSelectClauseColumnNames } from \"../imodel/NodeSelectQueryFactory.js\";\nimport { defaultNodesParser } from \"../imodel/TreeNodesReader.js\";\nimport { partition } from \"../internal/operators/Partition.js\";\nimport { RxjsHierarchyDefinition, RxjsNodeParser, RxjsNodePostProcessor, RxjsNodePreProcessor } from \"../internal/RxjsHierarchyDefinition.js\";\n\ninterface FilteringHierarchyDefinitionProps {\n imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n source: RxjsHierarchyDefinition;\n nodeIdentifierPaths: HierarchyFilteringPath[];\n nodesParser?: RxjsNodeParser;\n}\n\n/** @internal */\nexport class FilteringHierarchyDefinition implements RxjsHierarchyDefinition {\n private _imodelAccess: ECClassHierarchyInspector & { imodelKey: string };\n private _source: RxjsHierarchyDefinition;\n private _nodeIdentifierPaths: HierarchyFilteringPath[];\n private _nodesParser: RxjsNodeParser;\n\n public constructor(props: FilteringHierarchyDefinitionProps) {\n this._imodelAccess = props.imodelAccess;\n this._source = props.source;\n this._nodeIdentifierPaths = props.nodeIdentifierPaths;\n this._nodesParser = props.nodesParser ?? this._source.parseNode ?? ((row) => of(defaultNodesParser(row)));\n }\n\n public get preProcessNode(): RxjsNodePreProcessor {\n return (node) => {\n return (this._source.preProcessNode ? this._source.preProcessNode(node) : of(node)).pipe(\n filter((processedNode) => {\n if (processedNode.processingParams?.hideInHierarchy && processedNode.filtering?.isFilterTarget && !processedNode.filtering.hasFilterTargetAncestor) {\n // we want to hide target nodes if they have `hideInHierarchy` param, but only if they're not under another filter target\n return false;\n }\n return true;\n }),\n );\n };\n }\n\n public get postProcessNode(): RxjsNodePostProcessor {\n return (node) => {\n return (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(\n map((processedNode) => {\n // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing\n if (ProcessedHierarchyNode.isGroupingNode(node) && shouldExpandGroupingNode(node)) {\n Object.assign(processedNode, { autoExpand: true });\n }\n return processedNode;\n }),\n );\n };\n }\n\n public get parseNode(): RxjsNodeParser {\n return (row, parentNode) => {\n return this._nodesParser(row).pipe(\n mergeMap((parsedNode) => {\n if (!row[ECSQL_COLUMN_NAME_FilterECInstanceId] || !row[ECSQL_COLUMN_NAME_FilterClassName]) {\n return of(parsedNode);\n }\n const rowInstanceKey = { className: row[ECSQL_COLUMN_NAME_FilterClassName], id: row[ECSQL_COLUMN_NAME_FilterECInstanceId] };\n const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, parentNode);\n const nodeExtraPropsPossiblyPromise = filteringHelper.createChildNodePropsAsync({\n pathMatcher: (identifier): boolean | Promise<boolean> => {\n if (identifier.id !== rowInstanceKey.id) {\n return false;\n }\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(identifier)) {\n return false;\n }\n if (identifier.imodelKey && identifier.imodelKey !== this._imodelAccess.imodelKey) {\n return false;\n }\n if (identifier.className === rowInstanceKey.className) {\n return true;\n }\n return Promise.all([\n this._imodelAccess.classDerivesFrom(identifier.className, rowInstanceKey.className),\n this._imodelAccess.classDerivesFrom(rowInstanceKey.className, identifier.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo);\n },\n });\n return (nodeExtraPropsPossiblyPromise instanceof Promise ? from(nodeExtraPropsPossiblyPromise) : of(nodeExtraPropsPossiblyPromise)).pipe(\n map((nodeExtraProps) => {\n if (nodeExtraProps?.autoExpand) {\n parsedNode.autoExpand = true;\n }\n if (nodeExtraProps?.filtering) {\n parsedNode.filtering = nodeExtraProps.filtering;\n }\n return parsedNode;\n }),\n );\n }),\n );\n };\n }\n\n public defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition> {\n const sourceDefinitions = this._source.defineHierarchyLevel(props);\n\n const filteringHelper = createHierarchyFilteringHelper(this._nodeIdentifierPaths, props.parentNode);\n const childNodeFilteringIdentifiers = filteringHelper.getChildNodeFilteringIdentifiers();\n if (!childNodeFilteringIdentifiers) {\n return sourceDefinitions;\n }\n\n const [genericNodeDefinitions, instanceNodeDefinitions] = partition(sourceDefinitions.pipe(mergeAll()), HierarchyNodesDefinition.isGenericNode);\n return merge(\n genericNodeDefinitions.pipe(\n map((definition) => {\n if (\n filteringHelper.hasFilterTargetAncestor ||\n childNodeFilteringIdentifiers.some(\n (identifier) =>\n HierarchyNodeIdentifier.isGenericNodeIdentifier(identifier) &&\n (!identifier.source || identifier.source === this._imodelAccess.imodelKey) &&\n identifier.id === definition.node.key,\n )\n ) {\n return {\n ...definition,\n node: {\n ...definition.node,\n ...filteringHelper.createChildNodeProps({ pathMatcher: ({ id }) => id === definition.node.key }),\n },\n };\n }\n return undefined;\n }),\n filter((def): def is GenericHierarchyNodeDefinition => !!def),\n ),\n\n instanceNodeDefinitions.pipe(\n mergeMap((definition) => {\n if (filteringHelper.hasFilterTargetAncestor) {\n // if we have a filter target ancestor, we don't need to filter the definitions - we use all of them\n return of(applyECInstanceIdsSelector(definition));\n }\n return defer(async () => {\n const imodelAccess = this._imodelAccess;\n const matches = new Map<Id64String, IModelInstanceKey[]>();\n async function getEntries(x: IModelInstanceKey) {\n let entries = matches.get(x.id);\n if (!entries) {\n entries = [];\n matches.set(x.id, entries);\n }\n // make sure that we don't have path identifiers that only differ by class name, where\n // class names are in the same class hierarchy, e.g.:\n // [{ className: \"bis.Element\", id: \"0x1\" }, { className: \"bis.Subject\", id: \"0x1\" }]\n // are actually the same instance, so we only need to keep one of them, or otherwise the query will\n // duplicate it\n for (const entry of entries) {\n if (\n entry.className === x.className ||\n (await imodelAccess.classDerivesFrom(entry.className, x.className)) ||\n (await imodelAccess.classDerivesFrom(x.className, entry.className))\n ) {\n return undefined;\n }\n }\n return entries;\n }\n for (const id of childNodeFilteringIdentifiers) {\n // take only identifiers that match the definition by type, source and class\n if (!HierarchyNodeIdentifier.isInstanceNodeIdentifier(id)) {\n continue;\n }\n if (id.imodelKey && id.imodelKey !== imodelAccess.imodelKey) {\n continue;\n }\n if (\n id.className !== definition.fullClassName &&\n !(await Promise.all([\n imodelAccess.classDerivesFrom(id.className, definition.fullClassName),\n imodelAccess.classDerivesFrom(definition.fullClassName, id.className),\n ]).then(([isDerivedFrom, isDerivedTo]) => isDerivedFrom || isDerivedTo))\n ) {\n continue;\n }\n const entriesTargetForPathIdentifier = await getEntries(id);\n if (entriesTargetForPathIdentifier) {\n entriesTargetForPathIdentifier.push(id);\n }\n }\n return Array.from(matches.values()).flat();\n }).pipe(\n // only take definitions that have matching path identifiers\n filter((pathIdentifiers) => pathIdentifiers.length > 0),\n\n // for each definition that we're going to use, apply query-level filter\n map((pathIdentifiers) => applyECInstanceIdsFilter(definition, pathIdentifiers)),\n );\n }),\n ),\n ).pipe(toArray());\n }\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterECInstanceId = \"FilterECInstanceId\";\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const ECSQL_COLUMN_NAME_FilterClassName = \"FilterClassName\";\n\nfunction getClassECInstanceIds(filteredInstanceKeys: InstanceKey[]) {\n const classNameECInstanceIds = new Map<string, Id64String[]>();\n for (const key of filteredInstanceKeys) {\n const entry = classNameECInstanceIds.get(key.className);\n if (entry === undefined) {\n classNameECInstanceIds.set(key.className, [key.id]);\n continue;\n }\n entry.push(key.id);\n }\n return classNameECInstanceIds;\n}\n\n/** @internal */\nexport function applyECInstanceIdsFilter(def: InstanceNodesQueryDefinition, filteredInstanceKeys: InstanceKey[]): InstanceNodesQueryDefinition {\n const instanceIdsByClass = getClassECInstanceIds(filteredInstanceKeys);\n return {\n ...def,\n query: {\n ...def.query,\n ctes: [\n ...(def.query.ctes ?? []),\n `FilteringInfo(ECInstanceId, FilterClassName) AS (\n ${Array.from(instanceIdsByClass)\n .map(\n ([className, ecInstanceIds]) => `\n SELECT ECInstanceId, '${className}' AS FilterClassName\n FROM ${className}\n WHERE ECInstanceId IN (${ecInstanceIds.join(\", \")})\n `,\n )\n .join(\" UNION ALL \")}\n )`,\n ],\n ecsql: `\n SELECT\n [q].*,\n IdToHex([f].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_FilterECInstanceId}],\n [f].[FilterClassName] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (\n ${def.query.ecsql}\n ) [q]\n JOIN FilteringInfo [f] ON [f].[ECInstanceId] = [q].[ECInstanceId]\n `,\n },\n };\n}\n\n/** @internal */\nexport function applyECInstanceIdsSelector(def: InstanceNodesQueryDefinition): InstanceNodesQueryDefinition {\n return {\n ...def,\n query: {\n ...def.query,\n ecsql: `\n SELECT\n [q].*,\n IdToHex([q].[ECInstanceId]) AS [${ECSQL_COLUMN_NAME_FilterECInstanceId}],\n [q].[${NodeSelectClauseColumnNames.FullClassName}] AS [${ECSQL_COLUMN_NAME_FilterClassName}]\n FROM (${def.query.ecsql}) [q]\n `,\n },\n };\n}\n\nfunction shouldExpandGroupingNode(node: ProcessedGroupingHierarchyNode) {\n const numberOfNonGroupingParentNodes = node.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n for (const child of node.children) {\n /* c8 ignore next 3 */\n if (!child.filtering) {\n continue;\n }\n\n if (\n child.filtering.isFilterTarget &&\n getAutoExpandAsTrueFalse(child.filtering.filterTargetOptions?.autoExpand, numberOfNonGroupingParentNodes, node.parentKeys.length)\n ) {\n return true;\n }\n\n if (!child.filtering.filteredChildrenIdentifierPaths) {\n /* c8 ignore next */\n continue;\n }\n\n for (const path of child.filtering.filteredChildrenIdentifierPaths) {\n if (\"path\" in path && getAutoExpandAsTrueFalse(path.options?.autoExpand, numberOfNonGroupingParentNodes, node.parentKeys.length)) {\n return true;\n }\n }\n }\n return false;\n}\n\nfunction getAutoExpandAsTrueFalse(\n autoExpand: HierarchyFilteringPathOptions[\"autoExpand\"],\n numberOfNonGroupingParentNodes: number,\n numberOfParentNodes: number,\n): boolean {\n if (!autoExpand) {\n return false;\n }\n if (autoExpand === true) {\n return true;\n }\n\n // auto-expand should be set to true only if parentKeys length is smaller than depth.\n const nodeDepth = \"depthInHierarchy\" in autoExpand ? numberOfParentNodes : numberOfNonGroupingParentNodes;\n const filterTargetDepth = \"depthInPath\" in autoExpand ? autoExpand.depthInPath : autoExpand.depthInHierarchy;\n return nodeDepth < filterTargetDepth;\n}\n"]}
@@ -2,19 +2,24 @@ import { HierarchyNode, NonGroupingHierarchyNode } from "./HierarchyNode.js";
2
2
  import { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier.js";
3
3
  import { GenericNodeKey, InstancesNodeKey } from "./HierarchyNodeKey.js";
4
4
  /** @public */
5
- export interface FilteringPathAutoExpandOption {
5
+ export interface FilteringPathAutoExpandDepthInPath {
6
6
  /**
7
- * Depth up to which nodes in the hierarchy should be expanded.
7
+ * Depth that tells which nodes in the filtering path should be expanded.
8
8
  *
9
- * If `includeGroupingNodes` is set to true, then depth should take into account the number of grouping nodes in hierarchy.
9
+ * Use when you want to expand up to specific instance node and don't care about grouping nodes.
10
+ *
11
+ * **NOTE**: All nodes that are up to `depthInPath` will be expanded. Node at the `depthInPath` position won't be expanded.
10
12
  */
11
- depth: number;
13
+ depthInPath: number;
14
+ }
15
+ /** @public */
16
+ export interface FilteringPathAutoExpandDepthInHierarchy {
12
17
  /**
13
- * Whether or not `depth` includes grouping nodes.
18
+ * Depth that tells which nodes in the hierarchy should be expanded.
14
19
  *
15
- * Use when you want to autoExpand only some of the grouping nodes.
20
+ * This should take into account the number of grouping nodes in hierarchy.
16
21
  *
17
- * **Use case example:**
22
+ * * **Use case example:**
18
23
  *
19
24
  * You want to `autoExpand` only `Node1` and `GroupingNode1` in the following hierarchy:
20
25
  * - Node1
@@ -22,9 +27,13 @@ export interface FilteringPathAutoExpandOption {
22
27
  * - GroupingNode2
23
28
  * - Element1
24
29
  * - Element2
25
- * Then you provide `autoExpand: { depth: 2, includeGroupingNodes: true }`
30
+ * Then you provide `autoExpand: { depthInHierarchy: 2 }`
31
+ *
32
+ * To get the correct depth use `HierarchyNode.parentKeys.length`.
33
+ *
34
+ * **NOTE**: All nodes that are up to and including `depthInHierarchy` will be expanded.
26
35
  */
27
- includeGroupingNodes?: boolean;
36
+ depthInHierarchy: number;
28
37
  }
29
38
  /** @public */
30
39
  export interface HierarchyFilteringPathOptions {
@@ -32,9 +41,10 @@ export interface HierarchyFilteringPathOptions {
32
41
  * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.
33
42
  * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.
34
43
  * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.
35
- * - If it's an instance of `FilteringPathAutoExpandOption`, then all nodes up to and including `depth` will have `autoExpand` flag.
44
+ * - If it's an instance of `FilteringPathAutoExpandDepthInPath`, then all nodes up to `depthInPath` will have `autoExpand` flag.
45
+ * - If it's an instance of `FilteringPathAutoExpandDepthInHierarchy`, then all nodes up to and including `depthInHierarchy` will have `autoExpand` flag.
36
46
  */
37
- autoExpand?: boolean | FilteringPathAutoExpandOption;
47
+ autoExpand?: boolean | FilteringPathAutoExpandDepthInHierarchy | FilteringPathAutoExpandDepthInPath;
38
48
  }
39
49
  /**
40
50
  * A path of hierarchy node identifiers for filtering the hierarchy with additional options.
@@ -62,8 +72,8 @@ export declare namespace HierarchyFilteringPath {
62
72
  * - else if only one of the inputs is an object, return it,
63
73
  * - else if both inputs are falsy, return `false` or `undefined`,
64
74
  * - else:
65
- * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined, return the one that has only `depth` set,
66
- * - else return the one with greater `depth`.
75
+ * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined or `depthInHierarchy` set, return the other one,
76
+ * - else return the one with greater `depth`, `depthInPath` or `depthInHierarchy`.
67
77
  *
68
78
  * @public
69
79
  */
@@ -85,7 +95,7 @@ export declare function extractFilteringProps(rootLevelFilteringProps: Hierarchy
85
95
  *
86
96
  * @public
87
97
  */
88
- export declare function createHierarchyFilteringHelper(rootLevelFilteringProps: HierarchyFilteringPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "filtering"> | undefined): {
98
+ export declare function createHierarchyFilteringHelper(rootLevelFilteringProps: HierarchyFilteringPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "filtering" | "parentKeys"> | undefined): {
89
99
  /**
90
100
  * Returns a flag indicating if the hierarchy level is filtered.
91
101
  */
@@ -115,19 +125,12 @@ export declare function createHierarchyFilteringHelper(rootLevelFilteringProps:
115
125
  nodeKey: InstancesNodeKey | GenericNodeKey;
116
126
  } | {
117
127
  pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
118
- }) => NodeProps | undefined;
128
+ }) => Pick<HierarchyNode, "autoExpand" | "filtering"> | undefined;
119
129
  /**
120
130
  * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
121
131
  */
122
132
  createChildNodePropsAsync: (props: {
123
133
  pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
124
- }) => Promise<NodeProps | undefined> | NodeProps | undefined;
125
- };
126
- /** @public */
127
- export type NodeProps = Pick<HierarchyNode, "autoExpand" | "filtering"> & {
128
- filtering?: {
129
- autoExpandDepth?: number;
130
- includeGroupingNodes?: boolean;
131
- };
134
+ }) => Promise<Pick<HierarchyNode, "autoExpand" | "filtering"> | undefined> | Pick<HierarchyNode, "autoExpand" | "filtering"> | undefined;
132
135
  };
133
136
  //# sourceMappingURL=HierarchyFiltering.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyFiltering.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAE,cAAc,EAAoB,g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KAAG,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,CAAC,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,CAAC,GAAG,SAAS;EAgCzI"}
@@ -13,16 +13,20 @@ var HierarchyFilteringPathOptions;
13
13
  if (!rhs || !lhs) {
14
14
  return !!rhs ? rhs : lhs;
15
15
  }
16
- if (!lhs.includeGroupingNodes) {
17
- if (!rhs.includeGroupingNodes) {
18
- return lhs.depth > rhs.depth ? lhs : rhs;
16
+ const lhsDepth = "depthInPath" in lhs ? lhs.depthInPath : lhs.depthInHierarchy;
17
+ const rhsDepth = "depthInPath" in rhs ? rhs.depthInPath : rhs.depthInHierarchy;
18
+ const isLhsDepthBasedOnPath = "depthInPath" in lhs;
19
+ const isRhsDepthBasedOnPath = "depthInPath" in rhs;
20
+ if (isLhsDepthBasedOnPath) {
21
+ if (isRhsDepthBasedOnPath) {
22
+ return lhsDepth > rhsDepth ? lhs : rhs;
19
23
  }
20
24
  return lhs;
21
25
  }
22
- if (!rhs.includeGroupingNodes) {
26
+ if (isRhsDepthBasedOnPath) {
23
27
  return rhs;
24
28
  }
25
- return lhs.depth > rhs.depth ? lhs : rhs;
29
+ return lhsDepth > rhsDepth ? lhs : rhs;
26
30
  }
27
31
  HierarchyFilteringPathOptions.mergeAutoExpandOptions = mergeAutoExpandOptions;
28
32
  })(HierarchyFilteringPathOptions || (HierarchyFilteringPathOptions = {}));
@@ -52,8 +56,8 @@ export var HierarchyFilteringPath;
52
56
  * - else if only one of the inputs is an object, return it,
53
57
  * - else if both inputs are falsy, return `false` or `undefined`,
54
58
  * - else:
55
- * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined, return the one that has only `depth` set,
56
- * - else return the one with greater `depth`.
59
+ * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined or `depthInHierarchy` set, return the other one,
60
+ * - else return the one with greater `depth`, `depthInPath` or `depthInHierarchy`.
57
61
  *
58
62
  * @public
59
63
  */
@@ -148,7 +152,7 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
148
152
  reducer.accept(normalizedPath);
149
153
  }
150
154
  });
151
- return reducer.getNodeProps();
155
+ return reducer.getNodeProps(parentNode);
152
156
  },
153
157
  /**
154
158
  * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
@@ -176,11 +180,11 @@ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNo
176
180
  reducer.accept(normalizedPath);
177
181
  }
178
182
  if (matchedPathPromises.length === 0) {
179
- return reducer.getNodeProps();
183
+ return reducer.getNodeProps(parentNode);
180
184
  }
181
185
  return Promise.all(matchedPathPromises)
182
186
  .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))
183
- .then(() => reducer.getNodeProps());
187
+ .then(() => reducer.getNodeProps(parentNode));
184
188
  },
185
189
  };
186
190
  }
@@ -189,21 +193,40 @@ class MatchingFilteringPathsReducer {
189
193
  _filteredChildrenIdentifierPaths = new Array();
190
194
  _isFilterTarget = false;
191
195
  _filterTargetOptions = undefined;
192
- _needsAutoExpand = false;
196
+ _autoExpandOption = false;
193
197
  constructor(_hasFilterTargetAncestor) {
194
198
  this._hasFilterTargetAncestor = _hasFilterTargetAncestor;
195
199
  }
196
- accept({ path, options }) {
200
+ accept(normalizedPath) {
201
+ const { path, options } = normalizedPath;
197
202
  if (path.length === 1) {
198
203
  this._isFilterTarget = true;
199
204
  this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);
200
205
  }
201
206
  else if (path.length > 1) {
202
207
  this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });
203
- this._needsAutoExpand = HierarchyFilteringPathOptions.mergeAutoExpandOptions(options?.autoExpand, this._needsAutoExpand);
208
+ this._autoExpandOption = HierarchyFilteringPathOptions.mergeAutoExpandOptions(options?.autoExpand, this._autoExpandOption);
204
209
  }
205
210
  }
206
- getNodeProps() {
211
+ getNeedsAutoExpand(parentNode) {
212
+ if (this._autoExpandOption === true) {
213
+ return true;
214
+ }
215
+ if (typeof this._autoExpandOption === "object") {
216
+ const parentLength = !parentNode
217
+ ? 0
218
+ : "depthInHierarchy" in this._autoExpandOption
219
+ ? 1 + parentNode.parentKeys.length
220
+ : 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;
221
+ const depth = "depthInHierarchy" in this._autoExpandOption
222
+ ? this._autoExpandOption.depthInHierarchy
223
+ : // With `depthInPath` option we don't want to expand node that is at the `depthInPath` position
224
+ this._autoExpandOption.depthInPath - 1;
225
+ return parentLength < depth;
226
+ }
227
+ return false;
228
+ }
229
+ getNodeProps(parentNode) {
207
230
  return {
208
231
  ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0
209
232
  ? {
@@ -211,16 +234,10 @@ class MatchingFilteringPathsReducer {
211
234
  ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),
212
235
  ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),
213
236
  ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),
214
- ...(this._needsAutoExpand && this._needsAutoExpand !== true
215
- ? {
216
- autoExpandDepth: this._needsAutoExpand.depth,
217
- includeGroupingNodes: this._needsAutoExpand.includeGroupingNodes ? true : false,
218
- }
219
- : undefined),
220
237
  },
221
238
  }
222
239
  : undefined),
223
- ...(this._needsAutoExpand ? { autoExpand: !!this._needsAutoExpand } : undefined),
240
+ ...(this.getNeedsAutoExpand(parentNode) ? { autoExpand: true } : undefined),
224
241
  };
225
242
  }
226
243
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,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C,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SACjF,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\nimport { HierarchyNode, NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilteringPathAutoExpandOption {\n /**\n * Depth up to which nodes in the hierarchy should be expanded.\n *\n * If `includeGroupingNodes` is set to true, then depth should take into account the number of grouping nodes in hierarchy.\n */\n depth: number;\n /**\n * Whether or not `depth` includes grouping nodes.\n *\n * Use when you want to autoExpand only some of the grouping nodes.\n *\n * **Use case example:**\n *\n * You want to `autoExpand` only `Node1` and `GroupingNode1` in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n * Then you provide `autoExpand: { depth: 2, includeGroupingNodes: true }`\n */\n includeGroupingNodes?: boolean;\n}\n\n/** @public */\nexport interface HierarchyFilteringPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathAutoExpandOption`, then all nodes up to and including `depth` will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilteringPathAutoExpandOption;\n}\n\nnamespace HierarchyFilteringPathOptions {\n export function mergeAutoExpandOptions(\n lhs: HierarchyFilteringPathOptions[\"autoExpand\"],\n rhs: HierarchyFilteringPathOptions[\"autoExpand\"],\n ): HierarchyFilteringPathOptions[\"autoExpand\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n if (!lhs.includeGroupingNodes) {\n if (!rhs.includeGroupingNodes) {\n return lhs.depth > rhs.depth ? lhs : rhs;\n }\n return lhs;\n }\n if (!rhs.includeGroupingNodes) {\n return rhs;\n }\n return lhs.depth > rhs.depth ? lhs : rhs;\n }\n}\n\n/**\n * A path of hierarchy node identifiers for filtering the hierarchy with additional options.\n * @public\n */\nexport type HierarchyFilteringPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchyFilteringPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyFilteringPath {\n /**\n * Normalizes the hierarchy filtering path to the object form.\n * @public\n */\n export function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchyFilteringPathOptions` objects.\n * - if both inputs are `undefined`, `undefined` is returned,\n * - else if one of the inputs is `undefined`, the other one is returned.\n * - else, merge each option individually.\n *\n * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if only one of the inputs is an object, return it,\n * - else if both inputs are falsy, return `false` or `undefined`,\n * - else:\n * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined, return the one that has only `depth` set,\n * - else return the one with greater `depth`.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchyFilteringPathOptions | undefined,\n rhs: HierarchyFilteringPathOptions | undefined,\n ): HierarchyFilteringPathOptions | undefined {\n if (!lhs || !rhs) {\n return lhs ?? rhs;\n }\n\n return {\n autoExpand: HierarchyFilteringPathOptions.mergeAutoExpandOptions(lhs.autoExpand, rhs.autoExpand),\n };\n }\n}\n\n/**\n * An utility that extracts filtering properties from given root level filtering props or\n * the parent node. Returns `undefined` if filtering props are not present.\n * @public\n * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.\n */\n/* c8 ignore start */\nexport function extractFilteringProps(\n rootLevelFilteringProps: HierarchyFilteringPath[],\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n}\n/* c8 ignore end */\n\nfunction extractFilteringPropsInternal(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;\n }\n return parentNode.filtering?.filteredChildrenIdentifierPaths\n ? {\n filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths,\n hasFilterTargetAncestor: !!parentNode.filtering.hasFilterTargetAncestor || !!parentNode.filtering.isFilterTarget,\n }\n : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to filter the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchyFilteringHelper(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n) {\n const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n const hasFilter = !!filteringProps;\n return {\n /**\n * Returns a flag indicating if the hierarchy level is filtered.\n */\n hasFilter,\n\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a filter target. That generally means that this and all downstream hierarchy\n * levels should be displayed without filter being applied to them, even if filter paths\n * say otherwise.\n */\n hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,\n\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if filtering is not applied to this level.\n */\n getChildNodeFilteringIdentifiers: () => {\n if (!hasFilter) {\n return undefined;\n }\n return filteringProps.filteredNodePaths\n .map(HierarchyFilteringPath.normalize)\n .filter(({ path }) => path.length > 0)\n .map(({ path }) => path[0]);\n },\n\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`\n * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies\n * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the\n * `nodeKey` prop can be used to check the whole identifier.\n */\n createChildNodeProps: (\n props:\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n },\n ): NodeProps | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n filteringProps.filteredNodePaths.forEach((filteredPath) => {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);\n if (\n \"nodeKey\" in props &&\n ((HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||\n (HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))\n ) {\n reducer.accept(normalizedPath);\n } else if (\"pathMatcher\" in props && props.pathMatcher(normalizedPath.path[0])) {\n reducer.accept(normalizedPath);\n }\n });\n return reducer.getNodeProps();\n },\n\n /**\n * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.\n */\n createChildNodePropsAsync: (props: {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<NodeProps | undefined> | NodeProps | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n const matchedPathPromises = new Array<Promise<NormalizedFilteringPath | undefined>>();\n for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);\n /* c8 ignore next 3 */\n if (normalizedPath.path.length === 0) {\n continue;\n }\n\n const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));\n continue;\n }\n if (!matchesPossiblyPromise) {\n continue;\n }\n\n reducer.accept(normalizedPath);\n }\n if (matchedPathPromises.length === 0) {\n return reducer.getNodeProps();\n }\n return Promise.all(matchedPathPromises)\n .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))\n .then(() => reducer.getNodeProps());\n },\n };\n}\n\n/** @public */\nexport type NodeProps = Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> & { filtering?: { autoExpandDepth?: number; includeGroupingNodes?: boolean } };\n\ntype NormalizedFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\n\nclass MatchingFilteringPathsReducer {\n private _filteredChildrenIdentifierPaths = new Array<NormalizedFilteringPath>();\n private _isFilterTarget = false;\n private _filterTargetOptions = undefined as HierarchyFilteringPathOptions | undefined;\n private _needsAutoExpand: HierarchyFilteringPathOptions[\"autoExpand\"] = false;\n\n public constructor(private _hasFilterTargetAncestor: boolean) {}\n\n public accept({ path, options }: NormalizedFilteringPath) {\n if (path.length === 1) {\n this._isFilterTarget = true;\n this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);\n } else if (path.length > 1) {\n this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });\n this._needsAutoExpand = HierarchyFilteringPathOptions.mergeAutoExpandOptions(options?.autoExpand, this._needsAutoExpand);\n }\n }\n public getNodeProps(): NodeProps {\n return {\n ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0\n ? {\n filtering: {\n ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),\n ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),\n ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),\n ...(this._needsAutoExpand && this._needsAutoExpand !== true\n ? {\n autoExpandDepth: this._needsAutoExpand.depth,\n includeGroupingNodes: this._needsAutoExpand.includeGroupingNodes ? true : false,\n }\n : undefined),\n },\n }\n : undefined),\n ...(this._needsAutoExpand ? { autoExpand: !!this._needsAutoExpand } : undefined),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,uBAAuB,EAAgC,MAAM,8BAA8B,CAAC;AACrG,OAAO,EAAkB,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAkD3F,IAAU,6BAA6B,CA4BtC;AA5BD,WAAU,6BAA6B;IACrC,SAAgB,sBAAsB,CACpC,GAAgD,EAChD,GAAgD;QAEhD,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC3B,CAAC;QAED,MAAM,QAAQ,GAAG,aAAa,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAA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CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;wBAChH,GAAG,CAAC,IAAI,CAAC,gCAAgC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,+BAA+B,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;qBAC/I;iBACF;gBACH,CAAC,CAAC,SAAS,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC5E,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\nimport { HierarchyNode, NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GenericNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilteringPathAutoExpandDepthInPath {\n /**\n * Depth that tells which nodes in the filtering path should be expanded.\n *\n * Use when you want to expand up to specific instance node and don't care about grouping nodes.\n *\n * **NOTE**: All nodes that are up to `depthInPath` will be expanded. Node at the `depthInPath` position won't be expanded.\n */\n depthInPath: number;\n}\n\n/** @public */\nexport interface FilteringPathAutoExpandDepthInHierarchy {\n /**\n * Depth that tells which nodes in the hierarchy should be expanded.\n *\n * This should take into account the number of grouping nodes in hierarchy.\n *\n * * **Use case example:**\n *\n * You want to `autoExpand` only `Node1` and `GroupingNode1` in the following hierarchy:\n * - Node1\n * - GroupingNode1\n * - GroupingNode2\n * - Element1\n * - Element2\n * Then you provide `autoExpand: { depthInHierarchy: 2 }`\n *\n * To get the correct depth use `HierarchyNode.parentKeys.length`.\n *\n * **NOTE**: All nodes that are up to and including `depthInHierarchy` will be expanded.\n */\n depthInHierarchy: number;\n}\n\n/** @public */\nexport interface HierarchyFilteringPathOptions {\n /**\n * This option specifies the way `autoExpand` flag should be assigned to nodes in the filtered hierarchy.\n * - If it's `false` or `undefined`, nodes have no 'autoExpand' flag.\n * - If it's `true`, then all nodes up to the filter target will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathAutoExpandDepthInPath`, then all nodes up to `depthInPath` will have `autoExpand` flag.\n * - If it's an instance of `FilteringPathAutoExpandDepthInHierarchy`, then all nodes up to and including `depthInHierarchy` will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilteringPathAutoExpandDepthInHierarchy | FilteringPathAutoExpandDepthInPath;\n}\n\nnamespace HierarchyFilteringPathOptions {\n export function mergeAutoExpandOptions(\n lhs: HierarchyFilteringPathOptions[\"autoExpand\"],\n rhs: HierarchyFilteringPathOptions[\"autoExpand\"],\n ): HierarchyFilteringPathOptions[\"autoExpand\"] {\n if (rhs === true || lhs === true) {\n return true;\n }\n if (!rhs || !lhs) {\n return !!rhs ? rhs : lhs;\n }\n\n const lhsDepth = \"depthInPath\" in lhs ? lhs.depthInPath : lhs.depthInHierarchy;\n const rhsDepth = \"depthInPath\" in rhs ? rhs.depthInPath : rhs.depthInHierarchy;\n const isLhsDepthBasedOnPath = \"depthInPath\" in lhs;\n const isRhsDepthBasedOnPath = \"depthInPath\" in rhs;\n\n if (isLhsDepthBasedOnPath) {\n if (isRhsDepthBasedOnPath) {\n return lhsDepth > rhsDepth ? lhs : rhs;\n }\n return lhs;\n }\n if (isRhsDepthBasedOnPath) {\n return rhs;\n }\n return lhsDepth > rhsDepth ? lhs : rhs;\n }\n}\n\n/**\n * A path of hierarchy node identifiers for filtering the hierarchy with additional options.\n * @public\n */\nexport type HierarchyFilteringPath = HierarchyNodeIdentifiersPath | { path: HierarchyNodeIdentifiersPath; options?: HierarchyFilteringPathOptions };\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyFilteringPath {\n /**\n * Normalizes the hierarchy filtering path to the object form.\n * @public\n */\n export function normalize(source: HierarchyFilteringPath): Exclude<HierarchyFilteringPath, HierarchyNodeIdentifiersPath> {\n if (Array.isArray(source)) {\n return { path: source };\n }\n return source;\n }\n\n /**\n * Merges two given `HierarchyFilteringPathOptions` objects.\n * - if both inputs are `undefined`, `undefined` is returned,\n * - else if one of the inputs is `undefined`, the other one is returned.\n * - else, merge each option individually.\n *\n * For the `autoExpand` attribute, the merge chooses to auto-expand as deep as the deepest input:\n * - if any one of the inputs is `true`, return `true`,\n * - else if only one of the inputs is an object, return it,\n * - else if both inputs are falsy, return `false` or `undefined`,\n * - else:\n * - if only one of the inputs has `includeGroupingNodes` set to `true` or `key` defined or `depthInHierarchy` set, return the other one,\n * - else return the one with greater `depth`, `depthInPath` or `depthInHierarchy`.\n *\n * @public\n */\n export function mergeOptions(\n lhs: HierarchyFilteringPathOptions | undefined,\n rhs: HierarchyFilteringPathOptions | undefined,\n ): HierarchyFilteringPathOptions | undefined {\n if (!lhs || !rhs) {\n return lhs ?? rhs;\n }\n\n return {\n autoExpand: HierarchyFilteringPathOptions.mergeAutoExpandOptions(lhs.autoExpand, rhs.autoExpand),\n };\n }\n}\n\n/**\n * An utility that extracts filtering properties from given root level filtering props or\n * the parent node. Returns `undefined` if filtering props are not present.\n * @public\n * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.\n */\n/* c8 ignore start */\nexport function extractFilteringProps(\n rootLevelFilteringProps: HierarchyFilteringPath[],\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n}\n/* c8 ignore end */\n\nfunction extractFilteringPropsInternal(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;\n }\n return parentNode.filtering?.filteredChildrenIdentifierPaths\n ? {\n filteredNodePaths: parentNode.filtering.filteredChildrenIdentifierPaths,\n hasFilterTargetAncestor: !!parentNode.filtering.hasFilterTargetAncestor || !!parentNode.filtering.isFilterTarget,\n }\n : undefined;\n}\n\n/**\n * Creates a set of utilities for making it easier to filter the given hierarchy\n * level.\n *\n * @public\n */\nexport function createHierarchyFilteringHelper(\n rootLevelFilteringProps: HierarchyFilteringPath[] | undefined,\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\" | \"parentKeys\"> | undefined,\n) {\n const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);\n const hasFilter = !!filteringProps;\n return {\n /**\n * Returns a flag indicating if the hierarchy level is filtered.\n */\n hasFilter,\n\n /**\n * Returns a flag indicating whether this hierarchy level has an ancestor node\n * that is a filter target. That generally means that this and all downstream hierarchy\n * levels should be displayed without filter being applied to them, even if filter paths\n * say otherwise.\n */\n hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,\n\n /**\n * Returns a list of hierarchy node identifiers that apply specifically for this\n * hierarchy level. Returns `undefined` if filtering is not applied to this level.\n */\n getChildNodeFilteringIdentifiers: () => {\n if (!hasFilter) {\n return undefined;\n }\n return filteringProps.filteredNodePaths\n .map(HierarchyFilteringPath.normalize)\n .filter(({ path }) => path.length > 0)\n .map(({ path }) => path[0]);\n },\n\n /**\n * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`\n * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates\n * these props for a child node based on its key or path matcher.\n *\n * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies\n * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the\n * `nodeKey` prop can be used to check the whole identifier.\n */\n createChildNodeProps: (\n props:\n | {\n nodeKey: InstancesNodeKey | GenericNodeKey;\n }\n | {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;\n },\n ): Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n filteringProps.filteredNodePaths.forEach((filteredPath) => {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);\n if (\n \"nodeKey\" in props &&\n ((HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||\n (HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))\n ) {\n reducer.accept(normalizedPath);\n } else if (\"pathMatcher\" in props && props.pathMatcher(normalizedPath.path[0])) {\n reducer.accept(normalizedPath);\n }\n });\n return reducer.getNodeProps(parentNode);\n },\n\n /**\n * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.\n */\n createChildNodePropsAsync: (props: {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> | undefined> | Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> | undefined => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\n const matchedPathPromises = new Array<Promise<NormalizedFilteringPath | undefined>>();\n for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {\n const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);\n /* c8 ignore next 3 */\n if (normalizedPath.path.length === 0) {\n continue;\n }\n\n const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);\n if (matchesPossiblyPromise instanceof Promise) {\n matchedPathPromises.push(matchesPossiblyPromise.then((matches) => (matches ? normalizedPath : undefined)));\n continue;\n }\n if (!matchesPossiblyPromise) {\n continue;\n }\n\n reducer.accept(normalizedPath);\n }\n if (matchedPathPromises.length === 0) {\n return reducer.getNodeProps(parentNode);\n }\n return Promise.all(matchedPathPromises)\n .then((matchedPath) => matchedPath.forEach((normalizedPath) => normalizedPath && reducer.accept(normalizedPath)))\n .then(() => reducer.getNodeProps(parentNode));\n },\n };\n}\n\ntype NormalizedFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\n\nclass MatchingFilteringPathsReducer {\n private _filteredChildrenIdentifierPaths = new Array<NormalizedFilteringPath>();\n private _isFilterTarget = false;\n private _filterTargetOptions = undefined as HierarchyFilteringPathOptions | undefined;\n private _autoExpandOption: HierarchyFilteringPathOptions[\"autoExpand\"] = false;\n\n public constructor(private _hasFilterTargetAncestor: boolean) {}\n\n public accept(normalizedPath: NormalizedFilteringPath): void {\n const { path, options } = normalizedPath;\n if (path.length === 1) {\n this._isFilterTarget = true;\n this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);\n } else if (path.length > 1) {\n this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });\n this._autoExpandOption = HierarchyFilteringPathOptions.mergeAutoExpandOptions(options?.autoExpand, this._autoExpandOption);\n }\n }\n\n private getNeedsAutoExpand(parentNode: Pick<NonGroupingHierarchyNode, \"parentKeys\"> | undefined): boolean {\n if (this._autoExpandOption === true) {\n return true;\n }\n if (typeof this._autoExpandOption === \"object\") {\n const parentLength = !parentNode\n ? 0\n : \"depthInHierarchy\" in this._autoExpandOption\n ? 1 + parentNode.parentKeys.length\n : 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;\n const depth =\n \"depthInHierarchy\" in this._autoExpandOption\n ? this._autoExpandOption.depthInHierarchy\n : // With `depthInPath` option we don't want to expand node that is at the `depthInPath` position\n this._autoExpandOption.depthInPath - 1;\n\n return parentLength < depth;\n }\n return false;\n }\n\n public getNodeProps(parentNode: Pick<NonGroupingHierarchyNode, \"parentKeys\"> | undefined): Pick<HierarchyNode, \"autoExpand\" | \"filtering\"> {\n return {\n ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0\n ? {\n filtering: {\n ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),\n ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),\n ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),\n },\n }\n : undefined),\n ...(this.getNeedsAutoExpand(parentNode) ? { autoExpand: true } : undefined),\n };\n }\n}\n"]}
@@ -19,7 +19,6 @@ export declare class FilteringHierarchyDefinition implements RxjsHierarchyDefini
19
19
  private _nodesParser;
20
20
  constructor(props: FilteringHierarchyDefinitionProps);
21
21
  get preProcessNode(): RxjsNodePreProcessor;
22
- private shouldExpandGroupingNode;
23
22
  get postProcessNode(): RxjsNodePostProcessor;
24
23
  get parseNode(): RxjsNodeParser;
25
24
  defineHierarchyLevel(props: DefineHierarchyLevelProps): Observable<HierarchyLevelDefinition>;
@@ -1 +1 @@
1
- {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuD,UAAU,EAAe,MAAM,MAAM,CAAC;AAEpG,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EAAkC,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlG,OAAO,EACL,yBAAyB,EAEzB,wBAAwB,EAExB,4BAA4B,EAC7B,MAAM,wCAAwC,CAAC;AAKhD,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9I,UAAU,iCAAiC;IACzC,YAAY,EAAE,yBAAyB,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,MAAM,EAAE,uBAAuB,CAAC;IAChC,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;IAC9C,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,gBAAgB;AAChB,qBAAa,4BAA6B,YAAW,uBAAuB;IAC1E,OAAO,CAAC,aAAa,CAAoD;IACzE,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,oBAAoB,CAA2B;IACvD,OAAO,CAAC,YAAY,CAAiB;gBAElB,KAAK,EAAE,iCAAiC;IAO3D,IAAW,cAAc,IAAI,oBAAoB,CAYhD;IAED,OAAO,CAAC,wBAAwB;IA6ChC,IAAW,eAAe,IAAI,qBAAqB,CAYlD;IAED,IAAW,SAAS,IAAI,cAAc,CAiDrC;IAEM,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,UAAU,CAAC,wBAAwB,CAAC;CAoGpG;AAED,gBAAgB;AAEhB,eAAO,MAAM,oCAAoC,uBAAuB,CAAC;AAEzE,gBAAgB;AAEhB,eAAO,MAAM,iCAAiC,oBAAoB,CAAC;AAenE,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,WAAW,EAAE,GAAG,4BAA4B,CAgC7I;AAED,gBAAgB;AAChB,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,4BAA4B,GAAG,4BAA4B,CAc1G"}
1
+ {"version":3,"file":"FilteringHierarchyDefinition.d.ts","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/FilteringHierarchyDefinition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuD,UAAU,EAAe,MAAM,MA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AA4B,CAc1G"}
@@ -34,49 +34,11 @@ export class FilteringHierarchyDefinition {
34
34
  }));
35
35
  };
36
36
  }
37
- shouldExpandGroupingNode(node) {
38
- for (const child of node.children) {
39
- /* c8 ignore next 3 */
40
- if (!child.filtering) {
41
- continue;
42
- }
43
- if (child.filtering.isFilterTarget) {
44
- const childAutoExpand = child.filtering.filterTargetOptions?.autoExpand;
45
- // If child is a filter target and is has no `autoExpand` flag, then it's always to be expanded.
46
- if (childAutoExpand === true) {
47
- return true;
48
- }
49
- // If it's not an object and not `true`, then it's falsy - continue looking
50
- if (typeof childAutoExpand !== "object") {
51
- continue;
52
- }
53
- // If grouping node's child has `autoExpandUntil` flag,
54
- // auto-expand the grouping node only if it's depth is lower than that of the grouping node in associated with the target.
55
- const nodeDepth = childAutoExpand.includeGroupingNodes
56
- ? node.parentKeys.length
57
- : node.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;
58
- const filterTargetDepth = childAutoExpand.depth;
59
- if (nodeDepth < filterTargetDepth) {
60
- return true;
61
- }
62
- }
63
- if (!child.filtering.filteredChildrenIdentifierPaths) {
64
- /* c8 ignore next */
65
- continue;
66
- }
67
- for (const path of child.filtering.filteredChildrenIdentifierPaths) {
68
- if ("path" in path && path.options?.autoExpand) {
69
- return true;
70
- }
71
- }
72
- }
73
- return false;
74
- }
75
37
  get postProcessNode() {
76
38
  return (node) => {
77
39
  return (this._source.postProcessNode ? this._source.postProcessNode(node) : of(node)).pipe(map((processedNode) => {
78
40
  // instance nodes get the auto-expand flag in `parseNode`, but grouping ones need to be handled during post-processing
79
- if (ProcessedHierarchyNode.isGroupingNode(node) && this.shouldExpandGroupingNode(node)) {
41
+ if (ProcessedHierarchyNode.isGroupingNode(node) && shouldExpandGroupingNode(node)) {
80
42
  Object.assign(processedNode, { autoExpand: true });
81
43
  }
82
44
  return processedNode;
@@ -113,13 +75,7 @@ export class FilteringHierarchyDefinition {
113
75
  });
114
76
  return (nodeExtraPropsPossiblyPromise instanceof Promise ? from(nodeExtraPropsPossiblyPromise) : of(nodeExtraPropsPossiblyPromise)).pipe(map((nodeExtraProps) => {
115
77
  if (nodeExtraProps?.autoExpand) {
116
- const parentLength = !parentNode
117
- ? 0
118
- : nodeExtraProps.filtering?.includeGroupingNodes
119
- ? 1 + parentNode.parentKeys.length
120
- : 1 + parentNode.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;
121
- parsedNode.autoExpand =
122
- nodeExtraProps.filtering?.autoExpandDepth !== undefined && parentLength >= nodeExtraProps.filtering.autoExpandDepth ? undefined : true;
78
+ parsedNode.autoExpand = true;
123
79
  }
124
80
  if (nodeExtraProps?.filtering) {
125
81
  parsedNode.filtering = nodeExtraProps.filtering;
@@ -274,4 +230,39 @@ export function applyECInstanceIdsSelector(def) {
274
230
  },
275
231
  };
276
232
  }
233
+ function shouldExpandGroupingNode(node) {
234
+ const numberOfNonGroupingParentNodes = node.parentKeys.filter((key) => !HierarchyNodeKey.isGrouping(key)).length;
235
+ for (const child of node.children) {
236
+ /* c8 ignore next 3 */
237
+ if (!child.filtering) {
238
+ continue;
239
+ }
240
+ if (child.filtering.isFilterTarget &&
241
+ getAutoExpandAsTrueFalse(child.filtering.filterTargetOptions?.autoExpand, numberOfNonGroupingParentNodes, node.parentKeys.length)) {
242
+ return true;
243
+ }
244
+ if (!child.filtering.filteredChildrenIdentifierPaths) {
245
+ /* c8 ignore next */
246
+ continue;
247
+ }
248
+ for (const path of child.filtering.filteredChildrenIdentifierPaths) {
249
+ if ("path" in path && getAutoExpandAsTrueFalse(path.options?.autoExpand, numberOfNonGroupingParentNodes, node.parentKeys.length)) {
250
+ return true;
251
+ }
252
+ }
253
+ }
254
+ return false;
255
+ }
256
+ function getAutoExpandAsTrueFalse(autoExpand, numberOfNonGroupingParentNodes, numberOfParentNodes) {
257
+ if (!autoExpand) {
258
+ return false;
259
+ }
260
+ if (autoExpand === true) {
261
+ return true;
262
+ }
263
+ // auto-expand should be set to true only if parentKeys length is smaller than depth.
264
+ const nodeDepth = "depthInHierarchy" in autoExpand ? numberOfParentNodes : numberOfNonGroupingParentNodes;
265
+ const filterTargetDepth = "depthInPath" in autoExpand ? autoExpand.depthInPath : autoExpand.depthInHierarchy;
266
+ return nodeDepth < filterTargetDepth;
267
+ }
277
268
  //# sourceMappingURL=FilteringHierarchyDefinition.js.map