@itwin/presentation-hierarchies 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +4 -3
  3. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts +48 -3
  4. package/lib/cjs/hierarchies/HierarchyFiltering.d.ts.map +1 -1
  5. package/lib/cjs/hierarchies/HierarchyFiltering.js +137 -2
  6. package/lib/cjs/hierarchies/HierarchyFiltering.js.map +1 -1
  7. package/lib/cjs/hierarchies/HierarchyNode.d.ts +1 -0
  8. package/lib/cjs/hierarchies/HierarchyNode.d.ts.map +1 -1
  9. package/lib/cjs/hierarchies/HierarchyNode.js +3 -0
  10. package/lib/cjs/hierarchies/HierarchyNode.js.map +1 -1
  11. package/lib/cjs/hierarchies/HierarchyProvider.d.ts +43 -8
  12. package/lib/cjs/hierarchies/HierarchyProvider.d.ts.map +1 -1
  13. package/lib/cjs/hierarchies/HierarchyProvider.js.map +1 -1
  14. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +3 -6
  15. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
  16. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js +134 -181
  17. package/lib/cjs/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
  18. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  19. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js +11 -7
  20. package/lib/cjs/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  21. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  22. package/lib/cjs/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  23. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +1 -1
  24. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
  25. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js +12 -0
  26. package/lib/cjs/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
  27. package/lib/cjs/package.json +1 -0
  28. package/lib/cjs/presentation-hierarchies.d.ts +1 -1
  29. package/lib/cjs/presentation-hierarchies.d.ts.map +1 -1
  30. package/lib/cjs/presentation-hierarchies.js +3 -2
  31. package/lib/cjs/presentation-hierarchies.js.map +1 -1
  32. package/lib/esm/hierarchies/HierarchyFiltering.d.ts +48 -3
  33. package/lib/esm/hierarchies/HierarchyFiltering.d.ts.map +1 -1
  34. package/lib/esm/hierarchies/HierarchyFiltering.js +136 -2
  35. package/lib/esm/hierarchies/HierarchyFiltering.js.map +1 -1
  36. package/lib/esm/hierarchies/HierarchyNode.d.ts +1 -0
  37. package/lib/esm/hierarchies/HierarchyNode.d.ts.map +1 -1
  38. package/lib/esm/hierarchies/HierarchyNode.js +3 -0
  39. package/lib/esm/hierarchies/HierarchyNode.js.map +1 -1
  40. package/lib/esm/hierarchies/HierarchyProvider.d.ts +43 -8
  41. package/lib/esm/hierarchies/HierarchyProvider.d.ts.map +1 -1
  42. package/lib/esm/hierarchies/HierarchyProvider.js.map +1 -1
  43. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts +3 -6
  44. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.d.ts.map +1 -1
  45. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js +132 -180
  46. package/lib/esm/hierarchies/imodel/FilteringHierarchyDefinition.js.map +1 -1
  47. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.d.ts.map +1 -1
  48. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js +11 -7
  49. package/lib/esm/hierarchies/imodel/IModelHierarchyProvider.js.map +1 -1
  50. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.d.ts.map +1 -1
  51. package/lib/esm/hierarchies/imodel/NodeSelectQueryFactory.js.map +1 -1
  52. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts +1 -1
  53. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.d.ts.map +1 -1
  54. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js +12 -0
  55. package/lib/esm/hierarchies/imodel/PredicateBasedHierarchyDefinition.js.map +1 -1
  56. package/lib/esm/presentation-hierarchies.d.ts +1 -1
  57. package/lib/esm/presentation-hierarchies.d.ts.map +1 -1
  58. package/lib/esm/presentation-hierarchies.js +1 -1
  59. package/lib/esm/presentation-hierarchies.js.map +1 -1
  60. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"PredicateBasedHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/PredicateBasedHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAwJhG,0FAEC;AAxJD,+BAA4F;AAG5F,0DAAoD;AA4IpD;;;;;;GAMG;AACH,SAAgB,uCAAuC,CAAC,KAA6C;IACnG,OAAO,IAAI,iCAAiC,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,iCAAiC;IACV;IAA3B,YAA2B,MAA8C;QAA9C,WAAM,GAAN,MAAM,CAAwC;IAAG,CAAC;IAE7E;;;OAGG;IACI,KAAK,CAAC,oBAAoB,CAAC,KAAgC;QAChE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QAE7B,IAAI,UAAU,IAAI,gCAAa,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;YACtD,OAAO,IAAA,qBAAc,EACnB,IAAA,WAAI,EAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,IAAI,CACzC,IAAA,aAAM,EAAC,0CAA0C,CAAC,EAClD,IAAA,eAAQ,EAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBACrB,IAAI,MAAM,GAAG,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AAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,WAAW,GAAG,EAAE,CAAC;YACjB,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACrD,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,SAAS,0CAA0C,CAAC,GAA2C;IAC7F,OAAO,CAAC,CAAE,GAAgD,CAAC,0BAA0B,CAAC;AACxF,CAAC;AAED,SAAS,4CAA4C,CAAC,GAA2C;IAC/F,OAAO,CAAC,CAAE,GAAkD,CAAC,4BAA4B,CAAC;AAC5F,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 { concatMap, filter, firstValueFrom, from, mergeAll, mergeMap, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { HierarchyNode } from \"../HierarchyNode.js\";\nimport { GenericNodeKey, InstancesNodeKey } from \"../HierarchyNodeKey.js\";\nimport { DefineHierarchyLevelProps, HierarchyDefinition, HierarchyDefinitionParentNode, HierarchyLevelDefinition } from \"./IModelHierarchyDefinition.js\";\n\n/**\n * Props for defining child hierarchy level for specific parent instance node.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\nexport type DefineInstanceNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\"> & {\n /** The parent instance node. */\n parentNode: Omit<HierarchyDefinitionParentNode, \"key\"> & { key: InstancesNodeKey };\n\n /**\n * Full name of the parent instance node class.\n *\n * The `parentNode.key` also contains information about the instances the parent node is based on. However,\n * an instance node may be based on instances of multiple classes. In case that happens, parent node's instance\n * keys are grouped by class and a hierarchy level definition is requested for each combination of class and\n * instance IDs (with the same `parentNode`).\n */\n parentNodeClassName: string;\n\n /**\n * ECInstanceIds of the parent instance node.\n *\n * The `parentNode.key` also contains information about the instances the parent node is based on. However,\n * an instance node may be based on instances of multiple classes. In case that happens, parent node's instance\n * keys are grouped by class and a hierarchy level definition is requested for each combination of class and\n * instance IDs (with the same `parentNode`).\n */\n parentNodeInstanceIds: Id64String[];\n};\n\n/**\n * A definition of a hierarchy level that should be used for specific parent instance nodes.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\ninterface InstancesNodeChildHierarchyLevelDefinition {\n /**\n * A predicate for matching the parent instances node. This can be either a string or a predicate function:\n *\n * - The string version should specify full name of the parent instance node's class to match against when\n * checking if this hierarchy level should be used for specific parent instance node. The check is polymorphic,\n * so `BisCore.Element` class would match `BisCore.GeometricElement`, `BisCore.Category` and all other element classes.\n *\n * - The function version should return a boolean indicating whether this hierarchy level definition should be used\n * for the given parent node.\n */\n parentInstancesNodePredicate: string | ((parentNodeKey: InstancesNodeKey) => Promise<boolean>);\n\n /**\n * Called to create a hierarchy level definition when the `parentInstancesNodePredicate` predicate passes.\n */\n definitions: (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n\n /**\n * If set to true, and node matches at least one of the previous definitions, this definition will not be applied.\n *\n * For example:\n * ```ts\n * {\n * parentInstancesNodePredicate: \"BisCore.GeometricElement3d\",\n * definitions: () => ...,\n * },\n * // This will apply to all elements, that are not `BisCore.GeometricElement3d`\n * {\n * parentInstancesNodePredicate: \"BisCore.Element\",\n * onlyIfNotHandled: true,\n * definitions: () => ...,\n * }\n * ```\n */\n onlyIfNotHandled?: boolean;\n}\n\n/**\n * Props for defining child hierarchy level for specific generic parent node.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\nexport type DefineGenericNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\"> & {\n /** The parent generic node. */\n parentNode: Omit<HierarchyDefinitionParentNode, \"key\"> & { key: GenericNodeKey };\n};\n\n/**\n * A definition of a hierarchy level for that should be used for specific generic parent nodes.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\ninterface GenericNodeChildHierarchyLevelDefinition {\n /**\n * A function that indicates whether this hierarchy level definition should be used for\n * specific parent generic node.\n */\n parentGenericNodePredicate: (parentNodeKey: GenericNodeKey) => Promise<boolean>;\n\n /**\n * Called to create a hierarchy level definition when the `parentInstancesNodePredicate` predicate passes.\n */\n definitions: (requestProps: DefineGenericNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n}\n\n/**\n * A hierarchy level definition associated with specific parent instance or generic node. *\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\ntype PredicateBasedHierarchyLevelDefinition = InstancesNodeChildHierarchyLevelDefinition | GenericNodeChildHierarchyLevelDefinition;\n\n/**\n * Props for defining root hierarchy level.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\nexport type DefineRootHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\">;\n\n/**\n * Props for `createPredicateBasedHierarchyDefinition`.\n * @public\n */\ninterface PredicateBasedHierarchyDefinitionProps {\n /** Access to ECClass hierarchy in the iModel */\n classHierarchyInspector: ECClassHierarchyInspector;\n\n /** Hierarchy level definitions */\n hierarchy: {\n /** Called to create the root hierarchy level definition. */\n rootNodes: (props: DefineRootHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n\n /**\n * A list of child hierarchy level definitions. The list is first filtered based on\n * the parent node and then is used to create child hierarchy level definitions.\n */\n childNodes: PredicateBasedHierarchyLevelDefinition[];\n };\n}\n\n/**\n * Creates an instance of `HierarchyDefinition` that uses a somewhat declarative approach to define the\n * hierarchy - each hierarchy level is defined by specifying a parent node predicate and child hierarchy\n * level definitions, that are used when the predicate passes.\n *\n * @public\n */\nexport function createPredicateBasedHierarchyDefinition(props: PredicateBasedHierarchyDefinitionProps): HierarchyDefinition {\n return new PredicateBasedHierarchyDefinition(props);\n}\n\nclass PredicateBasedHierarchyDefinition implements HierarchyDefinition {\n public constructor(private _props: PredicateBasedHierarchyDefinitionProps) {}\n\n /**\n * Create hierarchy level definitions for specific hierarchy level.\n * @param parentNode Parent node to create children definitions for.\n */\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const { parentNode } = props;\n\n if (parentNode && HierarchyNode.isGeneric(parentNode)) {\n return firstValueFrom(\n from(this._props.hierarchy.childNodes).pipe(\n filter(isGenericNodeChildHierarchyLevelDefinition),\n mergeMap(async (def) => {\n if (await def.parentGenericNodePredicate(parentNode.key)) {\n return def.definitions({ ...props, parentNode });\n }\n return [];\n }),\n mergeAll(),\n toArray(),\n ),\n );\n }\n\n if (parentNode && HierarchyNode.isInstancesNode(parentNode)) {\n const instancesParentNodeDefs = this._props.hierarchy.childNodes.filter(isInstancesNodeChildHierarchyLevelDefinition);\n return firstValueFrom(\n from(groupInstanceIdsByClass(parentNode.key.instanceKeys).entries()).pipe(\n mergeMap(async ([parentNodeClassName, parentNodeInstanceIds]) =>\n createHierarchyLevelDefinitions(this._props.classHierarchyInspector, instancesParentNodeDefs, {\n ...props,\n parentNodeClassName,\n parentNodeInstanceIds,\n parentNode,\n }),\n ),\n mergeAll(),\n toArray(),\n ),\n );\n }\n\n return this._props.hierarchy.rootNodes(props);\n }\n}\n\nasync function createHierarchyLevelDefinitions(\n classHierarchy: ECClassHierarchyInspector,\n defs: InstancesNodeChildHierarchyLevelDefinition[],\n requestProps: DefineInstanceNodeChildHierarchyLevelProps,\n) {\n return from(defs).pipe(\n mergeMap(async (def, idx) => {\n if (\n typeof def.parentInstancesNodePredicate === \"string\" &&\n (await classHierarchy.classDerivesFrom(requestProps.parentNodeClassName, def.parentInstancesNodePredicate))\n ) {\n return { def, idx };\n }\n if (typeof def.parentInstancesNodePredicate === \"function\" && (await def.parentInstancesNodePredicate(requestProps.parentNode.key))) {\n return { def, idx };\n }\n return undefined;\n }),\n filter((x): x is Exclude<typeof x, undefined> => !!x),\n toArray(),\n concatMap((x) => x.sort((a, b) => a.idx - b.idx).map(({ def }) => def)),\n filter((def, idx) => !def.onlyIfNotHandled || idx === 0),\n mergeMap(async (def) => def.definitions(requestProps)),\n mergeAll(),\n );\n}\n\nfunction groupInstanceIdsByClass(instanceKeys: InstanceKey[]) {\n const instanceIdsByClass = new Map<string, Id64String[]>();\n instanceKeys.forEach((key) => {\n let instanceIds = instanceIdsByClass.get(key.className);\n if (!instanceIds) {\n instanceIds = [];\n instanceIdsByClass.set(key.className, instanceIds);\n }\n instanceIds.push(key.id);\n });\n return instanceIdsByClass;\n}\n\nfunction isGenericNodeChildHierarchyLevelDefinition(def: PredicateBasedHierarchyLevelDefinition): def is GenericNodeChildHierarchyLevelDefinition {\n return !!(def as GenericNodeChildHierarchyLevelDefinition).parentGenericNodePredicate;\n}\n\nfunction isInstancesNodeChildHierarchyLevelDefinition(def: PredicateBasedHierarchyLevelDefinition): def is InstancesNodeChildHierarchyLevelDefinition {\n return !!(def as InstancesNodeChildHierarchyLevelDefinition).parentInstancesNodePredicate;\n}\n"]}
1
+ {"version":3,"file":"PredicateBasedHierarchyDefinition.js","sourceRoot":"","sources":["../../../../src/hierarchies/imodel/PredicateBasedHierarchyDefinition.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAgKhG,0FAEC;AAhKD,+BAA4F;AAG5F,0DAAoD;AAoJpD;;;;;;GAMG;AACH,SAAgB,uCAAuC,CAAC,KAA6C;IACnG,OAAO,IAAI,iCAAiC,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,iCAAiC;IAKV;IAJpB,SAAS,CAAyB;IAClC,cAAc,CAA+B;IAC7C,eAAe,CAAgC;IAEtD,YAA2B,MAA8C;QAA9C,WAAM,GAAN,MAAM,CAAwC;QACvE,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,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E,GAAkD,CAAC,4BAA4B,CAAC;AAC5F,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 { concatMap, filter, firstValueFrom, from, mergeAll, mergeMap, toArray } from \"rxjs\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { ECClassHierarchyInspector, InstanceKey } from \"@itwin/presentation-shared\";\nimport { HierarchyNode } from \"../HierarchyNode.js\";\nimport { GenericNodeKey, InstancesNodeKey } from \"../HierarchyNodeKey.js\";\nimport {\n DefineHierarchyLevelProps,\n HierarchyDefinition,\n HierarchyDefinitionParentNode,\n HierarchyLevelDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"./IModelHierarchyDefinition.js\";\n\n/**\n * Props for defining child hierarchy level for specific parent instance node.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\nexport type DefineInstanceNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\"> & {\n /** The parent instance node. */\n parentNode: Omit<HierarchyDefinitionParentNode, \"key\"> & { key: InstancesNodeKey };\n\n /**\n * Full name of the parent instance node class.\n *\n * The `parentNode.key` also contains information about the instances the parent node is based on. However,\n * an instance node may be based on instances of multiple classes. In case that happens, parent node's instance\n * keys are grouped by class and a hierarchy level definition is requested for each combination of class and\n * instance IDs (with the same `parentNode`).\n */\n parentNodeClassName: string;\n\n /**\n * ECInstanceIds of the parent instance node.\n *\n * The `parentNode.key` also contains information about the instances the parent node is based on. However,\n * an instance node may be based on instances of multiple classes. In case that happens, parent node's instance\n * keys are grouped by class and a hierarchy level definition is requested for each combination of class and\n * instance IDs (with the same `parentNode`).\n */\n parentNodeInstanceIds: Id64String[];\n};\n\n/**\n * A definition of a hierarchy level that should be used for specific parent instance nodes.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\ninterface InstancesNodeChildHierarchyLevelDefinition {\n /**\n * A predicate for matching the parent instances node. This can be either a string or a predicate function:\n *\n * - The string version should specify full name of the parent instance node's class to match against when\n * checking if this hierarchy level should be used for specific parent instance node. The check is polymorphic,\n * so `BisCore.Element` class would match `BisCore.GeometricElement`, `BisCore.Category` and all other element classes.\n *\n * - The function version should return a boolean indicating whether this hierarchy level definition should be used\n * for the given parent node.\n */\n parentInstancesNodePredicate: string | ((parentNodeKey: InstancesNodeKey) => Promise<boolean>);\n\n /**\n * Called to create a hierarchy level definition when the `parentInstancesNodePredicate` predicate passes.\n */\n definitions: (requestProps: DefineInstanceNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n\n /**\n * If set to true, and node matches at least one of the previous definitions, this definition will not be applied.\n *\n * For example:\n * ```ts\n * {\n * parentInstancesNodePredicate: \"BisCore.GeometricElement3d\",\n * definitions: () => ...,\n * },\n * // This will apply to all elements, that are not `BisCore.GeometricElement3d`\n * {\n * parentInstancesNodePredicate: \"BisCore.Element\",\n * onlyIfNotHandled: true,\n * definitions: () => ...,\n * }\n * ```\n */\n onlyIfNotHandled?: boolean;\n}\n\n/**\n * Props for defining child hierarchy level for specific generic parent node.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\nexport type DefineGenericNodeChildHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\"> & {\n /** The parent generic node. */\n parentNode: Omit<HierarchyDefinitionParentNode, \"key\"> & { key: GenericNodeKey };\n};\n\n/**\n * A definition of a hierarchy level for that should be used for specific generic parent nodes.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\ninterface GenericNodeChildHierarchyLevelDefinition {\n /**\n * A function that indicates whether this hierarchy level definition should be used for\n * specific parent generic node.\n */\n parentGenericNodePredicate: (parentNodeKey: GenericNodeKey) => Promise<boolean>;\n\n /**\n * Called to create a hierarchy level definition when the `parentInstancesNodePredicate` predicate passes.\n */\n definitions: (requestProps: DefineGenericNodeChildHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n}\n\n/**\n * A hierarchy level definition associated with specific parent instance or generic node. *\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\ntype PredicateBasedHierarchyLevelDefinition = InstancesNodeChildHierarchyLevelDefinition | GenericNodeChildHierarchyLevelDefinition;\n\n/**\n * Props for defining root hierarchy level.\n * @see `createPredicateBasedHierarchyDefinition`\n * @public\n */\nexport type DefineRootHierarchyLevelProps = Omit<DefineHierarchyLevelProps, \"parentNode\">;\n\n/**\n * Props for `createPredicateBasedHierarchyDefinition`.\n * @public\n */\ninterface PredicateBasedHierarchyDefinitionProps extends Pick<HierarchyDefinition, \"parseNode\" | \"preProcessNode\" | \"postProcessNode\"> {\n /** Access to ECClass hierarchy in the iModel */\n classHierarchyInspector: ECClassHierarchyInspector;\n\n /** Hierarchy level definitions */\n hierarchy: {\n /** Called to create the root hierarchy level definition. */\n rootNodes: (props: DefineRootHierarchyLevelProps) => Promise<HierarchyLevelDefinition>;\n\n /**\n * A list of child hierarchy level definitions. The list is first filtered based on\n * the parent node and then is used to create child hierarchy level definitions.\n */\n childNodes: PredicateBasedHierarchyLevelDefinition[];\n };\n}\n\n/**\n * Creates an instance of `HierarchyDefinition` that uses a somewhat declarative approach to define the\n * hierarchy - each hierarchy level is defined by specifying a parent node predicate and child hierarchy\n * level definitions, that are used when the predicate passes.\n *\n * @public\n */\nexport function createPredicateBasedHierarchyDefinition(props: PredicateBasedHierarchyDefinitionProps): HierarchyDefinition {\n return new PredicateBasedHierarchyDefinition(props);\n}\n\nclass PredicateBasedHierarchyDefinition implements HierarchyDefinition {\n public parseNode: NodeParser | undefined;\n public preProcessNode: NodePreProcessor | undefined;\n public postProcessNode: NodePostProcessor | undefined;\n\n public constructor(private _props: PredicateBasedHierarchyDefinitionProps) {\n if (this._props.parseNode) {\n this.parseNode = this._props.parseNode;\n }\n if (this._props.preProcessNode) {\n this.preProcessNode = this._props.preProcessNode;\n }\n if (this._props.postProcessNode) {\n this.postProcessNode = this._props.postProcessNode;\n }\n }\n\n /**\n * Create hierarchy level definitions for specific hierarchy level.\n * @param parentNode Parent node to create children definitions for.\n */\n public async defineHierarchyLevel(props: DefineHierarchyLevelProps): Promise<HierarchyLevelDefinition> {\n const { parentNode } = props;\n\n if (parentNode && HierarchyNode.isGeneric(parentNode)) {\n return firstValueFrom(\n from(this._props.hierarchy.childNodes).pipe(\n filter(isGenericNodeChildHierarchyLevelDefinition),\n mergeMap(async (def) => {\n if (await def.parentGenericNodePredicate(parentNode.key)) {\n return def.definitions({ ...props, parentNode });\n }\n return [];\n }),\n mergeAll(),\n toArray(),\n ),\n );\n }\n\n if (parentNode && HierarchyNode.isInstancesNode(parentNode)) {\n const instancesParentNodeDefs = this._props.hierarchy.childNodes.filter(isInstancesNodeChildHierarchyLevelDefinition);\n return firstValueFrom(\n from(groupInstanceIdsByClass(parentNode.key.instanceKeys).entries()).pipe(\n mergeMap(async ([parentNodeClassName, parentNodeInstanceIds]) =>\n createHierarchyLevelDefinitions(this._props.classHierarchyInspector, instancesParentNodeDefs, {\n ...props,\n parentNodeClassName,\n parentNodeInstanceIds,\n parentNode,\n }),\n ),\n mergeAll(),\n toArray(),\n ),\n );\n }\n\n return this._props.hierarchy.rootNodes(props);\n }\n}\n\nasync function createHierarchyLevelDefinitions(\n classHierarchy: ECClassHierarchyInspector,\n defs: InstancesNodeChildHierarchyLevelDefinition[],\n requestProps: DefineInstanceNodeChildHierarchyLevelProps,\n) {\n return from(defs).pipe(\n mergeMap(async (def, idx) => {\n if (\n typeof def.parentInstancesNodePredicate === \"string\" &&\n (await classHierarchy.classDerivesFrom(requestProps.parentNodeClassName, def.parentInstancesNodePredicate))\n ) {\n return { def, idx };\n }\n if (typeof def.parentInstancesNodePredicate === \"function\" && (await def.parentInstancesNodePredicate(requestProps.parentNode.key))) {\n return { def, idx };\n }\n return undefined;\n }),\n filter((x): x is Exclude<typeof x, undefined> => !!x),\n toArray(),\n concatMap((x) => x.sort((a, b) => a.idx - b.idx).map(({ def }) => def)),\n filter((def, idx) => !def.onlyIfNotHandled || idx === 0),\n mergeMap(async (def) => def.definitions(requestProps)),\n mergeAll(),\n );\n}\n\nfunction groupInstanceIdsByClass(instanceKeys: InstanceKey[]) {\n const instanceIdsByClass = new Map<string, Id64String[]>();\n instanceKeys.forEach((key) => {\n let instanceIds = instanceIdsByClass.get(key.className);\n if (!instanceIds) {\n instanceIds = [];\n instanceIdsByClass.set(key.className, instanceIds);\n }\n instanceIds.push(key.id);\n });\n return instanceIdsByClass;\n}\n\nfunction isGenericNodeChildHierarchyLevelDefinition(def: PredicateBasedHierarchyLevelDefinition): def is GenericNodeChildHierarchyLevelDefinition {\n return !!(def as GenericNodeChildHierarchyLevelDefinition).parentGenericNodePredicate;\n}\n\nfunction isInstancesNodeChildHierarchyLevelDefinition(def: PredicateBasedHierarchyLevelDefinition): def is InstancesNodeChildHierarchyLevelDefinition {\n return !!(def as InstancesNodeChildHierarchyLevelDefinition).parentInstancesNodePredicate;\n}\n"]}
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -10,6 +10,6 @@ export { GroupingHierarchyNode, HierarchyNode, NonGroupingHierarchyNode } from "
10
10
  export { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from "./hierarchies/HierarchyNodeIdentifier.js";
11
11
  export { GenericNodeKey, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey, ClassGroupingNodeKey, LabelGroupingNodeKey, PropertyGroupingNodeKey, PropertyOtherValuesGroupingNodeKey, PropertyValueGroupingNodeKey, PropertyValueRangeGroupingNodeKey, IModelHierarchyNodeKey, } from "./hierarchies/HierarchyNodeKey.js";
12
12
  export { GetHierarchyNodesProps, HierarchyProvider, mergeProviders } from "./hierarchies/HierarchyProvider.js";
13
- export { HierarchyFilteringPath, extractFilteringProps } from "./hierarchies/HierarchyFiltering.js";
13
+ export { createHierarchyFilteringHelper, extractFilteringProps, HierarchyFilteringPath, HierarchyFilteringPathOptions, } from "./hierarchies/HierarchyFiltering.js";
14
14
  export { getLogger, setLogger } from "./hierarchies/Logging.js";
15
15
  //# sourceMappingURL=presentation-hierarchies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-hierarchies.d.ts","sourceRoot":"","sources":["../../src/presentation-hierarchies.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,yCAAyC,EACzC,0CAA0C,EAC1C,6BAA6B,EAC7B,uCAAuC,GACxC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,oDAAoD,CAAC;AAClI,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AACrJ,OAAO,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAE1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAChH,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACjH,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC/G,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"presentation-hierarchies.d.ts","sourceRoot":"","sources":["../../src/presentation-hierarchies.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,yCAAyC,EACzC,0CAA0C,EAC1C,6BAA6B,EAC7B,uCAAuC,GACxC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,MAAM,oDAAoD,CAAC;AAClI,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AACrJ,OAAO,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAE1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAChH,OAAO,EAAE,uBAAuB,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACjH,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,kCAAkC,EAClC,4BAA4B,EAC5B,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC/G,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,EACtB,6BAA6B,GAC9B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC"}
@@ -4,7 +4,7 @@
4
4
  * See LICENSE.md in the project root for license terms and full copyright notice.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.setLogger = exports.getLogger = exports.extractFilteringProps = exports.HierarchyFilteringPath = exports.mergeProviders = exports.HierarchyNodeKey = exports.HierarchyNodeIdentifier = exports.HierarchyNode = exports.RowsLimitExceededError = exports.ProcessedHierarchyNode = exports.createIModelHierarchyProvider = exports.createNodesQueryClauseFactory = exports.NodeSelectClauseColumnNames = exports.createLimitingECSqlQueryExecutor = exports.createPredicateBasedHierarchyDefinition = exports.HierarchyNodesDefinition = exports.GenericInstanceFilter = void 0;
7
+ exports.setLogger = exports.getLogger = exports.HierarchyFilteringPath = exports.extractFilteringProps = exports.createHierarchyFilteringHelper = exports.mergeProviders = exports.HierarchyNodeKey = exports.HierarchyNodeIdentifier = exports.HierarchyNode = exports.RowsLimitExceededError = exports.ProcessedHierarchyNode = exports.createIModelHierarchyProvider = exports.createNodesQueryClauseFactory = exports.NodeSelectClauseColumnNames = exports.createLimitingECSqlQueryExecutor = exports.createPredicateBasedHierarchyDefinition = exports.HierarchyNodesDefinition = exports.GenericInstanceFilter = void 0;
8
8
  var core_common_1 = require("@itwin/core-common");
9
9
  Object.defineProperty(exports, "GenericInstanceFilter", { enumerable: true, get: function () { return core_common_1.GenericInstanceFilter; } });
10
10
  var IModelHierarchyDefinition_js_1 = require("./hierarchies/imodel/IModelHierarchyDefinition.js");
@@ -31,8 +31,9 @@ Object.defineProperty(exports, "HierarchyNodeKey", { enumerable: true, get: func
31
31
  var HierarchyProvider_js_1 = require("./hierarchies/HierarchyProvider.js");
32
32
  Object.defineProperty(exports, "mergeProviders", { enumerable: true, get: function () { return HierarchyProvider_js_1.mergeProviders; } });
33
33
  var HierarchyFiltering_js_1 = require("./hierarchies/HierarchyFiltering.js");
34
- Object.defineProperty(exports, "HierarchyFilteringPath", { enumerable: true, get: function () { return HierarchyFiltering_js_1.HierarchyFilteringPath; } });
34
+ Object.defineProperty(exports, "createHierarchyFilteringHelper", { enumerable: true, get: function () { return HierarchyFiltering_js_1.createHierarchyFilteringHelper; } });
35
35
  Object.defineProperty(exports, "extractFilteringProps", { enumerable: true, get: function () { return HierarchyFiltering_js_1.extractFilteringProps; } });
36
+ Object.defineProperty(exports, "HierarchyFilteringPath", { enumerable: true, get: function () { return HierarchyFiltering_js_1.HierarchyFilteringPath; } });
36
37
  var Logging_js_1 = require("./hierarchies/Logging.js");
37
38
  Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return Logging_js_1.getLogger; } });
38
39
  Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return Logging_js_1.setLogger; } });
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-hierarchies.js","sourceRoot":"","sources":["../../src/presentation-hierarchies.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,kDAA2D;AAAlD,oHAAA,qBAAqB,OAAA;AAE9B,kGAQ2D;AAJzD,wIAAA,wBAAwB,OAAA;AAK1B,kHAKmE;AADjE,+JAAA,uCAAuC,OAAA;AAEzC,oGAAkI;AAA7F,iJAAA,gCAAgC,OAAA;AACrE,4FAAqJ;AAA5I,wIAAA,2BAA2B,OAAA;AAA2B,0IAAA,6BAA6B,OAAA;AAC5F,8FAAgG;AAAvF,2IAAA,6BAA6B,OAAA;AACtC,sFAA0G;AAA5E,gIAAA,sBAAsB,OAAA;AAEpD,uEAA0E;AAAjE,4HAAA,sBAAsB,OAAA;AAC/B,mEAAgH;AAAhF,iHAAA,aAAa,OAAA;AAC7C,uFAAiH;AAAxG,qIAAA,uBAAuB,OAAA;AAChC,yEAY2C;AATzC,uHAAA,gBAAgB,OAAA;AAUlB,2EAA+G;AAA3D,sHAAA,cAAc,OAAA;AAClE,6EAAoG;AAA3F,+HAAA,sBAAsB,OAAA;AAAE,8HAAA,qBAAqB,OAAA;AACtD,uDAAgE;AAAvD,uGAAA,SAAS,OAAA;AAAE,uGAAA,SAAS,OAAA","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\nexport { GenericInstanceFilter } from \"@itwin/core-common\";\n\nexport {\n DefineHierarchyLevelProps,\n HierarchyLevelDefinition,\n HierarchyDefinition,\n HierarchyNodesDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"./hierarchies/imodel/IModelHierarchyDefinition.js\";\nexport {\n DefineGenericNodeChildHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n createPredicateBasedHierarchyDefinition,\n} from \"./hierarchies/imodel/PredicateBasedHierarchyDefinition.js\";\nexport { LimitingECSqlQueryExecutor, createLimitingECSqlQueryExecutor } from \"./hierarchies/imodel/LimitingECSqlQueryExecutor.js\";\nexport { NodeSelectClauseColumnNames, NodesQueryClauseFactory, createNodesQueryClauseFactory } from \"./hierarchies/imodel/NodeSelectQueryFactory.js\";\nexport { createIModelHierarchyProvider } from \"./hierarchies/imodel/IModelHierarchyProvider.js\";\nexport { SourceHierarchyNode, ProcessedHierarchyNode } from \"./hierarchies/imodel/IModelHierarchyNode.js\";\n\nexport { RowsLimitExceededError } from \"./hierarchies/HierarchyErrors.js\";\nexport { GroupingHierarchyNode, HierarchyNode, NonGroupingHierarchyNode } from \"./hierarchies/HierarchyNode.js\";\nexport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./hierarchies/HierarchyNodeIdentifier.js\";\nexport {\n GenericNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n InstancesNodeKey,\n ClassGroupingNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n IModelHierarchyNodeKey,\n} from \"./hierarchies/HierarchyNodeKey.js\";\nexport { GetHierarchyNodesProps, HierarchyProvider, mergeProviders } from \"./hierarchies/HierarchyProvider.js\";\nexport { HierarchyFilteringPath, extractFilteringProps } from \"./hierarchies/HierarchyFiltering.js\";\nexport { getLogger, setLogger } from \"./hierarchies/Logging.js\";\n"]}
1
+ {"version":3,"file":"presentation-hierarchies.js","sourceRoot":"","sources":["../../src/presentation-hierarchies.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,kDAA2D;AAAlD,oHAAA,qBAAqB,OAAA;AAE9B,kGAQ2D;AAJzD,wIAAA,wBAAwB,OAAA;AAK1B,kHAKmE;AADjE,+JAAA,uCAAuC,OAAA;AAEzC,oGAAkI;AAA7F,iJAAA,gCAAgC,OAAA;AACrE,4FAAqJ;AAA5I,wIAAA,2BAA2B,OAAA;AAA2B,0IAAA,6BAA6B,OAAA;AAC5F,8FAAgG;AAAvF,2IAAA,6BAA6B,OAAA;AACtC,sFAA0G;AAA5E,gIAAA,sBAAsB,OAAA;AAEpD,uEAA0E;AAAjE,4HAAA,sBAAsB,OAAA;AAC/B,mEAAgH;AAAhF,iHAAA,aAAa,OAAA;AAC7C,uFAAiH;AAAxG,qIAAA,uBAAuB,OAAA;AAChC,yEAY2C;AATzC,uHAAA,gBAAgB,OAAA;AAUlB,2EAA+G;AAA3D,sHAAA,cAAc,OAAA;AAClE,6EAK6C;AAJ3C,uIAAA,8BAA8B,OAAA;AAC9B,8HAAA,qBAAqB,OAAA;AACrB,+HAAA,sBAAsB,OAAA;AAGxB,uDAAgE;AAAvD,uGAAA,SAAS,OAAA;AAAE,uGAAA,SAAS,OAAA","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\nexport { GenericInstanceFilter } from \"@itwin/core-common\";\n\nexport {\n DefineHierarchyLevelProps,\n HierarchyLevelDefinition,\n HierarchyDefinition,\n HierarchyNodesDefinition,\n NodeParser,\n NodePostProcessor,\n NodePreProcessor,\n} from \"./hierarchies/imodel/IModelHierarchyDefinition.js\";\nexport {\n DefineGenericNodeChildHierarchyLevelProps,\n DefineInstanceNodeChildHierarchyLevelProps,\n DefineRootHierarchyLevelProps,\n createPredicateBasedHierarchyDefinition,\n} from \"./hierarchies/imodel/PredicateBasedHierarchyDefinition.js\";\nexport { LimitingECSqlQueryExecutor, createLimitingECSqlQueryExecutor } from \"./hierarchies/imodel/LimitingECSqlQueryExecutor.js\";\nexport { NodeSelectClauseColumnNames, NodesQueryClauseFactory, createNodesQueryClauseFactory } from \"./hierarchies/imodel/NodeSelectQueryFactory.js\";\nexport { createIModelHierarchyProvider } from \"./hierarchies/imodel/IModelHierarchyProvider.js\";\nexport { SourceHierarchyNode, ProcessedHierarchyNode } from \"./hierarchies/imodel/IModelHierarchyNode.js\";\n\nexport { RowsLimitExceededError } from \"./hierarchies/HierarchyErrors.js\";\nexport { GroupingHierarchyNode, HierarchyNode, NonGroupingHierarchyNode } from \"./hierarchies/HierarchyNode.js\";\nexport { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from \"./hierarchies/HierarchyNodeIdentifier.js\";\nexport {\n GenericNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n InstancesNodeKey,\n ClassGroupingNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n IModelHierarchyNodeKey,\n} from \"./hierarchies/HierarchyNodeKey.js\";\nexport { GetHierarchyNodesProps, HierarchyProvider, mergeProviders } from \"./hierarchies/HierarchyProvider.js\";\nexport {\n createHierarchyFilteringHelper,\n extractFilteringProps,\n HierarchyFilteringPath,\n HierarchyFilteringPathOptions,\n} from \"./hierarchies/HierarchyFiltering.js\";\nexport { getLogger, setLogger } from \"./hierarchies/Logging.js\";\n"]}
@@ -1,6 +1,6 @@
1
- import { NonGroupingHierarchyNode } from "./HierarchyNode.js";
2
- import { HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier.js";
3
- import { GroupingNodeKey } from "./HierarchyNodeKey.js";
1
+ import { HierarchyNode, NonGroupingHierarchyNode } from "./HierarchyNode.js";
2
+ import { HierarchyNodeIdentifier, HierarchyNodeIdentifiersPath } from "./HierarchyNodeIdentifier.js";
3
+ import { GenericNodeKey, GroupingNodeKey, InstancesNodeKey } from "./HierarchyNodeKey.js";
4
4
  /** @public */
5
5
  export interface FilterTargetGroupingNodeInfo {
6
6
  /** Key of the grouping node. */
@@ -57,9 +57,54 @@ export declare namespace HierarchyFilteringPath {
57
57
  * An utility that extracts filtering properties from given root level filtering props or
58
58
  * the parent node. Returns `undefined` if filtering props are not present.
59
59
  * @public
60
+ * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.
60
61
  */
61
62
  export declare function extractFilteringProps(rootLevelFilteringProps: HierarchyFilteringPath[], parentNode: Pick<NonGroupingHierarchyNode, "filtering"> | undefined): {
62
63
  filteredNodePaths: HierarchyFilteringPath[];
63
64
  hasFilterTargetAncestor: boolean;
64
65
  } | undefined;
66
+ /**
67
+ * Creates a set of utilities for making it easier to filter the given hierarchy
68
+ * level.
69
+ *
70
+ * @public
71
+ */
72
+ export declare function createHierarchyFilteringHelper(rootLevelFilteringProps: HierarchyFilteringPath[] | undefined, parentNode: Pick<NonGroupingHierarchyNode, "filtering"> | undefined): {
73
+ /**
74
+ * Returns a flag indicating if the hierarchy level is filtered.
75
+ */
76
+ hasFilter: boolean;
77
+ /**
78
+ * Returns a flag indicating whether this hierarchy level has an ancestor node
79
+ * that is a filter target. That generally means that this and all downstream hierarchy
80
+ * levels should be displayed without filter being applied to them, even if filter paths
81
+ * say otherwise.
82
+ */
83
+ hasFilterTargetAncestor: boolean;
84
+ /**
85
+ * Returns a list of hierarchy node identifiers that apply specifically for this
86
+ * hierarchy level. Returns `undefined` if filtering is not applied to this level.
87
+ */
88
+ getChildNodeFilteringIdentifiers: () => HierarchyNodeIdentifier[] | undefined;
89
+ /**
90
+ * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`
91
+ * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
92
+ * these props for a child node based on its key or path matcher.
93
+ *
94
+ * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
95
+ * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the
96
+ * `nodeKey` prop can be used to check the whole identifier.
97
+ */
98
+ createChildNodeProps: (props: {
99
+ nodeKey: InstancesNodeKey | GenericNodeKey;
100
+ } | {
101
+ pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean;
102
+ }) => Pick<HierarchyNode, "filtering" | "autoExpand"> | undefined;
103
+ /**
104
+ * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
105
+ */
106
+ createChildNodePropsAsync: (props: {
107
+ pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;
108
+ }) => Promise<Pick<HierarchyNode, "filtering" | "autoExpand"> | undefined>;
109
+ };
65
110
  //# 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,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C,gCAAgC;IAChC,GAAG,EAAE,eAAe,CAAC;IAErB;;;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;KAC/D,KACJ,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS;IAoB9D;;OAEG;uCACsC;QACvC,WAAW,EAAE,CAAC,UAAU,EAAE,uBAAuB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;KAClF,KAAG,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;EA2B3E"}
@@ -2,6 +2,8 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
+ import { HierarchyNodeIdentifier } from "./HierarchyNodeIdentifier.js";
6
+ import { HierarchyNodeKey } from "./HierarchyNodeKey.js";
5
7
  /** @public */
6
8
  // eslint-disable-next-line @typescript-eslint/no-redeclare
7
9
  export var HierarchyFilteringPath;
@@ -12,7 +14,7 @@ export var HierarchyFilteringPath;
12
14
  */
13
15
  function normalize(source) {
14
16
  if (Array.isArray(source)) {
15
- return { path: source, options: undefined };
17
+ return { path: source };
16
18
  }
17
19
  return source;
18
20
  }
@@ -56,10 +58,16 @@ export var HierarchyFilteringPath;
56
58
  * An utility that extracts filtering properties from given root level filtering props or
57
59
  * the parent node. Returns `undefined` if filtering props are not present.
58
60
  * @public
61
+ * @deprecated in 1.3. Use `createHierarchyFilteringHelper` instead.
59
62
  */
63
+ /* c8 ignore start */
60
64
  export function extractFilteringProps(rootLevelFilteringProps, parentNode) {
65
+ return extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
66
+ }
67
+ /* c8 ignore end */
68
+ function extractFilteringPropsInternal(rootLevelFilteringProps, parentNode) {
61
69
  if (!parentNode) {
62
- return { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false };
70
+ return rootLevelFilteringProps ? { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false } : undefined;
63
71
  }
64
72
  return parentNode.filtering?.filteredChildrenIdentifierPaths
65
73
  ? {
@@ -68,4 +76,130 @@ export function extractFilteringProps(rootLevelFilteringProps, parentNode) {
68
76
  }
69
77
  : undefined;
70
78
  }
79
+ /**
80
+ * Creates a set of utilities for making it easier to filter the given hierarchy
81
+ * level.
82
+ *
83
+ * @public
84
+ */
85
+ export function createHierarchyFilteringHelper(rootLevelFilteringProps, parentNode) {
86
+ const filteringProps = extractFilteringPropsInternal(rootLevelFilteringProps, parentNode);
87
+ const hasFilter = !!filteringProps;
88
+ return {
89
+ /**
90
+ * Returns a flag indicating if the hierarchy level is filtered.
91
+ */
92
+ hasFilter,
93
+ /**
94
+ * Returns a flag indicating whether this hierarchy level has an ancestor node
95
+ * that is a filter target. That generally means that this and all downstream hierarchy
96
+ * levels should be displayed without filter being applied to them, even if filter paths
97
+ * say otherwise.
98
+ */
99
+ hasFilterTargetAncestor: filteringProps?.hasFilterTargetAncestor ?? false,
100
+ /**
101
+ * Returns a list of hierarchy node identifiers that apply specifically for this
102
+ * hierarchy level. Returns `undefined` if filtering is not applied to this level.
103
+ */
104
+ getChildNodeFilteringIdentifiers: () => {
105
+ if (!hasFilter) {
106
+ return undefined;
107
+ }
108
+ return filteringProps.filteredNodePaths
109
+ .map(HierarchyFilteringPath.normalize)
110
+ .filter(({ path }) => path.length > 0)
111
+ .map(({ path }) => path[0]);
112
+ },
113
+ /**
114
+ * When a hierarchy node is created for a filtered hierarchy level, it needs some attributes (e.g. `filtering`
115
+ * and `autoExpand`) to be set based on the filter paths and filtering options. This function calculates
116
+ * these props for a child node based on its key or path matcher.
117
+ *
118
+ * When using `pathMatcher` prop, callers have more flexibility to decide whether the given `HierarchyNodeIdentifier` applies
119
+ * to their node. For example, only some parts of the identifier can be checked for improved performance. Otherwise, the
120
+ * `nodeKey` prop can be used to check the whole identifier.
121
+ */
122
+ createChildNodeProps: (props) => {
123
+ if (!hasFilter) {
124
+ return undefined;
125
+ }
126
+ const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
127
+ filteringProps.filteredNodePaths.forEach((filteredPath) => {
128
+ const normalizedPath = HierarchyFilteringPath.normalize(filteredPath);
129
+ if ("nodeKey" in props &&
130
+ ((HierarchyNodeKey.isGeneric(props.nodeKey) && HierarchyNodeIdentifier.equal(normalizedPath.path[0], props.nodeKey)) ||
131
+ (HierarchyNodeKey.isInstances(props.nodeKey) && props.nodeKey.instanceKeys.some((ik) => HierarchyNodeIdentifier.equal(normalizedPath.path[0], ik))))) {
132
+ reducer.accept(normalizedPath);
133
+ }
134
+ else if ("pathMatcher" in props && props.pathMatcher(normalizedPath.path[0])) {
135
+ reducer.accept(normalizedPath);
136
+ }
137
+ });
138
+ return reducer.getNodeProps();
139
+ },
140
+ /**
141
+ * Similar to `createChildNodeProps`, but takes an async `pathMatcher` prop.
142
+ */
143
+ createChildNodePropsAsync: async (props) => {
144
+ if (!hasFilter) {
145
+ return undefined;
146
+ }
147
+ const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);
148
+ for (const filteredChildrenNodeIdentifierPath of filteringProps.filteredNodePaths) {
149
+ const normalizedPath = HierarchyFilteringPath.normalize(filteredChildrenNodeIdentifierPath);
150
+ /* c8 ignore next 3 */
151
+ if (normalizedPath.path.length === 0) {
152
+ continue;
153
+ }
154
+ const matchesPossiblyPromise = props.pathMatcher(normalizedPath.path[0]);
155
+ if (matchesPossiblyPromise instanceof Promise) {
156
+ if (!(await matchesPossiblyPromise)) {
157
+ continue;
158
+ }
159
+ }
160
+ if (!matchesPossiblyPromise) {
161
+ continue;
162
+ }
163
+ reducer.accept(normalizedPath);
164
+ }
165
+ return reducer.getNodeProps();
166
+ },
167
+ };
168
+ }
169
+ class MatchingFilteringPathsReducer {
170
+ _hasFilterTargetAncestor;
171
+ _filteredChildrenIdentifierPaths = new Array();
172
+ _isFilterTarget = false;
173
+ _filterTargetOptions = undefined;
174
+ _needsAutoExpand = false;
175
+ constructor(_hasFilterTargetAncestor) {
176
+ this._hasFilterTargetAncestor = _hasFilterTargetAncestor;
177
+ }
178
+ accept({ path, options }) {
179
+ if (path.length === 1) {
180
+ this._isFilterTarget = true;
181
+ this._filterTargetOptions = HierarchyFilteringPath.mergeOptions(this._filterTargetOptions, options);
182
+ }
183
+ else if (path.length > 1) {
184
+ this._filteredChildrenIdentifierPaths.push({ path: path.slice(1), options });
185
+ if (options?.autoExpand) {
186
+ this._needsAutoExpand = true;
187
+ }
188
+ }
189
+ }
190
+ getNodeProps() {
191
+ return {
192
+ ...(this._hasFilterTargetAncestor || this._isFilterTarget || this._filteredChildrenIdentifierPaths.length > 0
193
+ ? {
194
+ filtering: {
195
+ ...(this._hasFilterTargetAncestor ? { hasFilterTargetAncestor: true } : undefined),
196
+ ...(this._isFilterTarget ? { isFilterTarget: true, filterTargetOptions: this._filterTargetOptions } : undefined),
197
+ ...(this._filteredChildrenIdentifierPaths.length > 0 ? { filteredChildrenIdentifierPaths: this._filteredChildrenIdentifierPaths } : undefined),
198
+ },
199
+ }
200
+ : undefined),
201
+ ...(this._needsAutoExpand ? { autoExpand: true } : undefined),
202
+ };
203
+ }
204
+ }
71
205
  //# sourceMappingURL=HierarchyFiltering.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyFiltering.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyFiltering.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAmChG,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,sBAAsB,CAiDtC;AAjDD,WAAiB,sBAAsB;IACrC;;;OAGG;IACH,SAAgB,SAAS,CAAC,MAA8B;QACtD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;QAC9C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IALe,gCAAS,YAKxB,CAAA;IAED;;;;;;;;;;;;;OAaG;IACH,SAA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AAC;AAChB,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 { NonGroupingHierarchyNode } from \"./HierarchyNode.js\";\nimport { HierarchyNodeIdentifiersPath } from \"./HierarchyNodeIdentifier.js\";\nimport { GroupingNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilterTargetGroupingNodeInfo {\n /** Key of the grouping node. */\n key: GroupingNodeKey;\n\n /**\n * Depth of the grouping node in the hierarchy.\n * Generally, it can be retrieved from `parentKeys.length`.\n */\n depth: 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 `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,\n * will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilterTargetGroupingNodeInfo;\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, options: undefined };\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 both inputs are objects, return the one with the greater `depth` attribute.\n * - else if one input is an object, return it.\n * - else, return `false` or `undefined`.\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[\"autoExpand\"] => {\n if (rhs.autoExpand === true || lhs.autoExpand === true) {\n return true;\n }\n if (typeof lhs.autoExpand === \"object\") {\n if (typeof rhs.autoExpand === \"object\" && rhs.autoExpand.depth > lhs.autoExpand.depth) {\n return rhs.autoExpand;\n }\n return lhs.autoExpand;\n }\n return rhs.autoExpand;\n })(),\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 */\nexport function extractFilteringProps(\n rootLevelFilteringProps: HierarchyFilteringPath[],\n parentNode: Pick<NonGroupingHierarchyNode, \"filtering\"> | undefined,\n):\n | {\n filteredNodePaths: HierarchyFilteringPath[];\n hasFilterTargetAncestor: boolean;\n }\n | undefined {\n if (!parentNode) {\n return { filteredNodePaths: rootLevelFilteringProps, hasFilterTargetAncestor: false };\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"]}
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,EAAmC,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AA+B5G,c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------------------------------\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, GroupingNodeKey, HierarchyNodeKey, InstancesNodeKey } from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport interface FilterTargetGroupingNodeInfo {\n /** Key of the grouping node. */\n key: GroupingNodeKey;\n\n /**\n * Depth of the grouping node in the hierarchy.\n * Generally, it can be retrieved from `parentKeys.length`.\n */\n depth: 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 `FilterTargetGroupingNodeInfo`, then all nodes up to the grouping node that matches this property,\n * will have `autoExpand` flag.\n */\n autoExpand?: boolean | FilterTargetGroupingNodeInfo;\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 both inputs are objects, return the one with the greater `depth` attribute.\n * - else if one input is an object, return it.\n * - else, return `false` or `undefined`.\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[\"autoExpand\"] => {\n if (rhs.autoExpand === true || lhs.autoExpand === true) {\n return true;\n }\n if (typeof lhs.autoExpand === \"object\") {\n if (typeof rhs.autoExpand === \"object\" && rhs.autoExpand.depth > lhs.autoExpand.depth) {\n return rhs.autoExpand;\n }\n return lhs.autoExpand;\n }\n return rhs.autoExpand;\n })(),\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 ): Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | 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: async (props: {\n pathMatcher: (identifier: HierarchyNodeIdentifier) => boolean | Promise<boolean>;\n }): Promise<Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> | undefined> => {\n if (!hasFilter) {\n return undefined;\n }\n const reducer = new MatchingFilteringPathsReducer(filteringProps?.hasFilterTargetAncestor);\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 if (!(await matchesPossiblyPromise)) {\n continue;\n }\n }\n if (!matchesPossiblyPromise) {\n continue;\n }\n\n reducer.accept(normalizedPath);\n }\n return reducer.getNodeProps();\n },\n };\n}\n\ntype NormalizedFilteringPath = ReturnType<(typeof HierarchyFilteringPath)[\"normalize\"]>;\nclass MatchingFilteringPathsReducer {\n private _filteredChildrenIdentifierPaths = new Array<NormalizedFilteringPath>();\n private _isFilterTarget = false;\n private _filterTargetOptions = undefined as HierarchyFilteringPathOptions | undefined;\n private _needsAutoExpand = 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 if (options?.autoExpand) {\n this._needsAutoExpand = true;\n }\n }\n }\n public getNodeProps(): Pick<HierarchyNode, \"filtering\" | \"autoExpand\"> {\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._needsAutoExpand ? { autoExpand: true } : undefined),\n };\n }\n}\n"]}
@@ -18,6 +18,7 @@ export type HierarchyNodeFilteringProps = {
18
18
  });
19
19
  /** @public */
20
20
  export declare namespace HierarchyNodeFilteringProps {
21
+ /** @deprecated in 1.3. Use `createHierarchyFilteringHelper` and its `createChildNodeProps` function to create filtering props for nodes. */
21
22
  function create(props: {
22
23
  hasFilterTargetAncestor?: boolean;
23
24
  filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNode.d.ts","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,iBAA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AE,kCAAkC,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAEpH;IACD,sEAAsE;IACtE,SAAgB,2BAA2B,CAAC,KAAK,SAAS;QAAE,GAAG,EAAE,gBAAgB,CAAA;KAAE,EACjF,IAAI,EAAE,KAAK,GACV,IAAI,IAAI,KAAK,GAAG;QAAE,GAAG,EAAE,4BAA4B,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAE9G;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAAC,KAAK,SAAS;QAAE,GAAG,EAAE,gBAAgB,CAAA;KAAE,EACtF,IAAI,EAAE,KAAK,GACV,IAAI,IAAI,KAAK,GAAG;QAAE,GAAG,EAAE,iCAAiC,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAEnH;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CAAC,KAAK,SAAS;QAAE,GAAG,EAAE,gBAAgB,CAAA;KAAE,EAC5E,IAAI,EAAE,KAAK,GACV,IAAI,IAAI,KAAK,GAAG;QAAE,GAAG,EAAE,uBAAuB,CAAC;QAAC,iBAAiB,CAAC,EAAE,SAAS,CAAA;KAAE,GAAG,qBAAqB,CAEzG;CACF;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,KAAK,GAAG,aAAa,IAAI,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC"}
@@ -7,6 +7,8 @@ import { HierarchyNodeKey, } from "./HierarchyNodeKey.js";
7
7
  // eslint-disable-next-line @typescript-eslint/no-redeclare
8
8
  export var HierarchyNodeFilteringProps;
9
9
  (function (HierarchyNodeFilteringProps) {
10
+ /** @deprecated in 1.3. Use `createHierarchyFilteringHelper` and its `createChildNodeProps` function to create filtering props for nodes. */
11
+ /* c8 ignore start */
10
12
  function create(props) {
11
13
  const { hasFilterTargetAncestor, filteredChildrenIdentifierPaths, isFilterTarget, filterTargetOptions } = props;
12
14
  if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {
@@ -19,6 +21,7 @@ export var HierarchyNodeFilteringProps;
19
21
  return undefined;
20
22
  }
21
23
  HierarchyNodeFilteringProps.create = create;
24
+ /* c8 ignore end */
22
25
  })(HierarchyNodeFilteringProps || (HierarchyNodeFilteringProps = {}));
23
26
  /** @public */
24
27
  // eslint-disable-next-line @typescript-eslint/no-redeclare
@@ -1 +1 @@
1
- {"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,OAAO,EAIL,gBAAgB,GASjB,MAAM,uBAAuB,CAAC;AAoB/B,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,2BAA2B,CAiB3C;AAjBD,WAAiB,2BAA2B;IAC1C,SAAgB,MAAM,CAAC,KAKtB;QACC,MAAM,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,cAAc,EAAE,mBAAmB,EAAE,GAAG,KAAK,CAAC;QAChH,IAAI,cAAc,IAAI,uBAAuB,IAAI,+BAA+B,EAAE,MAAM,EAAE,CAAC;YACzF,OAAO;gBACL,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBACzE,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,uBAAuB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;gBACtE,GAAG,CAAC,CAAC,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,+BAA+B,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;aACjG,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAfe,kCAAM,SAerB,CAAA;AACH,CAAC,EAjBgB,2BAA2B,KAA3B,2BAA2B,QAiB3C;AA2DD,cAA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CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAJe,yCAA2B,8BAI1C,CAAA;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAEX,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IAJe,8CAAgC,mCAI/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAEX,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IAJe,oCAAsB,yBAIrC,CAAA;AACH,CAAC,EArDgB,aAAa,KAAb,aAAa,QAqD7B","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 { OmitOverUnion } from \"@itwin/presentation-shared\";\nimport { HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"./HierarchyFiltering.js\";\nimport {\n ClassGroupingNodeKey,\n GenericNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n IModelHierarchyNodeKey,\n IModelInstanceKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n} from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport type HierarchyNodeFilteringProps = {\n /** If set to true, then one of the ancestor nodes in the hierarchy is the filter target. */\n hasFilterTargetAncestor?: boolean;\n /** Paths to node's children that are filter targets. */\n filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];\n} & (\n | {\n /** Whether or not this node is a filter target. */\n isFilterTarget?: false;\n }\n | {\n /** Whether or not this node is a filter target. */\n isFilterTarget: true;\n /** Options that were used to filter the node. */\n filterTargetOptions?: HierarchyFilteringPathOptions;\n }\n);\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodeFilteringProps {\n export function create(props: {\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];\n isFilterTarget?: boolean;\n filterTargetOptions?: HierarchyFilteringPathOptions;\n }): HierarchyNodeFilteringProps | undefined {\n const { hasFilterTargetAncestor, filteredChildrenIdentifierPaths, isFilterTarget, filterTargetOptions } = props;\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n return {\n ...(isFilterTarget ? { isFilterTarget, filterTargetOptions } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n }\n return undefined;\n }\n}\n\n/**\n * A data structure that defines attributes that are common to all types of hierarchy nodes.\n * @public\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n /** Data that may be assigned to the node if filtering is enabled */\n filtering?: HierarchyNodeFilteringProps;\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @public\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: GenericNodeKey | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @public\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: IModelInstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @public\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a generic node */\n export function isGeneric<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: GenericNodeKey } {\n return HierarchyNodeKey.isGeneric(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isIModelNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: IModelHierarchyNodeKey } {\n return HierarchyNodeKey.isIModelNodeKey(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & GroupingHierarchyNode {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n * @public\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n"]}
1
+ {"version":3,"file":"HierarchyNode.js","sourceRoot":"","sources":["../../../src/hierarchies/HierarchyNode.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAIhG,OAAO,EAIL,gBAAgB,GASjB,MAAM,uBAAuB,CAAC;AAoB/B,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,2BAA2B,CAoB3C;AApBD,WAAiB,2BAA2B;IAC1C,4IAA4I;IAC5I,qBAAqB;IACrB,SAAgB,MAAM,CAAC,KA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,IAAW;QACjF,OAAO,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAFe,4BAAc,iBAE7B,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAEX,OAAO,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAJe,iCAAmB,sBAIlC,CAAA;IACD,6DAA6D;IAC7D,SAAgB,mBAAmB,CACjC,IAAW;QAEX,OAAO,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpD,CAAC;IAJe,iCAAmB,sBAIlC,CAAA;IACD,gFAAgF;IAChF,SAAgB,iCAAiC,CAC/C,IAAW;QAEX,OAAO,gBAAgB,CAAC,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClE,CAAC;IAJe,+CAAiC,oCAIhD,CAAA;IACD,sEAAsE;IACtE,SAAgB,2BAA2B,CACzC,IAAW;QAEX,OAAO,gBAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,CAAC;IAJe,yCAA2B,8BAI1C,CAAA;IACD,4EAA4E;IAC5E,SAAgB,gCAAgC,CAC9C,IAAW;QAEX,OAAO,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC;IAJe,8CAAgC,mCAI/C,CAAA;IACD,gEAAgE;IAChE,SAAgB,sBAAsB,CACpC,IAAW;QAEX,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IAJe,oCAAsB,yBAIrC,CAAA;AACH,CAAC,EArDgB,aAAa,KAAb,aAAa,QAqD7B","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 { OmitOverUnion } from \"@itwin/presentation-shared\";\nimport { HierarchyFilteringPath, HierarchyFilteringPathOptions } from \"./HierarchyFiltering.js\";\nimport {\n ClassGroupingNodeKey,\n GenericNodeKey,\n GroupingNodeKey,\n HierarchyNodeKey,\n IModelHierarchyNodeKey,\n IModelInstanceKey,\n InstancesNodeKey,\n LabelGroupingNodeKey,\n PropertyGroupingNodeKey,\n PropertyOtherValuesGroupingNodeKey,\n PropertyValueGroupingNodeKey,\n PropertyValueRangeGroupingNodeKey,\n} from \"./HierarchyNodeKey.js\";\n\n/** @public */\nexport type HierarchyNodeFilteringProps = {\n /** If set to true, then one of the ancestor nodes in the hierarchy is the filter target. */\n hasFilterTargetAncestor?: boolean;\n /** Paths to node's children that are filter targets. */\n filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];\n} & (\n | {\n /** Whether or not this node is a filter target. */\n isFilterTarget?: false;\n }\n | {\n /** Whether or not this node is a filter target. */\n isFilterTarget: true;\n /** Options that were used to filter the node. */\n filterTargetOptions?: HierarchyFilteringPathOptions;\n }\n);\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNodeFilteringProps {\n /** @deprecated in 1.3. Use `createHierarchyFilteringHelper` and its `createChildNodeProps` function to create filtering props for nodes. */\n /* c8 ignore start */\n export function create(props: {\n hasFilterTargetAncestor?: boolean;\n filteredChildrenIdentifierPaths?: HierarchyFilteringPath[];\n isFilterTarget?: boolean;\n filterTargetOptions?: HierarchyFilteringPathOptions;\n }): HierarchyNodeFilteringProps | undefined {\n const { hasFilterTargetAncestor, filteredChildrenIdentifierPaths, isFilterTarget, filterTargetOptions } = props;\n if (isFilterTarget || hasFilterTargetAncestor || filteredChildrenIdentifierPaths?.length) {\n return {\n ...(isFilterTarget ? { isFilterTarget, filterTargetOptions } : undefined),\n ...(hasFilterTargetAncestor ? { hasFilterTargetAncestor } : undefined),\n ...(!!filteredChildrenIdentifierPaths?.length ? { filteredChildrenIdentifierPaths } : undefined),\n };\n }\n return undefined;\n }\n /* c8 ignore end */\n}\n\n/**\n * A data structure that defines attributes that are common to all types of hierarchy nodes.\n * @public\n */\ninterface BaseHierarchyNode {\n /** Identifiers of all node ancestors. Can be used to identify a node in the hierarchy. */\n parentKeys: HierarchyNodeKey[];\n /** Node's display label. */\n label: string;\n /** A flag indicating whether the node has children or not. */\n children: boolean;\n /** A flag indicating whether this node should be auto-expanded in the UI. */\n autoExpand?: boolean;\n /** Additional data that may be assigned to this node. */\n extendedData?: { [key: string]: any };\n /** Data that may be assigned to the node if filtering is enabled */\n filtering?: HierarchyNodeFilteringProps;\n}\n\n/**\n * A data structure that represents a single non-grouping hierarchy node.\n * @public\n */\nexport interface NonGroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify the node in its hierarchy level. */\n key: GenericNodeKey | InstancesNodeKey;\n /**\n * Identifies whether the hierarchy level below this node supports filtering. If not, supplying an instance\n * filter when requesting child hierarchy level will have no effect.\n */\n supportsFiltering?: boolean;\n}\n\n/**\n * A data structure that represents a grouping node that groups other nodes.\n * @public\n */\nexport interface GroupingHierarchyNode extends BaseHierarchyNode {\n /** An identifier to identify this grouping node in its hierarchy level. */\n key: GroupingNodeKey;\n\n /**\n * Keys of all instances grouped by this node, including deeply nested under\n * other grouping nodes.\n */\n groupedInstanceKeys: IModelInstanceKey[];\n\n /** The closest ancestor node that is not a grouping node. May be `undefined` if the grouping node grouped root level nodes. */\n nonGroupingAncestor?: ParentHierarchyNode<NonGroupingHierarchyNode>;\n}\n\n/**\n * A data structure that represents a single hierarchy node.\n * @public\n */\nexport type HierarchyNode = NonGroupingHierarchyNode | GroupingHierarchyNode;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace HierarchyNode {\n /** Checks whether the given node is a generic node */\n export function isGeneric<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: GenericNodeKey } {\n return HierarchyNodeKey.isGeneric(node.key);\n }\n /** Checks whether the given node is a standard (iModel content based) node */\n export function isIModelNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & { key: IModelHierarchyNodeKey } {\n return HierarchyNodeKey.isIModelNodeKey(node.key);\n }\n /** Checks whether the given node is an ECInstances-based node */\n export function isInstancesNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & NonGroupingHierarchyNode & { key: InstancesNodeKey } {\n return HierarchyNodeKey.isInstances(node.key);\n }\n /** Checks whether the given node is a grouping node */\n export function isGroupingNode<TNode extends { key: HierarchyNodeKey }>(node: TNode): node is TNode & GroupingHierarchyNode {\n return HierarchyNodeKey.isGrouping(node.key);\n }\n /** Checks whether the given node is a class grouping node */\n export function isClassGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: ClassGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isClassGrouping(node.key);\n }\n /** Checks whether the given node is a label grouping node */\n export function isLabelGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: LabelGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isLabelGrouping(node.key);\n }\n /** Checks whether the given node is property grouping node for other values */\n export function isPropertyOtherValuesGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyOtherValuesGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyOtherValuesGrouping(node.key);\n }\n /** Checks whether the given node is a property value grouping node */\n export function isPropertyValueGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueGrouping(node.key);\n }\n /** Checks whether the given node is a property value range grouping node */\n export function isPropertyValueRangeGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyValueRangeGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyValueRangeGrouping(node.key);\n }\n /** Checks whether the given node is a property grouping node */\n export function isPropertyGroupingNode<TNode extends { key: HierarchyNodeKey }>(\n node: TNode,\n ): node is TNode & { key: PropertyGroupingNodeKey; supportsFiltering?: undefined } & GroupingHierarchyNode {\n return HierarchyNodeKey.isPropertyGrouping(node.key);\n }\n}\n\n/**\n * A type of `HierarchyNode` that doesn't know about its children and is an input when requesting\n * them using `HierarchyProvider.getNodes`.\n * @public\n */\nexport type ParentHierarchyNode<TBase = HierarchyNode> = OmitOverUnion<TBase, \"children\">;\n"]}
@@ -1,5 +1,5 @@
1
1
  import { GenericInstanceFilter } from "@itwin/core-common";
2
- import { Event, InstanceKey, IPrimitiveValueFormatter } from "@itwin/presentation-shared";
2
+ import { Event, InstanceKey, IPrimitiveValueFormatter, Props } from "@itwin/presentation-shared";
3
3
  import { HierarchyFilteringPath } from "./HierarchyFiltering.js";
4
4
  import { HierarchyNode, ParentHierarchyNode } from "./HierarchyNode.js";
5
5
  /**
@@ -19,33 +19,68 @@ export interface GetHierarchyNodesProps {
19
19
  * Has no effect if `parentNode` is a `GroupingNode`.
20
20
  */
21
21
  hierarchyLevelSizeLimit?: number | "unbounded";
22
- /** When set to true ignores the cache and fetches the nodes again. */
22
+ /** When set to `true` ignores the cache and fetches the nodes again. */
23
23
  ignoreCache?: boolean;
24
24
  }
25
+ /**
26
+ * Event arguments for `HierarchyProvider.hierarchyChanged` event.
27
+ * @public
28
+ */
29
+ interface HierarchyChangedEventArgs {
30
+ /** Set when the hierarchy change was caused by a formatter change. */
31
+ formatterChange?: {
32
+ newFormatter: IPrimitiveValueFormatter | undefined;
33
+ };
34
+ /** Set when the hierarchy change was caused by a hierarchy filter change. */
35
+ filterChange?: {
36
+ newFilter: Props<HierarchyProvider["setHierarchyFilter"]>;
37
+ };
38
+ }
25
39
  /**
26
40
  * An interface for a hierarchy provider that knows how to create child nodes for a given parent node.
27
41
  * @public
28
42
  */
29
43
  export interface HierarchyProvider {
30
44
  /**
31
- * An event that provider raises when the internal data source changes, resulting in a
32
- * hierarchy change.
45
+ * An event that provider raises due to a hierarchy change, that requires a reload. Provider may
46
+ * set additional event arguments to provide extra information about what caused the change.
33
47
  *
34
48
  * Consumers are expected to subscribe to this event and reload the hierarchy when it's raised.
49
+ * Implementations may provide additional details on what caused the change through the optional
50
+ * event arguments.
51
+ */
52
+ readonly hierarchyChanged: Event<(args?: HierarchyChangedEventArgs) => void>;
53
+ /**
54
+ * Gets nodes for the specified parent node. This is **the method to implement**, otherwise
55
+ * the provider doesn't return any nodes.
35
56
  */
36
- readonly hierarchyChanged: Event<() => void>;
37
- /** Gets nodes for the specified parent node. */
38
57
  getNodes(props: GetHierarchyNodesProps): AsyncIterableIterator<HierarchyNode>;
39
- /** Gets instance keys for the specified parent node. */
58
+ /**
59
+ * Gets instance keys for the specified parent node.
60
+ *
61
+ * The result of this method may be used to determine instances whose nodes would be displayed as children
62
+ * of the specified parent node. For such use cases calling this method should be more efficient compared
63
+ * to calling `getNodes`.
64
+ */
40
65
  getNodeInstanceKeys(props: Omit<GetHierarchyNodesProps, "ignoreCache">): AsyncIterableIterator<InstanceKey>;
41
66
  /**
42
67
  * Overrides the property value formatter used by the hierarchy provider. Setting to `undefined`
43
- * resets the formatter to the result of `createDefaultValueFormatter` called with default parameters.
68
+ * resets the formatter, but what that means depends on the provider implementation - it could just
69
+ * use unformatted values, or use some default formatter, e.g. the on created by `createDefaultValueFormatter`
70
+ * from `@itwin/presentation-shared` package.
71
+ *
72
+ * @note Changing formatter is expected to trigger the `hierarchyChanged` event with `formatterChange` arg.
44
73
  */
45
74
  setFormatter(formatter: IPrimitiveValueFormatter | undefined): void;
46
75
  /**
47
76
  * Sets the hierarchy filter used by this hierarchy provider. Setting to `undefined`
48
77
  * removes the filter.
78
+ *
79
+ * @note There's a difference between `undefined` filter and filter with empty paths list. The
80
+ * former means no filter is applied, while the latter means the filter is applied and it filters-out
81
+ * all hierarchy.
82
+ *
83
+ * @note Changing filter is expected to trigger the `hierarchyChanged` event with `filterChange` arg.
49
84
  */
50
85
  setHierarchyFilter(props: {
51
86
  /** A list of node identifiers from root to target node. */