@itwin/unified-selection 0.1.0 → 0.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 (82) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +104 -6
  3. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts +33 -0
  4. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
  5. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js +62 -0
  6. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js.map +1 -0
  7. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
  8. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  9. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +205 -0
  10. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  11. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts +37 -0
  12. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts.map +1 -0
  13. package/lib/cjs/unified-selection/HiliteSetProvider.js +344 -0
  14. package/lib/cjs/unified-selection/HiliteSetProvider.js.map +1 -0
  15. package/lib/cjs/unified-selection/Selectable.d.ts +0 -3
  16. package/lib/cjs/unified-selection/Selectable.d.ts.map +1 -1
  17. package/lib/cjs/unified-selection/Selectable.js +2 -2
  18. package/lib/cjs/unified-selection/Selectable.js.map +1 -1
  19. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts +11 -7
  20. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  21. package/lib/cjs/unified-selection/SelectionChangeEvent.js +1 -1
  22. package/lib/cjs/unified-selection/SelectionChangeEvent.js.map +1 -1
  23. package/lib/cjs/unified-selection/SelectionScope.d.ts +44 -0
  24. package/lib/cjs/unified-selection/SelectionScope.d.ts.map +1 -0
  25. package/lib/cjs/unified-selection/SelectionScope.js +193 -0
  26. package/lib/cjs/unified-selection/SelectionScope.js.map +1 -0
  27. package/lib/cjs/unified-selection/SelectionStorage.d.ts +34 -29
  28. package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +1 -1
  29. package/lib/cjs/unified-selection/SelectionStorage.js +32 -18
  30. package/lib/cjs/unified-selection/SelectionStorage.js.map +1 -1
  31. package/lib/cjs/unified-selection/Utils.d.ts +7 -0
  32. package/lib/cjs/unified-selection/Utils.d.ts.map +1 -0
  33. package/lib/cjs/unified-selection/Utils.js +24 -0
  34. package/lib/cjs/unified-selection/Utils.js.map +1 -0
  35. package/lib/cjs/unified-selection/types/IModel.d.ts +84 -0
  36. package/lib/cjs/unified-selection/types/IModel.d.ts.map +1 -0
  37. package/lib/cjs/unified-selection/types/IModel.js +24 -0
  38. package/lib/cjs/unified-selection/types/IModel.js.map +1 -0
  39. package/lib/cjs/unified-selection.d.ts +5 -7
  40. package/lib/cjs/unified-selection.d.ts.map +1 -1
  41. package/lib/cjs/unified-selection.js +11 -7
  42. package/lib/cjs/unified-selection.js.map +1 -1
  43. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts +33 -0
  44. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
  45. package/lib/esm/unified-selection/CachingHiliteSetProvider.js +58 -0
  46. package/lib/esm/unified-selection/CachingHiliteSetProvider.js.map +1 -0
  47. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
  48. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  49. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +200 -0
  50. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  51. package/lib/esm/unified-selection/HiliteSetProvider.d.ts +37 -0
  52. package/lib/esm/unified-selection/HiliteSetProvider.d.ts.map +1 -0
  53. package/lib/esm/unified-selection/HiliteSetProvider.js +340 -0
  54. package/lib/esm/unified-selection/HiliteSetProvider.js.map +1 -0
  55. package/lib/esm/unified-selection/Selectable.d.ts +0 -3
  56. package/lib/esm/unified-selection/Selectable.d.ts.map +1 -1
  57. package/lib/esm/unified-selection/Selectable.js.map +1 -1
  58. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts +11 -7
  59. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  60. package/lib/esm/unified-selection/SelectionChangeEvent.js +1 -1
  61. package/lib/esm/unified-selection/SelectionChangeEvent.js.map +1 -1
  62. package/lib/esm/unified-selection/SelectionScope.d.ts +44 -0
  63. package/lib/esm/unified-selection/SelectionScope.d.ts.map +1 -0
  64. package/lib/esm/unified-selection/SelectionScope.js +189 -0
  65. package/lib/esm/unified-selection/SelectionScope.js.map +1 -0
  66. package/lib/esm/unified-selection/SelectionStorage.d.ts +34 -29
  67. package/lib/esm/unified-selection/SelectionStorage.d.ts.map +1 -1
  68. package/lib/esm/unified-selection/SelectionStorage.js +31 -17
  69. package/lib/esm/unified-selection/SelectionStorage.js.map +1 -1
  70. package/lib/esm/unified-selection/Utils.d.ts +7 -0
  71. package/lib/esm/unified-selection/Utils.d.ts.map +1 -0
  72. package/lib/esm/unified-selection/Utils.js +20 -0
  73. package/lib/esm/unified-selection/Utils.js.map +1 -0
  74. package/lib/esm/unified-selection/types/IModel.d.ts +84 -0
  75. package/lib/esm/unified-selection/types/IModel.d.ts.map +1 -0
  76. package/lib/esm/unified-selection/types/IModel.js +21 -0
  77. package/lib/esm/unified-selection/types/IModel.js.map +1 -0
  78. package/lib/esm/unified-selection.d.ts +5 -7
  79. package/lib/esm/unified-selection.d.ts.map +1 -1
  80. package/lib/esm/unified-selection.js +5 -7
  81. package/lib/esm/unified-selection.js.map +1 -1
  82. package/package.json +28 -15
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/HiliteSetProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAE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CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAED,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,OAAO;IACP,UAAU;IACV,aAAa;IACb,mBAAmB;IACnB,yBAAyB;IACzB,kBAAkB;IAClB,SAAS;IACT,SAAS;CACD,CAAC;AAQX,SAAS,MAAM;IACb,OAAO,UAAU,GAAkB;QACjC,OAAO,GAAG,CAAC,IAAI,CACb,IAAA,WAAI,EACF,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACX,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,OAAO,GAAG,CAAC,GAAG,CAAC;gBACf,OAAO,GAAG,CAAC;YACb,CAAC;YAED,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACjB,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;YACd,OAAO,GAAG,CAAC;QACb,CAAC,EACD,EAAE,GAAG,EAAE,IAAI,GAAG,EAAK,EAA8B,CAClD,EACD,IAAA,UAAG,EAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EACrB,IAAA,aAAM,EAAC,CAAC,CAAC,EAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { EMPTY, filter, forkJoin, from, map, merge, mergeMap, Observable, scan, shareReplay, Subject, toArray } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { EC, ECSchemaProvider, ECSqlBinding, ECSqlQueryExecutor, parseFullClassName } from \"@itwin/presentation-shared\";\nimport { SelectableInstanceKey, Selectables } from \"./Selectable\";\nimport { formIdBindings } from \"./Utils\";\n\nconst HILITE_SET_EMIT_FREQUENCY = 20;\n\n/**\n * A set of model, subcategory and element ids that can be used for specifying hilite.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/hiliteset/\n * @beta\n */\nexport interface HiliteSet {\n models: string[];\n subCategories: string[];\n elements: string[];\n}\n\n/**\n * Props for creating a `HiliteSetProvider` instance.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface HiliteSetProviderProps {\n imodelAccess: ECSchemaProvider & ECSqlQueryExecutor;\n}\n\n/**\n * Defines return value of `createHiliteSetProvider`.\n *\n * @beta Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n */\nexport interface HiliteSetProvider {\n /** Get the current hilite set iterator for the specified imodel */\n getHiliteSet(props: { selectables: Selectables }): AsyncIterableIterator<HiliteSet>;\n}\n\n/**\n * Creates a hilite set provider that returns a `HiliteSet` for given selectables.\n * @beta\n */\nexport function createHiliteSetProvider(props: HiliteSetProviderProps): HiliteSetProvider {\n return new HiliteSetProviderImpl(props);\n}\n\nclass HiliteSetProviderImpl implements HiliteSetProvider {\n private _imodelAccess: ECSchemaProvider & ECSqlQueryExecutor;\n // Map between a class name and its type\n private _classRelationCache: Map<string, InstanceIdType | Promise<InstanceIdType>>;\n\n constructor(props: HiliteSetProviderProps) {\n this._imodelAccess = props.imodelAccess;\n this._classRelationCache = new Map();\n }\n\n /**\n * Get hilite set iterator for supplied `Selectables`.\n */\n public getHiliteSet(props: { selectables: Selectables }): AsyncIterableIterator<HiliteSet> {\n const obs = this.getHiliteSetObservable(props);\n return eachValueFrom(obs);\n }\n\n /**\n * Returns a \"hot\" observable of hilite sets.\n */\n private getHiliteSetObservable({ selectables }: { selectables: Selectables }): Subject<HiliteSet> {\n const instancesByType = this.getInstancesByType(selectables);\n const observables: { [key in keyof HiliteSet]?: Observable<string> } = {\n models: this.getHilitedModels(instancesByType),\n subCategories: this.getHilitedSubCategories(instancesByType),\n elements: this.getHilitedElements(instancesByType),\n };\n\n let hiliteSet: HiliteSet = { models: [], subCategories: [], elements: [] };\n let lastEmitTime = performance.now();\n const subject = new Subject<HiliteSet>();\n const subscriptions = ([\"models\", \"subCategories\", \"elements\"] as const).map((key) =>\n observables[key]!.subscribe({\n next(val) {\n hiliteSet[key].push(val);\n if (performance.now() - lastEmitTime < HILITE_SET_EMIT_FREQUENCY) {\n return;\n }\n subject.next(hiliteSet);\n hiliteSet = { models: [], subCategories: [], elements: [] };\n lastEmitTime = performance.now();\n },\n complete() {\n observables[key] = undefined;\n if (observables.models || observables.subCategories || observables.elements) {\n return;\n }\n // Emit last batch before completing the observable.\n if (hiliteSet.elements.length || hiliteSet.models.length || hiliteSet.subCategories.length) {\n subject.next(hiliteSet);\n }\n subject.complete();\n },\n error(err) {\n subscriptions.forEach((x) => x.unsubscribe());\n subscriptions.length = 0;\n subject.error(err);\n },\n }),\n );\n\n return subject;\n }\n\n private async getType(key: SelectableInstanceKey): Promise<InstanceIdType> {\n const cachedType = this._classRelationCache.get(key.className.replace(\".\", \":\"));\n if (cachedType) {\n return cachedType;\n }\n\n const promise = this.getTypeImpl(key).then((res) => {\n // Update the cache with the result of the promise.\n this._classRelationCache.set(key.className, res);\n return res;\n });\n\n // Add the promise to cache to prevent `getTypeImpl` being called multiple times.\n this._classRelationCache.set(key.className, promise);\n return promise;\n }\n\n private async getTypeImpl(key: SelectableInstanceKey): Promise<InstanceIdType> {\n const keyClass = await this.getClass(key.className);\n return (\n (keyClass &&\n ((await this.checkType(keyClass, \"BisCore\", \"Subject\", \"subject\")) ??\n (await this.checkType(keyClass, \"BisCore\", \"Model\", \"model\")) ??\n (await this.checkType(keyClass, \"BisCore\", \"Category\", \"category\")) ??\n (await this.checkType(keyClass, \"BisCore\", \"SubCategory\", \"subCategory\")) ??\n (await this.checkType(keyClass, \"Functional\", \"FunctionalElement\", \"functionalElement\")) ??\n (await this.checkType(keyClass, \"BisCore\", \"GroupInformationElement\", \"groupInformationElement\")) ??\n (await this.checkType(keyClass, \"BisCore\", \"GeometricElement\", \"geometricElement\")) ??\n (await this.checkType(keyClass, \"BisCore\", \"Element\", \"element\")))) ??\n \"unknown\"\n );\n }\n\n private async checkType(keyClass: EC.Class, schemaName: string, className: string, type: InstanceIdType) {\n return (await keyClass.is(className, schemaName)) ? type : undefined;\n }\n\n private getInstancesByType(selectables: Selectables): InstancesByType {\n const keyTypeObs = merge(\n from(selectables.custom.values()).pipe(mergeMap((selectable) => selectable.loadInstanceKeys())),\n from(selectables.instanceKeys).pipe(mergeMap(([className, idSet]) => from(idSet).pipe(map((id) => ({ className, id }))))),\n ).pipe(\n // Get types for each instance key\n mergeMap((instanceKey) => from(this.getType(instanceKey)).pipe(map((instanceIdType) => ({ instanceId: instanceKey.id, instanceIdType })))),\n // Cache the results\n shareReplay(),\n );\n\n return Object.fromEntries(\n INSTANCE_TYPES.map((type) => [\n type,\n keyTypeObs.pipe(\n filter(({ instanceIdType }) => instanceIdType === type),\n map(({ instanceId }) => instanceId),\n unique(),\n ),\n ]),\n ) as InstancesByType;\n }\n\n private getHilitedModels(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n modelKeys: instancesByType.model.pipe(toArray()),\n subjectKeys: instancesByType.subject.pipe(toArray()),\n }).pipe(\n mergeMap(({ modelKeys, subjectKeys }) => {\n if (!modelKeys.length && !subjectKeys.length) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n `\n ChildSubjects(ECInstanceId, JsonProperties) AS (\n SELECT ECInstanceId, JsonProperties\n FROM BisCore.Subject\n WHERE ${formIdBindings(\"ECInstanceId\", subjectKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.JsonProperties\n FROM ChildSubjects s\n JOIN BisCore.Subject r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n Models(ECInstanceId) AS (\n SELECT s.ECInstanceId AS ECInstanceId\n FROM BisCore.Model s\n WHERE ${formIdBindings(\"ECInstanceId\", modelKeys, bindings)}\n )\n `,\n ];\n const ecsql = [\n `\n SELECT r.ECInstanceId AS ECInstanceId\n FROM ChildSubjects s\n JOIN BisCore.PhysicalPartition r ON r.Parent.Id = s.ECInstanceId OR json_extract(s.JsonProperties,'$.Subject.Model.TargetPartition') = printf('0x%x', r.ECInstanceId)\n `,\n `\n SELECT ECInstanceId FROM Models\n `,\n ].join(\" UNION \");\n return from(this._imodelAccess.createQueryReader({ ctes, ecsql, bindings }));\n }),\n map((row) => row.ECInstanceId),\n );\n }\n\n private getHilitedSubCategories(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n subCategoryKeys: instancesByType.subCategory.pipe(toArray()),\n categoryKeys: instancesByType.category.pipe(toArray()),\n }).pipe(\n mergeMap(({ subCategoryKeys, categoryKeys }) => {\n if (!subCategoryKeys.length && !categoryKeys.length) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n `\n CategorySubCategories(ECInstanceId) AS (\n SELECT r.ECInstanceId AS ECInstanceId\n FROM BisCore.Category s\n JOIN BisCore.SubCategory r ON r.Parent.Id = s.ECInstanceId\n WHERE ${formIdBindings(\"s.ECInstanceId\", categoryKeys, bindings)}\n )\n `,\n `\n SubCategories(ECInstanceId) AS (\n SELECT s.ECInstanceId AS ECInstanceId\n FROM BisCore.SubCategory s\n WHERE ${formIdBindings(\"s.ECInstanceId\", subCategoryKeys, bindings)}\n )\n `,\n ];\n const ecsql = [`SELECT ECInstanceId FROM CategorySubCategories`, `SELECT ECInstanceId FROM SubCategories`].join(\" UNION \");\n return from(this._imodelAccess.createQueryReader({ ctes, ecsql, bindings }));\n }),\n map((row) => row.ECInstanceId),\n );\n }\n\n private getHilitedElements(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n groupInformationElementKeys: instancesByType.groupInformationElement.pipe(toArray()),\n geometricElementKeys: instancesByType.geometricElement.pipe(toArray()),\n functionalElements: instancesByType.functionalElement.pipe(toArray()),\n elementKeys: instancesByType.element.pipe(toArray()),\n }).pipe(\n mergeMap(({ groupInformationElementKeys, geometricElementKeys, functionalElements, elementKeys }) => {\n const hasFunctionalElements = !!functionalElements.length;\n if (!groupInformationElementKeys.length && !geometricElementKeys.length && !elementKeys.length && !hasFunctionalElements) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n ...(hasFunctionalElements ? this.getHilitedFunctionalElementsQueryCTEs(functionalElements, bindings) : []),\n `\n GroupMembers(ECInstanceId, ECClassId) AS (\n SELECT TargetECInstanceId, TargetECClassId\n FROM BisCore.ElementGroupsMembers\n WHERE ${formIdBindings(\"SourceECInstanceId\", groupInformationElementKeys, bindings)}\n )\n `,\n `\n GroupGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM GroupMembers\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM GroupGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n ElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", elementKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM ElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n GeometricElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM BisCore.GeometricElement\n WHERE ${formIdBindings(\"ECInstanceId\", geometricElementKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM GeometricElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n ];\n const ecsql = [\n ...(hasFunctionalElements ? [\"SELECT ECInstanceId FROM FunctionalElementChildGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\"] : []),\n \"SELECT ECInstanceId FROM GeometricElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n \"SELECT ECInstanceId FROM GroupGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n \"SELECT ECInstanceId FROM ElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n ].join(\" UNION \");\n return from(this._imodelAccess.createQueryReader({ ctes, ecsql, bindings }));\n }),\n map((row) => row.ECInstanceId as string),\n );\n }\n\n private getHilitedFunctionalElementsQueryCTEs(functionalElements: string[], bindings: ECSqlBinding[]): string[] {\n return [\n `\n ChildFunctionalElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM Functional.FunctionalElement\n WHERE ${formIdBindings(\"ECInstanceId\", functionalElements, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.FunctionalElement r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n PhysicalElements(ECInstanceId, ECClassId) AS (\n SELECT r.SourceECInstanceId, r.SourceECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.PhysicalElementFulfillsFunction r ON r.TargetECInstanceId = s.ECInstanceId\n )\n `,\n `\n DrawingGraphicElements(ECInstanceId, ECClassId) AS (\n SELECT r.SourceECInstanceId, r.SourceECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.DrawingGraphicRepresentsFunctionalElement r ON r.TargetECInstanceId = s.ECInstanceId\n )\n `,\n `\n PhysicalElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM PhysicalElements\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM PhysicalElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n DrawingGraphicElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM DrawingGraphicElements\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM DrawingGraphicElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n FunctionalElementChildGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM PhysicalElementGeometricElements\n UNION\n SELECT ECInstanceId, ECClassId FROM DrawingGraphicElementGeometricElements\n )\n `,\n ];\n }\n\n private async getClass(fullClassName: string): Promise<EC.Class | undefined> {\n const { schemaName, className } = parseFullClassName(fullClassName);\n const schema = await this._imodelAccess.getSchema(schemaName);\n if (!schema) {\n return undefined;\n }\n const schemaClass = await schema.getClass(className);\n if (!schemaClass) {\n return undefined;\n }\n return schemaClass;\n }\n}\n\nconst INSTANCE_TYPES = [\n \"subject\",\n \"model\",\n \"category\",\n \"subCategory\",\n \"functionalElement\",\n \"groupInformationElement\",\n \"geometricElement\",\n \"element\",\n \"unknown\",\n] as const;\n\ntype InstanceIdType = (typeof INSTANCE_TYPES)[number];\n\ntype InstancesByType = {\n [idType in InstanceIdType]: Observable<string>;\n};\n\nfunction unique<T>() {\n return function (obs: Observable<T>): Observable<T> {\n return obs.pipe(\n scan(\n (acc, val) => {\n if (acc.set.has(val)) {\n delete acc.val;\n return acc;\n }\n\n acc.set.add(val);\n acc.val = val;\n return acc;\n },\n { set: new Set<T>() } as { set: Set<T>; val?: T },\n ),\n map(({ val }) => val),\n filter((x): x is T => !!x),\n );\n };\n}\n"]}
@@ -1,6 +1,3 @@
1
- /** @packageDocumentation
2
- * @module UnifiedSelection
3
- */
4
1
  /**
5
2
  * ECInstance selectable
6
3
  * @beta
@@ -1 +1 @@
1
- {"version":3,"file":"Selectable.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;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AE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAoB3E;IAED;;;;;OAKG;IACH,SAAgB,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAmB9E;IAED;;;;OAIG;IACH,SAAgB,KAAK,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAOvD;IAED;;;;OAIG;IACH,SAAgB,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,WAc3F;IAED;;;;OAIG;IACH,SAAgB,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,QAQ1G;CAKF"}
@@ -20,7 +20,7 @@ var Selectable;
20
20
  return !!selectable.identifier;
21
21
  }
22
22
  Selectable.isCustom = isCustom;
23
- })(Selectable = exports.Selectable || (exports.Selectable = {}));
23
+ })(Selectable || (exports.Selectable = Selectable = {}));
24
24
  /** @beta */
25
25
  // eslint-disable-next-line @typescript-eslint/no-redeclare
26
26
  var Selectables;
@@ -217,5 +217,5 @@ var Selectables;
217
217
  function normalizeClassName(className) {
218
218
  return className.replace(".", ":");
219
219
  }
220
- })(Selectables = exports.Selectables || (exports.Selectables = {}));
220
+ })(Selectables || (exports.Selectables = Selectables = {}));
221
221
  //# sourceMappingURL=Selectable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA0ChG,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,UAAU,CAW1B;AAXD,WAAiB,UAAU;IACzB,oEAAoE;IACpE,SAAgB,aAAa,CAAC,UAA6C;QACzE,MAAM,WAAW,GAAG,UAAmC,CAAC;QACxD,OAAO,CAAC,CAAC,WAAW,CAAC,SAAS,I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C;IAde,gBAAI,OAcnB,CAAA;IAED;;;;OAIG;IACH,SAAgB,OAAO,CAAC,WAAwB,EAAE,QAAyD;QACzG,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAgB,EAAE,SAAiB,EAAE,EAAE;YACvE,GAAG,CAAC,OAAO,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAClC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IARe,mBAAO,UAQtB,CAAA;IAED,SAAS,kBAAkB,CAAC,SAAiB;QAC3C,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,EA/LgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA+L3B","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\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\n/**\n * ECInstance selectable\n * @beta\n */\nexport interface SelectableInstanceKey {\n /** Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName`. */\n className: string;\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable\n * @beta\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something in an iTwin.js application\n * @beta\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * Type of identifier that can be used to identify selectable in storage.\n * @beta\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @beta\n */\nexport interface Selectables {\n /**\n * Map between `SelectableInstanceKey.className` and a set of selected element IDs.\n */\n instanceKeys: Map<string, Set<string>>;\n /**\n * Map between unique identifier of `CustomSelectable` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @beta\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @beta\n */\n export function size(selectables: Selectables): number {\n let insatanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (insatanceCount += set.size));\n return insatanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @beta\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @beta\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @beta\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @beta\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @beta\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @beta\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @beta\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @beta\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @beta\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n function normalizeClassName(className: string): string {\n return className.replace(\".\", \":\");\n }\n}\n"]}
1
+ {"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAsChG,YAAY;AACZ,2DAA2D;AAC3D,IAAiB,UAAU,CAW1B;AAXD,WAAiB,UAAU;IACzB,oEAAoE;IACpE,SAAgB,aAAa,CAAC,UAA6C;QACzE,MAAM,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AAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;oBAChD,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;YACvC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvB,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAde,gBAAI,OAcnB,CAAA;IAED;;;;OAIG;IACH,SAAgB,OAAO,CAAC,WAAwB,EAAE,QAAyD;QACzG,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAgB,EAAE,SAAiB,EAAE,EAAE;YACvE,GAAG,CAAC,OAAO,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QACH,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAClC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IARe,mBAAO,UAQtB,CAAA;IAED,SAAS,kBAAkB,CAAC,SAAiB;QAC3C,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,EA/LgB,WAAW,2BAAX,WAAW,QA+L3B","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\n/**\n * ECInstance selectable\n * @beta\n */\nexport interface SelectableInstanceKey {\n /** Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName`. */\n className: string;\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable\n * @beta\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something in an iTwin.js application\n * @beta\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * Type of identifier that can be used to identify selectable in storage.\n * @beta\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @beta\n */\nexport interface Selectables {\n /**\n * Map between `SelectableInstanceKey.className` and a set of selected element IDs.\n */\n instanceKeys: Map<string, Set<string>>;\n /**\n * Map between unique identifier of `CustomSelectable` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/** @beta */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @beta\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @beta\n */\n export function size(selectables: Selectables): number {\n let insatanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (insatanceCount += set.size));\n return insatanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @beta\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @beta\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @beta\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @beta\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @beta\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @beta\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @beta\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @beta\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @beta\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n function normalizeClassName(className: string): string {\n return className.replace(\".\", \":\");\n }\n}\n"]}
@@ -1,10 +1,7 @@
1
1
  import { Selectables } from "./Selectable";
2
2
  import { SelectionStorage } from "./SelectionStorage";
3
- /** @packageDocumentation
4
- * @module UnifiedSelection
5
- */
6
3
  /**
7
- * The type of selection change
4
+ * The type of selection change.
8
5
  * @beta
9
6
  */
10
7
  export type StorageSelectionChangeType =
@@ -18,7 +15,9 @@ export type StorageSelectionChangeType =
18
15
  | "clear";
19
16
  /**
20
17
  * The event object that is sent when the selection changes.
21
- * @beta
18
+ *
19
+ * @beta Used in public API as an argument for `StorageSelectionChangesListener`. Not expected to be created / extended by package
20
+ * consumers, may be supplemented with required attributes any time.
22
21
  */
23
22
  export interface StorageSelectionChangeEventArgs {
24
23
  /** The name of the selection source which caused the selection change. */
@@ -30,12 +29,17 @@ export interface StorageSelectionChangeEventArgs {
30
29
  /** Selectables affected by this selection change event. */
31
30
  selectables: Selectables;
32
31
  /** iModel key with which the selection is associated with. */
32
+ imodelKey: string;
33
+ /**
34
+ * iModel key with which the selection is associated with.
35
+ * @deprecated in 0.2. Use `imodelKey` instead.
36
+ */
33
37
  iModelKey: string;
34
38
  /** The timestamp of when the selection change happened */
35
39
  timestamp: Date;
36
40
  }
37
41
  /**
38
- * An interface for selection change listeners
42
+ * An interface for selection change listeners.
39
43
  * @beta
40
44
  */
41
45
  export declare type StorageSelectionChangesListener = (args: StorageSelectionChangeEventArgs, storage: SelectionStorage) => void;
@@ -60,7 +64,7 @@ export interface SelectionChangeEvent {
60
64
  removeListener(listener: StorageSelectionChangesListener): void;
61
65
  }
62
66
  /**
63
- * An event broadcasted on selection changes
67
+ * An event broadcasted on selection changes.
64
68
  * @internal
65
69
  */
66
70
  export declare class SelectionChangeEventImpl implements SelectionChangeEvent {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionChangeEvent.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,E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G,IAAI;IAItE;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB;CAGnF"}
@@ -6,7 +6,7 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.SelectionChangeEventImpl = void 0;
8
8
  /**
9
- * An event broadcasted on selection changes
9
+ * An event broadcasted on selection changes.
10
10
  * @internal
11
11
  */
12
12
  class SelectionChangeEventImpl {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAqEhG;;;GAGG;AACH,MAAa,wBAAwB;IAC3B,UAAU,GAAsC,EAAE,CAAC;IAE3D;;;;;OAKG;IACI,WAAW,CAAC,QAAyC;QAC1D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,QAAyC;QAC7D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,IAAqC,EAAE,OAAyB;QAChF,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AAhCD,4DAgCC","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 { Selectables } from \"./Selectable\";\nimport { SelectionStorage } from \"./SelectionStorage\";\n\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\n/**\n * The type of selection change\n * @beta\n */\nexport type StorageSelectionChangeType =\n /** Added to selection. */\n | \"add\"\n /** Removed from selection. */\n | \"remove\"\n /** Selection was replaced. */\n | \"replace\"\n /** Selection was cleared. */\n | \"clear\";\n\n/**\n * The event object that is sent when the selection changes.\n * @beta\n */\nexport interface StorageSelectionChangeEventArgs {\n /** The name of the selection source which caused the selection change. */\n source: string;\n /** Level of the selection. */\n level: number;\n /** The selection change type. */\n changeType: StorageSelectionChangeType;\n /** Selectables affected by this selection change event. */\n selectables: Selectables;\n /** iModel key with which the selection is associated with. */\n iModelKey: string;\n /** The timestamp of when the selection change happened */\n timestamp: Date;\n}\n\n/**\n * An interface for selection change listeners\n * @beta\n */\nexport declare type StorageSelectionChangesListener = (args: StorageSelectionChangeEventArgs, storage: SelectionStorage) => void;\n\n/**\n * An interface that allows subscribing and unsubscribing listeners that\n * are called when a selection has changed.\n * @beta\n */\nexport interface SelectionChangeEvent {\n /**\n * Registers a Listener to be executed whenever this event is raised\n * @param listener The function to be executed when the event is raised\n * @returns A function that will remove this event listener\n * @beta\n */\n addListener(listener: StorageSelectionChangesListener): () => void;\n /**\n * Un-register a previously registered listener\n * @param listener The listener to be unregistered\n * @beta\n */\n removeListener(listener: StorageSelectionChangesListener): void;\n}\n\n/**\n * An event broadcasted on selection changes\n * @internal\n */\nexport class SelectionChangeEventImpl implements SelectionChangeEvent {\n private _listeners: StorageSelectionChangesListener[] = [];\n\n /**\n * Registers a Listener to be executed whenever this event is raised\n * @param listener The function to be executed when the event is raised\n * @returns A function that will remove this event listener\n * @beta\n */\n public addListener(listener: StorageSelectionChangesListener): () => void {\n this._listeners.push(listener);\n return () => this.removeListener(listener);\n }\n\n /**\n * Un-register a previously registered listener\n * @param listener The listener to be unregistered\n * @beta\n */\n public removeListener(listener: StorageSelectionChangesListener): void {\n this._listeners = this._listeners.filter((x) => x !== listener);\n }\n\n /**\n * Raises the event by calling each registered listener with the supplied arguments\n * @param args Event arguments\n * @param storage Storage that the selection changed in\n * @beta\n */\n public raiseEvent(args: StorageSelectionChangeEventArgs, storage: SelectionStorage) {\n this._listeners.forEach((listener) => listener(args, storage));\n }\n}\n"]}
1
+ {"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAwEhG;;;GAGG;AACH,MAAa,wBAAwB;IAC3B,UAAU,GAAsC,EAAE,CAAC;IAE3D;;;;;OAKG;IACI,WAAW,CAAC,QAAyC;QAC1D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,QAAyC;QAC7D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,IAAqC,EAAE,OAAyB;QAChF,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AAhCD,4DAgCC","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 { Selectables } from \"./Selectable\";\nimport { SelectionStorage } from \"./SelectionStorage\";\n\n/**\n * The type of selection change.\n * @beta\n */\nexport type StorageSelectionChangeType =\n /** Added to selection. */\n | \"add\"\n /** Removed from selection. */\n | \"remove\"\n /** Selection was replaced. */\n | \"replace\"\n /** Selection was cleared. */\n | \"clear\";\n\n/**\n * The event object that is sent when the selection changes.\n *\n * @beta Used in public API as an argument for `StorageSelectionChangesListener`. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n */\nexport interface StorageSelectionChangeEventArgs {\n /** The name of the selection source which caused the selection change. */\n source: string;\n /** Level of the selection. */\n level: number;\n /** The selection change type. */\n changeType: StorageSelectionChangeType;\n /** Selectables affected by this selection change event. */\n selectables: Selectables;\n /** iModel key with which the selection is associated with. */\n imodelKey: string;\n /**\n * iModel key with which the selection is associated with.\n * @deprecated in 0.2. Use `imodelKey` instead.\n */\n iModelKey: string;\n /** The timestamp of when the selection change happened */\n timestamp: Date;\n}\n\n/**\n * An interface for selection change listeners.\n * @beta\n */\nexport declare type StorageSelectionChangesListener = (args: StorageSelectionChangeEventArgs, storage: SelectionStorage) => void;\n\n/**\n * An interface that allows subscribing and unsubscribing listeners that\n * are called when a selection has changed.\n * @beta\n */\nexport interface SelectionChangeEvent {\n /**\n * Registers a Listener to be executed whenever this event is raised\n * @param listener The function to be executed when the event is raised\n * @returns A function that will remove this event listener\n * @beta\n */\n addListener(listener: StorageSelectionChangesListener): () => void;\n /**\n * Un-register a previously registered listener\n * @param listener The listener to be unregistered\n * @beta\n */\n removeListener(listener: StorageSelectionChangesListener): void;\n}\n\n/**\n * An event broadcasted on selection changes.\n * @internal\n */\nexport class SelectionChangeEventImpl implements SelectionChangeEvent {\n private _listeners: StorageSelectionChangesListener[] = [];\n\n /**\n * Registers a Listener to be executed whenever this event is raised\n * @param listener The function to be executed when the event is raised\n * @returns A function that will remove this event listener\n * @beta\n */\n public addListener(listener: StorageSelectionChangesListener): () => void {\n this._listeners.push(listener);\n return () => this.removeListener(listener);\n }\n\n /**\n * Un-register a previously registered listener\n * @param listener The listener to be unregistered\n * @beta\n */\n public removeListener(listener: StorageSelectionChangesListener): void {\n this._listeners = this._listeners.filter((x) => x !== listener);\n }\n\n /**\n * Raises the event by calling each registered listener with the supplied arguments\n * @param args Event arguments\n * @param storage Storage that the selection changed in\n * @beta\n */\n public raiseEvent(args: StorageSelectionChangeEventArgs, storage: SelectionStorage) {\n this._listeners.forEach((listener) => listener(args, storage));\n }\n}\n"]}
@@ -0,0 +1,44 @@
1
+ import { ECSqlQueryExecutor } from "@itwin/presentation-shared";
2
+ import { SelectableInstanceKey } from "./Selectable";
3
+ /**
4
+ * Available selection scopes.
5
+ * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with additional items in the union at any time.
6
+ */
7
+ export type SelectionScope = "element" | "model" | "category" | "functional";
8
+ /**
9
+ * Props for computing element selection.
10
+ * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.
11
+ */
12
+ export interface ElementSelectionScopeProps {
13
+ /** Identifies this as either "element" or "functional" selection scope */
14
+ id: "element" | "functional";
15
+ /**
16
+ * Specifies how far "up" we should walk to find the target element. When not specified or `0`,
17
+ * the target element matches the request element. When set to `1`, the target element matches the direct parent element.
18
+ * When set to `2`, the target element is parent of the parent element and so on. In all situations when this is `> 0`,
19
+ * we're not walking further than the last existing element, for example when `ancestorLevel = 1` (direct parent
20
+ * element is requested), but the request element doesn't have a parent, the request element is returned as the result.
21
+ * A negative value would result in the top-most element to be returned.
22
+ */
23
+ ancestorLevel?: number;
24
+ }
25
+ /**
26
+ * Props for `computeSelection`.
27
+ * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.
28
+ */
29
+ export interface ComputeSelectionProps {
30
+ queryExecutor: ECSqlQueryExecutor;
31
+ elementIds: string[];
32
+ scope: ElementSelectionScopeProps | {
33
+ id: SelectionScope;
34
+ } | SelectionScope;
35
+ }
36
+ /**
37
+ * Computes selection from given element ID's.
38
+ * @param queryExecutor iModel query executor.
39
+ * @param elementIds ID's of elements to compute selection for.
40
+ * @param scope Selection scope to compute selection with.
41
+ * @beta
42
+ */
43
+ export declare function computeSelection(props: ComputeSelectionProps): AsyncIterableIterator<SelectableInstanceKey>;
44
+ //# sourceMappingURL=SelectionScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectionScope.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionScope.ts"],"names":[],"mappings":"AAMA,OAAO,EAA+B,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,0EAA0E;IAC1E,EAAE,EAAE,SAAS,GAAG,YAAY,CAAC;IAC7B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,kBAAkB,CAAC;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,0BAA0B,GAAG;QAAE,EAAE,EAAE,cAAc,CAAA;KAAE,GAAG,cAAc,CAAC;CAC7E;AAED;;;;;;GAMG;AACH,wBAAuB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CAwBlH"}
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.computeSelection = void 0;
8
+ const core_bentley_1 = require("@itwin/core-bentley");
9
+ const Utils_1 = require("./Utils");
10
+ /**
11
+ * Computes selection from given element ID's.
12
+ * @param queryExecutor iModel query executor.
13
+ * @param elementIds ID's of elements to compute selection for.
14
+ * @param scope Selection scope to compute selection with.
15
+ * @beta
16
+ */
17
+ async function* computeSelection(props) {
18
+ const { queryExecutor, elementIds, scope } = props;
19
+ if (typeof scope === "string") {
20
+ yield* computeSelection({ queryExecutor, elementIds, scope: { id: scope } });
21
+ return;
22
+ }
23
+ const nonTransientKeys = elementIds.filter((key) => !core_bentley_1.Id64.isTransient(key));
24
+ switch (scope.id) {
25
+ case "element":
26
+ yield* computeElementSelection(queryExecutor, nonTransientKeys, scope.ancestorLevel ?? 0);
27
+ return;
28
+ case "category":
29
+ yield* computeCategorySelection(queryExecutor, nonTransientKeys);
30
+ return;
31
+ case "model":
32
+ yield* computeModelSelection(queryExecutor, nonTransientKeys);
33
+ return;
34
+ case "functional":
35
+ yield* computeFunctionalElementSelection(queryExecutor, nonTransientKeys, scope.ancestorLevel ?? 0);
36
+ return;
37
+ }
38
+ }
39
+ exports.computeSelection = computeSelection;
40
+ async function* computeElementSelection(queryExecutor, elementIds, ancestorLevel) {
41
+ const bindings = [];
42
+ const recurseUntilRoot = ancestorLevel < 0;
43
+ const ctes = [
44
+ `
45
+ AncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (
46
+ SELECT ECInstanceId, ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, Parent.Id
47
+ FROM BisCore.Element
48
+ WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", elementIds, bindings)}
49
+ UNION ALL
50
+ SELECT pe.ECInstanceId, pe.ECClassId, a.Depth - 1, pe.Parent.Id
51
+ FROM AncestorElements a
52
+ JOIN BisCore.Element pe ON pe.ECInstanceId = a.ParentId
53
+ WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
54
+ )
55
+ `,
56
+ ];
57
+ const ecsql = `
58
+ SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName
59
+ FROM AncestorElements
60
+ WHERE ${recurseUntilRoot ? "" : "Depth = 0 OR"} ParentId IS NULL
61
+ `;
62
+ yield* executeQuery(queryExecutor, { ctes, ecsql, bindings });
63
+ }
64
+ async function* computeCategorySelection(queryExecutor, ids) {
65
+ const bindings = [];
66
+ const ecsql = [
67
+ `
68
+ SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName
69
+ FROM BisCore.Category c
70
+ JOIN BisCore.GeometricElement2d ge ON ge.Category.Id = c.ECInstanceId
71
+ WHERE ${(0, Utils_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}
72
+ `,
73
+ `
74
+ SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName
75
+ FROM BisCore.Category c
76
+ JOIN BisCore.GeometricElement3d ge ON ge.Category.Id = c.ECInstanceId
77
+ WHERE ${(0, Utils_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}
78
+ `,
79
+ ].join(" UNION ALL ");
80
+ yield* executeQuery(queryExecutor, { ecsql, bindings });
81
+ }
82
+ async function* computeModelSelection(queryExecutor, ids) {
83
+ const bindings = [];
84
+ const ecsql = `
85
+ SELECT DISTINCT m.ECInstanceId, ec_classname(m.ECClassId, 's.c') AS ClassName
86
+ FROM BisCore.Model m
87
+ JOIN BisCore.Element e ON e.Model.Id = m.ECInstanceId
88
+ WHERE ${(0, Utils_1.formIdBindings)("e.ECInstanceId", ids, bindings)}
89
+ `;
90
+ yield* executeQuery(queryExecutor, { ecsql, bindings });
91
+ }
92
+ async function* computeFunctionalElementSelection(queryExecutor, ids, ancestorLevel) {
93
+ const bindings = [];
94
+ const recurseUntilRoot = ancestorLevel < 0;
95
+ const ctes = [
96
+ `
97
+ Elements2dOrNearestFunctionalElements(OriginalECInstanceId, OriginalECClassId, ECInstanceId, ECClassId, ParentId) AS (
98
+ SELECT ECInstanceId, ECClassId, ECInstanceId, ECClassId, Parent.Id
99
+ FROM BisCore.Element
100
+ WHERE ${(0, Utils_1.formIdBindings)("ECInstanceId", ids, bindings)} AND ECClassId IS NOT (BisCore.GeometricElement3d)
101
+ UNION ALL
102
+ SELECT
103
+ e2onfe.OriginalECInstanceId,
104
+ e2onfe.OriginalECClassId,
105
+ COALESCE(dgrfe.TargetECInstanceId, pe.ECInstanceId),
106
+ COALESCE(dgrfe.TargetECClassId, pe.ECClassId),
107
+ pe.Parent.Id
108
+ FROM Elements2dOrNearestFunctionalElements e2onfe
109
+ LEFT JOIN BisCore.Element pe ON pe.ECInstanceId = e2onfe.ParentId
110
+ LEFT JOIN Functional.DrawingGraphicRepresentsFunctionalElement dgrfe ON dgrfe.SourceECInstanceId = e2onfe.ECInstanceId
111
+ WHERE e2onfe.ECClassId IS NOT (Functional.FunctionalElement) AND (e2onfe.ParentId IS NOT NULL OR dgrfe.TargetECInstanceId IS NOT NULL)
112
+ )
113
+ `,
114
+ `
115
+ Element2dNearestFunctionalElements(OriginalECInstanceId, ECInstanceId, ECClassId) AS (
116
+ SELECT OriginalECInstanceId, ECInstanceId, ECClassId
117
+ FROM Elements2dOrNearestFunctionalElements
118
+ WHERE ECClassId IS (Functional.FunctionalElement)
119
+ )
120
+ `,
121
+ `
122
+ Elements2dWithoutFunctionalElement(ECInstanceId, ECClassId) AS (
123
+ SELECT e2wfe.OriginalECInstanceId, OriginalECClassId
124
+ FROM Elements2dOrNearestFunctionalElements e2wfe
125
+ LEFT JOIN Element2dNearestFunctionalElements e2nfe ON e2nfe.OriginalECInstanceId = e2wfe.OriginalECInstanceId
126
+ WHERE e2wfe.ParentId IS NULL AND e2nfe.ECInstanceId IS NULL
127
+ )
128
+ `,
129
+ `
130
+ Elements2d(ECInstanceId, ECClassId) AS (
131
+ SELECT ECInstanceId, ECClassId FROM Element2dNearestFunctionalElements
132
+ UNION
133
+ SELECT ECInstanceId, ECClassId FROM Elements2dWithoutFunctionalElement
134
+ )
135
+ `,
136
+ `
137
+ Element2dAncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (
138
+ SELECT e.ECInstanceId, e.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, e.Parent.Id
139
+ FROM BisCore.Element e
140
+ JOIN Elements2d e2d ON e2d.ECInstanceId = e.ECInstanceId
141
+ UNION ALL
142
+ SELECT pe.ECInstanceId, pe.ECClassId, e2ae.Depth - 1, pe.Parent.Id
143
+ FROM Element2dAncestorElements e2ae
144
+ JOIN BisCore.Element pe ON pe.ECInstanceId = e2ae.ParentId
145
+ WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
146
+ )
147
+ `,
148
+ `
149
+ Element3dAncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (
150
+ SELECT ge.ECInstanceId, ge.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, ge.Parent.Id
151
+ FROM BisCore.GeometricElement3d ge
152
+ WHERE ${(0, Utils_1.formIdBindings)("ge.ECInstanceId", ids, bindings)}
153
+ UNION ALL
154
+ SELECT pe.ECInstanceId, pe.ECClassId, e3ae.Depth - 1, pe.Parent.Id
155
+ FROM Element3dAncestorElements e3ae
156
+ JOIN BisCore.Element pe ON pe.ECInstanceId = e3ae.ParentId
157
+ WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
158
+ )
159
+ `,
160
+ `
161
+ Element3dAncestorRelatedFunctionalElement(ECInstanceId, ClassName) AS (
162
+ SELECT
163
+ COALESCE(peff.TargetECInstanceId, e3ae.ECInstanceId),
164
+ ec_classname(COALESCE(peff.TargetECClassId, e3ae.ECClassId), 's.c')
165
+ FROM Element3dAncestorElements e3ae
166
+ LEFT JOIN Functional.PhysicalElementFulfillsFunction peff ON peff.SourceECInstanceId = e3ae.ECInstanceId
167
+ WHERE ${recurseUntilRoot ? "" : "e3ae.Depth = 0 OR"} e3ae.ParentId IS NULL
168
+ )
169
+ `,
170
+ ];
171
+ const ecsql = [
172
+ `
173
+ SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName
174
+ FROM Element2dAncestorElements
175
+ WHERE ${recurseUntilRoot ? "" : "Depth = 0 OR"} ParentId IS NULL
176
+ `,
177
+ `
178
+ SELECT DISTINCT ECInstanceId, ClassName FROM Element3dAncestorRelatedFunctionalElement
179
+ `,
180
+ ].join(" UNION ALL ");
181
+ yield* executeQuery(queryExecutor, { ctes, ecsql, bindings });
182
+ }
183
+ function formAncestorLevelBinding(ancestorLevel, bindings) {
184
+ bindings.push({ type: "int", value: ancestorLevel });
185
+ return "?";
186
+ }
187
+ async function* executeQuery(queryExecutor, query) {
188
+ const reader = queryExecutor.createQueryReader(query);
189
+ for await (const row of reader) {
190
+ yield { className: row.ClassName, id: row.ECInstanceId };
191
+ }
192
+ }
193
+ //# sourceMappingURL=SelectionScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectionScope.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionScope.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,sDAA2C;AAG3C,mCAAyC;AAoCzC;;;;;;GAMG;AACI,KAAK,SAAS,CAAC,CAAC,gBAAgB,CAAC,KAA4B;IAClE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAEnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,KAAK,CAAC,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7E,OAAO;IACT,CAAC;IAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,mBAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IAE5E,QAAQ,KAAK,CAAC,EAAE,EAAE,CAAC;QACjB,KAAK,SAAS;YACZ,KAAK,CAAC,CAAC,uBAAuB,CAAC,aAAa,EAAE,gBAAgB,EAAG,KAAoC,CAAC,aAAa,IAAI,CAAC,CAAC,CAAC;YAC1H,OAAO;QACT,KAAK,UAAU;YACb,KAAK,CAAC,CAAC,wBAAwB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;YACjE,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C,EAAE,CAAC,CAAC,CAAC,cAAc;KAChD;QACD;;KAEC;KACF,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtB,KAAK,CAAC,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,wBAAwB,CAAC,aAAqB,EAAE,QAAwB;IAC/E,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;IACrD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,YAAY,CAAC,aAAiC,EAAE,KAAoB;IAClF,MAAM,MAAM,GAAG,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACtD,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,EAAE,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { Id64 } from \"@itwin/core-bentley\";\nimport { ECSqlBinding, ECSqlQueryDef, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport { SelectableInstanceKey } from \"./Selectable\";\nimport { formIdBindings } from \"./Utils\";\n\n/**\n * Available selection scopes.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with additional items in the union at any time.\n */\nexport type SelectionScope = \"element\" | \"model\" | \"category\" | \"functional\";\n\n/**\n * Props for computing element selection.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface ElementSelectionScopeProps {\n /** Identifies this as either \"element\" or \"functional\" selection scope */\n id: \"element\" | \"functional\";\n /**\n * Specifies how far \"up\" we should walk to find the target element. When not specified or `0`,\n * the target element matches the request element. When set to `1`, the target element matches the direct parent element.\n * When set to `2`, the target element is parent of the parent element and so on. In all situations when this is `> 0`,\n * we're not walking further than the last existing element, for example when `ancestorLevel = 1` (direct parent\n * element is requested), but the request element doesn't have a parent, the request element is returned as the result.\n * A negative value would result in the top-most element to be returned.\n */\n ancestorLevel?: number;\n}\n\n/**\n * Props for `computeSelection`.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface ComputeSelectionProps {\n queryExecutor: ECSqlQueryExecutor;\n elementIds: string[];\n scope: ElementSelectionScopeProps | { id: SelectionScope } | SelectionScope;\n}\n\n/**\n * Computes selection from given element ID's.\n * @param queryExecutor iModel query executor.\n * @param elementIds ID's of elements to compute selection for.\n * @param scope Selection scope to compute selection with.\n * @beta\n */\nexport async function* computeSelection(props: ComputeSelectionProps): AsyncIterableIterator<SelectableInstanceKey> {\n const { queryExecutor, elementIds, scope } = props;\n\n if (typeof scope === \"string\") {\n yield* computeSelection({ queryExecutor, elementIds, scope: { id: scope } });\n return;\n }\n\n const nonTransientKeys = elementIds.filter((key) => !Id64.isTransient(key));\n\n switch (scope.id) {\n case \"element\":\n yield* computeElementSelection(queryExecutor, nonTransientKeys, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n return;\n case \"category\":\n yield* computeCategorySelection(queryExecutor, nonTransientKeys);\n return;\n case \"model\":\n yield* computeModelSelection(queryExecutor, nonTransientKeys);\n return;\n case \"functional\":\n yield* computeFunctionalElementSelection(queryExecutor, nonTransientKeys, (scope as ElementSelectionScopeProps).ancestorLevel ?? 0);\n return;\n }\n}\n\nasync function* computeElementSelection(\n queryExecutor: ECSqlQueryExecutor,\n elementIds: string[],\n ancestorLevel: number,\n): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const recurseUntilRoot = ancestorLevel < 0;\n const ctes = [\n `\n AncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT ECInstanceId, ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, Parent.Id\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", elementIds, bindings)}\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, a.Depth - 1, pe.Parent.Id\n FROM AncestorElements a\n JOIN BisCore.Element pe ON pe.ECInstanceId = a.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n )\n `,\n ];\n const ecsql = `\n SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName\n FROM AncestorElements\n WHERE ${recurseUntilRoot ? \"\" : \"Depth = 0 OR\"} ParentId IS NULL\n `;\n yield* executeQuery(queryExecutor, { ctes, ecsql, bindings });\n}\n\nasync function* computeCategorySelection(queryExecutor: ECSqlQueryExecutor, ids: string[]): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const ecsql = [\n `\n SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName\n FROM BisCore.Category c\n JOIN BisCore.GeometricElement2d ge ON ge.Category.Id = c.ECInstanceId\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n `,\n `\n SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName\n FROM BisCore.Category c\n JOIN BisCore.GeometricElement3d ge ON ge.Category.Id = c.ECInstanceId\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n `,\n ].join(\" UNION ALL \");\n yield* executeQuery(queryExecutor, { ecsql, bindings });\n}\n\nasync function* computeModelSelection(queryExecutor: ECSqlQueryExecutor, ids: string[]): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const ecsql = `\n SELECT DISTINCT m.ECInstanceId, ec_classname(m.ECClassId, 's.c') AS ClassName\n FROM BisCore.Model m\n JOIN BisCore.Element e ON e.Model.Id = m.ECInstanceId\n WHERE ${formIdBindings(\"e.ECInstanceId\", ids, bindings)}\n `;\n yield* executeQuery(queryExecutor, { ecsql, bindings });\n}\n\nasync function* computeFunctionalElementSelection(\n queryExecutor: ECSqlQueryExecutor,\n ids: string[],\n ancestorLevel: number,\n): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const recurseUntilRoot = ancestorLevel < 0;\n const ctes = [\n `\n Elements2dOrNearestFunctionalElements(OriginalECInstanceId, OriginalECClassId, ECInstanceId, ECClassId, ParentId) AS (\n SELECT ECInstanceId, ECClassId, ECInstanceId, ECClassId, Parent.Id\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", ids, bindings)} AND ECClassId IS NOT (BisCore.GeometricElement3d)\n UNION ALL\n SELECT\n e2onfe.OriginalECInstanceId,\n e2onfe.OriginalECClassId,\n COALESCE(dgrfe.TargetECInstanceId, pe.ECInstanceId),\n COALESCE(dgrfe.TargetECClassId, pe.ECClassId),\n pe.Parent.Id\n FROM Elements2dOrNearestFunctionalElements e2onfe\n LEFT JOIN BisCore.Element pe ON pe.ECInstanceId = e2onfe.ParentId\n LEFT JOIN Functional.DrawingGraphicRepresentsFunctionalElement dgrfe ON dgrfe.SourceECInstanceId = e2onfe.ECInstanceId\n WHERE e2onfe.ECClassId IS NOT (Functional.FunctionalElement) AND (e2onfe.ParentId IS NOT NULL OR dgrfe.TargetECInstanceId IS NOT NULL)\n )\n `,\n `\n Element2dNearestFunctionalElements(OriginalECInstanceId, ECInstanceId, ECClassId) AS (\n SELECT OriginalECInstanceId, ECInstanceId, ECClassId\n FROM Elements2dOrNearestFunctionalElements\n WHERE ECClassId IS (Functional.FunctionalElement)\n )\n `,\n `\n Elements2dWithoutFunctionalElement(ECInstanceId, ECClassId) AS (\n SELECT e2wfe.OriginalECInstanceId, OriginalECClassId\n FROM Elements2dOrNearestFunctionalElements e2wfe\n LEFT JOIN Element2dNearestFunctionalElements e2nfe ON e2nfe.OriginalECInstanceId = e2wfe.OriginalECInstanceId\n WHERE e2wfe.ParentId IS NULL AND e2nfe.ECInstanceId IS NULL\n )\n `,\n `\n Elements2d(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM Element2dNearestFunctionalElements\n UNION\n SELECT ECInstanceId, ECClassId FROM Elements2dWithoutFunctionalElement\n )\n `,\n `\n Element2dAncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT e.ECInstanceId, e.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, e.Parent.Id\n FROM BisCore.Element e\n JOIN Elements2d e2d ON e2d.ECInstanceId = e.ECInstanceId\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, e2ae.Depth - 1, pe.Parent.Id\n FROM Element2dAncestorElements e2ae\n JOIN BisCore.Element pe ON pe.ECInstanceId = e2ae.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n )\n `,\n `\n Element3dAncestorElements(ECInstanceId, ECClassId, Depth, ParentId) AS (\n SELECT ge.ECInstanceId, ge.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, ge.Parent.Id\n FROM BisCore.GeometricElement3d ge\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n UNION ALL\n SELECT pe.ECInstanceId, pe.ECClassId, e3ae.Depth - 1, pe.Parent.Id\n FROM Element3dAncestorElements e3ae\n JOIN BisCore.Element pe ON pe.ECInstanceId = e3ae.ParentId\n WHERE ${recurseUntilRoot ? \"\" : \"Depth > 0 AND\"} ParentId IS NOT NULL\n )\n `,\n `\n Element3dAncestorRelatedFunctionalElement(ECInstanceId, ClassName) AS (\n SELECT\n COALESCE(peff.TargetECInstanceId, e3ae.ECInstanceId),\n ec_classname(COALESCE(peff.TargetECClassId, e3ae.ECClassId), 's.c')\n FROM Element3dAncestorElements e3ae\n LEFT JOIN Functional.PhysicalElementFulfillsFunction peff ON peff.SourceECInstanceId = e3ae.ECInstanceId\n WHERE ${recurseUntilRoot ? \"\" : \"e3ae.Depth = 0 OR\"} e3ae.ParentId IS NULL\n )\n `,\n ];\n const ecsql = [\n `\n SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName\n FROM Element2dAncestorElements\n WHERE ${recurseUntilRoot ? \"\" : \"Depth = 0 OR\"} ParentId IS NULL\n `,\n `\n SELECT DISTINCT ECInstanceId, ClassName FROM Element3dAncestorRelatedFunctionalElement\n `,\n ].join(\" UNION ALL \");\n yield* executeQuery(queryExecutor, { ctes, ecsql, bindings });\n}\n\nfunction formAncestorLevelBinding(ancestorLevel: number, bindings: ECSqlBinding[]) {\n bindings.push({ type: \"int\", value: ancestorLevel });\n return \"?\";\n}\n\nasync function* executeQuery(queryExecutor: ECSqlQueryExecutor, query: ECSqlQueryDef): AsyncIterableIterator<SelectableInstanceKey> {\n const reader = queryExecutor.createQueryReader(query);\n for await (const row of reader) {\n yield { className: row.ClassName, id: row.ECInstanceId };\n }\n}\n"]}