@itwin/unified-selection 0.1.0 → 0.2.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 (67) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +78 -0
  3. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts +37 -0
  4. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
  5. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js +65 -0
  6. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js.map +1 -0
  7. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts +39 -0
  8. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts.map +1 -0
  9. package/lib/cjs/unified-selection/HiliteSetProvider.js +298 -0
  10. package/lib/cjs/unified-selection/HiliteSetProvider.js.map +1 -0
  11. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts +6 -4
  12. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  13. package/lib/cjs/unified-selection/SelectionChangeEvent.js +1 -1
  14. package/lib/cjs/unified-selection/SelectionChangeEvent.js.map +1 -1
  15. package/lib/cjs/unified-selection/SelectionScope.d.ts +44 -0
  16. package/lib/cjs/unified-selection/SelectionScope.d.ts.map +1 -0
  17. package/lib/cjs/unified-selection/SelectionScope.js +160 -0
  18. package/lib/cjs/unified-selection/SelectionScope.js.map +1 -0
  19. package/lib/cjs/unified-selection/SelectionStorage.d.ts +16 -3
  20. package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +1 -1
  21. package/lib/cjs/unified-selection/SelectionStorage.js +14 -3
  22. package/lib/cjs/unified-selection/SelectionStorage.js.map +1 -1
  23. package/lib/cjs/unified-selection/queries/ECMetadata.d.ts +44 -0
  24. package/lib/cjs/unified-selection/queries/ECMetadata.d.ts.map +1 -0
  25. package/lib/cjs/unified-selection/queries/ECMetadata.js +17 -0
  26. package/lib/cjs/unified-selection/queries/ECMetadata.js.map +1 -0
  27. package/lib/cjs/unified-selection/queries/ECSqlCore.d.ts +69 -0
  28. package/lib/cjs/unified-selection/queries/ECSqlCore.d.ts.map +1 -0
  29. package/lib/cjs/unified-selection/queries/ECSqlCore.js +23 -0
  30. package/lib/cjs/unified-selection/queries/ECSqlCore.js.map +1 -0
  31. package/lib/cjs/unified-selection.d.ts +4 -1
  32. package/lib/cjs/unified-selection.d.ts.map +1 -1
  33. package/lib/cjs/unified-selection.js +9 -1
  34. package/lib/cjs/unified-selection.js.map +1 -1
  35. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts +37 -0
  36. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
  37. package/lib/esm/unified-selection/CachingHiliteSetProvider.js +61 -0
  38. package/lib/esm/unified-selection/CachingHiliteSetProvider.js.map +1 -0
  39. package/lib/esm/unified-selection/HiliteSetProvider.d.ts +39 -0
  40. package/lib/esm/unified-selection/HiliteSetProvider.d.ts.map +1 -0
  41. package/lib/esm/unified-selection/HiliteSetProvider.js +294 -0
  42. package/lib/esm/unified-selection/HiliteSetProvider.js.map +1 -0
  43. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts +6 -4
  44. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  45. package/lib/esm/unified-selection/SelectionChangeEvent.js +1 -1
  46. package/lib/esm/unified-selection/SelectionChangeEvent.js.map +1 -1
  47. package/lib/esm/unified-selection/SelectionScope.d.ts +44 -0
  48. package/lib/esm/unified-selection/SelectionScope.d.ts.map +1 -0
  49. package/lib/esm/unified-selection/SelectionScope.js +156 -0
  50. package/lib/esm/unified-selection/SelectionScope.js.map +1 -0
  51. package/lib/esm/unified-selection/SelectionStorage.d.ts +16 -3
  52. package/lib/esm/unified-selection/SelectionStorage.d.ts.map +1 -1
  53. package/lib/esm/unified-selection/SelectionStorage.js +13 -2
  54. package/lib/esm/unified-selection/SelectionStorage.js.map +1 -1
  55. package/lib/esm/unified-selection/queries/ECMetadata.d.ts +44 -0
  56. package/lib/esm/unified-selection/queries/ECMetadata.d.ts.map +1 -0
  57. package/lib/esm/unified-selection/queries/ECMetadata.js +13 -0
  58. package/lib/esm/unified-selection/queries/ECMetadata.js.map +1 -0
  59. package/lib/esm/unified-selection/queries/ECSqlCore.d.ts +69 -0
  60. package/lib/esm/unified-selection/queries/ECSqlCore.d.ts.map +1 -0
  61. package/lib/esm/unified-selection/queries/ECSqlCore.js +19 -0
  62. package/lib/esm/unified-selection/queries/ECSqlCore.js.map +1 -0
  63. package/lib/esm/unified-selection.d.ts +4 -1
  64. package/lib/esm/unified-selection.d.ts.map +1 -1
  65. package/lib/esm/unified-selection.js +4 -1
  66. package/lib/esm/unified-selection.js.map +1 -1
  67. package/package.json +9 -3
@@ -4,7 +4,7 @@ import { SelectionStorage } from "./SelectionStorage";
4
4
  * @module UnifiedSelection
5
5
  */
6
6
  /**
7
- * The type of selection change
7
+ * The type of selection change.
8
8
  * @beta
9
9
  */
10
10
  export type StorageSelectionChangeType =
@@ -18,7 +18,9 @@ export type StorageSelectionChangeType =
18
18
  | "clear";
19
19
  /**
20
20
  * The event object that is sent when the selection changes.
21
- * @beta
21
+ *
22
+ * @beta Used in public API as an argument for `StorageSelectionChangesListener`. Not expected to be created / extended by package
23
+ * consumers, may be supplemented with required attributes any time.
22
24
  */
23
25
  export interface StorageSelectionChangeEventArgs {
24
26
  /** The name of the selection source which caused the selection change. */
@@ -35,7 +37,7 @@ export interface StorageSelectionChangeEventArgs {
35
37
  timestamp: Date;
36
38
  }
37
39
  /**
38
- * An interface for selection change listeners
40
+ * An interface for selection change listeners.
39
41
  * @beta
40
42
  */
41
43
  export declare type StorageSelectionChangesListener = (args: StorageSelectionChangeEventArgs, storage: SelectionStorage) => void;
@@ -60,7 +62,7 @@ export interface SelectionChangeEvent {
60
62
  removeListener(listener: StorageSelectionChangesListener): void;
61
63
  }
62
64
  /**
63
- * An event broadcasted on selection changes
65
+ * An event broadcasted on selection changes.
64
66
  * @internal
65
67
  */
66
68
  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,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AAEH;;;GAGG;AACH,MAAM,MAAM,0BAA0B;AACpC,0BAA0B;AACxB,KAAK;AACP,8BAA8B;GAC5B,QAAQ;AACV,8BAA8B;GAC5B,SAAS;AACX,6BAA6B;GAC3B,OAAO,CAAC;AAEZ;;;GAGG;AACH,MAAM,WAAW,+BAA+B;IAC9C,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,UAAU,EAAE,0BAA0B,CAAC;IACvC,2DAA2D;IAC3D,WAAW,EAAE,WAAW,CAAC;IACzB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,MAAM,+BAA+B,GAAG,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAEjI;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,+BAA+B,GAAG,MAAM,IAAI,CAAC;IACnE;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI,CAAC;CACjE;AAED;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,OAAO,CAAC,UAAU,CAAyC;IAE3D;;;;;OAKG;IACI,WAAW,CAAC,QAAQ,EAAE,+BAA+B,GAAG,MAAM,IAAI;IAKzE;;;;OAIG;IACI,cAAc,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI;IAItE;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB;CAGnF"}
1
+ {"version":3,"file":"SelectionChangeEvent.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AAEH;;;GAGG;AACH,MAAM,MAAM,0BAA0B;AACpC,0BAA0B;AACxB,KAAK;AACP,8BAA8B;GAC5B,QAAQ;AACV,8BAA8B;GAC5B,SAAS;AACX,6BAA6B;GAC3B,OAAO,CAAC;AAEZ;;;;;GAKG;AACH,MAAM,WAAW,+BAA+B;IAC9C,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,UAAU,EAAE,0BAA0B,CAAC;IACvC,2DAA2D;IAC3D,WAAW,EAAE,WAAW,CAAC;IACzB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,MAAM,+BAA+B,GAAG,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAEjI;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,+BAA+B,GAAG,MAAM,IAAI,CAAC;IACnE;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI,CAAC;CACjE;AAED;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,OAAO,CAAC,UAAU,CAAyC;IAE3D;;;;;OAKG;IACI,WAAW,CAAC,QAAQ,EAAE,+BAA+B,GAAG,MAAM,IAAI;IAKzE;;;;OAIG;IACI,cAAc,CAAC,QAAQ,EAAE,+BAA+B,GAAG,IAAI;IAItE;;;;;OAKG;IACI,UAAU,CAAC,IAAI,EAAE,+BAA+B,EAAE,OAAO,EAAE,gBAAgB;CAGnF"}
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  /**
6
- * An event broadcasted on selection changes
6
+ * An event broadcasted on selection changes.
7
7
  * @internal
8
8
  */
9
9
  export class SelectionChangeEventImpl {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAqEhG;;;GAGG;AACH,MAAM,OAAO,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","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;AAuEhG;;;GAGG;AACH,MAAM,OAAO,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","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 *\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 /** 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 { IECSqlQueryExecutor } from "./queries/ECSqlCore";
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: IECSqlQueryExecutor;
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,EAAgC,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD;;;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,mBAAmB,CAAC;IACnC,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,156 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { Id64 } from "@itwin/core-bentley";
6
+ import { formIdBindings } from "./queries/ECSqlCore";
7
+ /**
8
+ * Computes selection from given element ID's.
9
+ * @param queryExecutor iModel query executor.
10
+ * @param elementIds ID's of elements to compute selection for.
11
+ * @param scope Selection scope to compute selection with.
12
+ * @beta
13
+ */
14
+ export async function* computeSelection(props) {
15
+ const { queryExecutor, elementIds, scope } = props;
16
+ if (typeof scope === "string") {
17
+ yield* computeSelection({ queryExecutor, elementIds, scope: { id: scope } });
18
+ return;
19
+ }
20
+ const nonTransientKeys = elementIds.filter((key) => !Id64.isTransient(key));
21
+ switch (scope.id) {
22
+ case "element":
23
+ yield* computeElementSelection(queryExecutor, nonTransientKeys, scope.ancestorLevel ?? 0);
24
+ return;
25
+ case "category":
26
+ yield* computeCategorySelection(queryExecutor, nonTransientKeys);
27
+ return;
28
+ case "model":
29
+ yield* computeModelSelection(queryExecutor, nonTransientKeys);
30
+ return;
31
+ case "functional":
32
+ yield* computeFunctionalElementSelection(queryExecutor, nonTransientKeys, scope.ancestorLevel ?? 0);
33
+ return;
34
+ }
35
+ }
36
+ async function* computeElementSelection(queryExecutor, elementIds, ancestorLevel) {
37
+ const bindings = [];
38
+ const recurseUntilRoot = ancestorLevel < 0;
39
+ const query = `
40
+ WITH RECURSIVE
41
+ AncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (
42
+ SELECT ECInstanceId, ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, Parent.Id
43
+ FROM BisCore.Element
44
+ WHERE ${formIdBindings("ECInstanceId", elementIds, bindings)}
45
+ UNION ALL
46
+ SELECT pe.ECInstanceId, pe.ECClassId, a.Depth - 1, pe.Parent.Id FROM AncestorElements a
47
+ JOIN BisCore.Element pe ON pe.ECInstanceId = a.ParentId
48
+ WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
49
+ )
50
+ SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName FROM AncestorElements
51
+ WHERE ${recurseUntilRoot ? "" : "Depth = 0 OR"} ParentId IS NULL`;
52
+ yield* executeQuery(queryExecutor, query, bindings);
53
+ }
54
+ async function* computeCategorySelection(queryExecutor, ids) {
55
+ const bindings = [];
56
+ const query = `
57
+ SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName
58
+ FROM BisCore.Category c JOIN BisCore.GeometricElement2d ge ON ge.Category.Id = c.ECInstanceId
59
+ WHERE ${formIdBindings("ge.ECInstanceId", ids, bindings)}
60
+ UNION ALL
61
+ SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName
62
+ FROM BisCore.Category c JOIN BisCore.GeometricElement3d ge ON ge.Category.Id = c.ECInstanceId
63
+ WHERE ${formIdBindings("ge.ECInstanceId", ids, bindings)}`;
64
+ yield* executeQuery(queryExecutor, query, bindings);
65
+ }
66
+ async function* computeModelSelection(queryExecutor, ids) {
67
+ const bindings = [];
68
+ const query = `
69
+ SELECT DISTINCT m.ECInstanceId, ec_classname(m.ECClassId, 's.c') AS ClassName
70
+ FROM BisCore.Model m JOIN BisCore.Element e ON e.Model.Id = m.ECInstanceId
71
+ WHERE ${formIdBindings("e.ECInstanceId", ids, bindings)}`;
72
+ yield* executeQuery(queryExecutor, query, bindings);
73
+ }
74
+ async function* computeFunctionalElementSelection(queryExecutor, ids, ancestorLevel) {
75
+ const bindings = [];
76
+ const recurseUntilRoot = ancestorLevel < 0;
77
+ const query = `
78
+ WITH RECURSIVE
79
+ Elements2dOrNearestFunctionalElements (OriginalECInstanceId, OriginalECClassId, ECInstanceId, ECClassId, ParentId) AS (
80
+ SELECT ECInstanceId, ECClassId, ECInstanceId, ECClassId, Parent.Id
81
+ FROM BisCore.Element
82
+ WHERE ${formIdBindings("ECInstanceId", ids, bindings)} AND ECClassId IS NOT (BisCore.GeometricElement3d)
83
+ UNION ALL
84
+ SELECT
85
+ e2onfe.OriginalECInstanceId,
86
+ e2onfe.OriginalECClassId,
87
+ COALESCE(dgrfe.TargetECInstanceId, pe.ECInstanceId),
88
+ COALESCE(dgrfe.TargetECClassId, pe.ECClassId),
89
+ pe.Parent.Id
90
+ FROM Elements2dOrNearestFunctionalElements e2onfe
91
+ LEFT JOIN BisCore.Element pe ON pe.ECInstanceId = e2onfe.ParentId
92
+ LEFT JOIN Functional.DrawingGraphicRepresentsFunctionalElement dgrfe ON dgrfe.SourceECInstanceId = e2onfe.ECInstanceId
93
+ WHERE e2onfe.ECClassId IS NOT (Functional.FunctionalElement) AND (e2onfe.ParentId IS NOT NULL OR dgrfe.TargetECInstanceId IS NOT NULL)
94
+ ),
95
+ Element2dNearestFunctionalElements (OriginalECInstanceId, ECInstanceId, ECClassId) AS (
96
+ SELECT OriginalECInstanceId, ECInstanceId, ECClassId
97
+ FROM Elements2dOrNearestFunctionalElements
98
+ WHERE ECClassId IS (Functional.FunctionalElement)
99
+ ),
100
+ Elements2dWithoutFunctionalElement (ECInstanceId, ECClassId) AS (
101
+ SELECT e2wfe.OriginalECInstanceId, OriginalECClassId
102
+ FROM Elements2dOrNearestFunctionalElements e2wfe
103
+ LEFT JOIN Element2dNearestFunctionalElements e2nfe ON e2nfe.OriginalECInstanceId = e2wfe.OriginalECInstanceId
104
+ WHERE e2wfe.ParentId IS NULL AND e2nfe.ECInstanceId IS NULL
105
+ ),
106
+ Elements2d (ECInstanceId, ECClassId) AS (
107
+ SELECT ECInstanceId, ECClassId FROM Element2dNearestFunctionalElements
108
+ UNION
109
+ SELECT ECInstanceId, ECClassId FROM Elements2dWithoutFunctionalElement
110
+ ),
111
+ Element2dAncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (
112
+ SELECT e.ECInstanceId, e.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, e.Parent.Id
113
+ FROM BisCore.Element e
114
+ JOIN Elements2d e2d ON e2d.ECInstanceId = e.ECInstanceId
115
+ UNION ALL
116
+ SELECT pe.ECInstanceId, pe.ECClassId, e2ae.Depth - 1, pe.Parent.Id
117
+ FROM Element2dAncestorElements e2ae
118
+ JOIN BisCore.Element pe ON pe.ECInstanceId = e2ae.ParentId
119
+ WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
120
+ ),
121
+ Element3dAncestorElements (ECInstanceId, ECClassId, Depth, ParentId) AS (
122
+ SELECT ge.ECInstanceId, ge.ECClassId, ${formAncestorLevelBinding(ancestorLevel, bindings)}, ge.Parent.Id
123
+ FROM BisCore.GeometricElement3d ge
124
+ WHERE ${formIdBindings("ge.ECInstanceId", ids, bindings)}
125
+ UNION ALL
126
+ SELECT pe.ECInstanceId, pe.ECClassId, e3ae.Depth - 1, pe.Parent.Id
127
+ FROM Element3dAncestorElements e3ae
128
+ JOIN BisCore.Element pe ON pe.ECInstanceId = e3ae.ParentId
129
+ WHERE ${recurseUntilRoot ? "" : "Depth > 0 AND"} ParentId IS NOT NULL
130
+ ),
131
+ Element3dAncestorRelatedFunctionalElement (ECInstanceId, ClassName) AS (
132
+ SELECT
133
+ COALESCE(peff.TargetECInstanceId, e3ae.ECInstanceId),
134
+ ec_classname(COALESCE(peff.TargetECClassId, e3ae.ECClassId), 's.c')
135
+ FROM Element3dAncestorElements e3ae
136
+ LEFT JOIN Functional.PhysicalElementFulfillsFunction peff ON peff.SourceECInstanceId = e3ae.ECInstanceId
137
+ WHERE ${recurseUntilRoot ? "" : "e3ae.Depth = 0 OR"} e3ae.ParentId IS NULL
138
+ )
139
+ SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName
140
+ FROM Element2dAncestorElements
141
+ WHERE ${recurseUntilRoot ? "" : "Depth = 0 OR"} ParentId IS NULL
142
+ UNION ALL
143
+ SELECT DISTINCT ECInstanceId, ClassName FROM Element3dAncestorRelatedFunctionalElement`;
144
+ yield* executeQuery(queryExecutor, query, bindings);
145
+ }
146
+ function formAncestorLevelBinding(ancestorLevel, bindings) {
147
+ bindings.push({ type: "int", value: ancestorLevel });
148
+ return "?";
149
+ }
150
+ async function* executeQuery(queryExecutor, query, bindings) {
151
+ const reader = queryExecutor.createQueryReader(query, bindings);
152
+ for await (const row of reader) {
153
+ yield { className: row.ClassName, id: row.ECInstanceId };
154
+ }
155
+ }
156
+ //# sourceMappingURL=SelectionScope.js.map
@@ -0,0 +1 @@
1
+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AAG,CAAC,YAAY,EAAE,CAAC;KAC1D;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, formIdBindings, IECSqlQueryExecutor } from \"./queries/ECSqlCore\";\nimport { SelectableInstanceKey } from \"./Selectable\";\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: IECSqlQueryExecutor;\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: IECSqlQueryExecutor,\n elementIds: string[],\n ancestorLevel: number,\n): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const recurseUntilRoot = ancestorLevel < 0;\n const query = `\n WITH RECURSIVE\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 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 SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName FROM AncestorElements\n WHERE ${recurseUntilRoot ? \"\" : \"Depth = 0 OR\"} ParentId IS NULL`;\n\n yield* executeQuery(queryExecutor, query, bindings);\n}\n\nasync function* computeCategorySelection(queryExecutor: IECSqlQueryExecutor, ids: string[]): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const query = `\n SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName\n FROM BisCore.Category c JOIN BisCore.GeometricElement2d ge ON ge.Category.Id = c.ECInstanceId\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}\n UNION ALL\n SELECT DISTINCT c.ECInstanceId, ec_classname(c.ECClassId, 's.c') AS ClassName\n FROM BisCore.Category c JOIN BisCore.GeometricElement3d ge ON ge.Category.Id = c.ECInstanceId\n WHERE ${formIdBindings(\"ge.ECInstanceId\", ids, bindings)}`;\n\n yield* executeQuery(queryExecutor, query, bindings);\n}\n\nasync function* computeModelSelection(queryExecutor: IECSqlQueryExecutor, ids: string[]): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const query = `\n SELECT DISTINCT m.ECInstanceId, ec_classname(m.ECClassId, 's.c') AS ClassName\n FROM BisCore.Model m JOIN BisCore.Element e ON e.Model.Id = m.ECInstanceId\n WHERE ${formIdBindings(\"e.ECInstanceId\", ids, bindings)}`;\n\n yield* executeQuery(queryExecutor, query, bindings);\n}\n\nasync function* computeFunctionalElementSelection(\n queryExecutor: IECSqlQueryExecutor,\n ids: string[],\n ancestorLevel: number,\n): AsyncIterableIterator<SelectableInstanceKey> {\n const bindings: ECSqlBinding[] = [];\n const recurseUntilRoot = ancestorLevel < 0;\n const query = `\n WITH RECURSIVE\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 Element2dNearestFunctionalElements (OriginalECInstanceId, ECInstanceId, ECClassId) AS (\n SELECT OriginalECInstanceId, ECInstanceId, ECClassId\n FROM Elements2dOrNearestFunctionalElements\n WHERE ECClassId IS (Functional.FunctionalElement)\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 Elements2d (ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM Element2dNearestFunctionalElements\n UNION\n SELECT ECInstanceId, ECClassId FROM Elements2dWithoutFunctionalElement\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 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 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 SELECT DISTINCT ECInstanceId, ec_classname(ECClassId, 's.c') AS ClassName\n FROM Element2dAncestorElements\n WHERE ${recurseUntilRoot ? \"\" : \"Depth = 0 OR\"} ParentId IS NULL\n UNION ALL\n SELECT DISTINCT ECInstanceId, ClassName FROM Element3dAncestorRelatedFunctionalElement`;\n\n yield* executeQuery(queryExecutor, query, bindings);\n}\n\nfunction formAncestorLevelBinding(ancestorLevel: number, bindings: ECSqlBinding[]) {\n bindings.push({ type: \"int\", value: ancestorLevel });\n return \"?\";\n}\n\nasync function* executeQuery(queryExecutor: IECSqlQueryExecutor, query: string, bindings?: ECSqlBinding[]): AsyncIterableIterator<SelectableInstanceKey> {\n const reader = queryExecutor.createQueryReader(query, bindings);\n\n for await (const row of reader) {\n yield { className: row.ClassName, id: row.ECInstanceId };\n }\n}\n"]}
@@ -4,8 +4,10 @@
4
4
  import { Selectable, Selectables } from "./Selectable";
5
5
  import { SelectionChangeEvent } from "./SelectionChangeEvent";
6
6
  /**
7
- * Selection storage interface which provides main selection and sub-selection.
8
- * @beta
7
+ * Defines return value of `createStorage`.
8
+ *
9
+ * @beta Used in public API as a return value. Not expected to be created / extended by package
10
+ * consumers, may be supplemented with required attributes any time.
9
11
  */
10
12
  export interface SelectionStorage {
11
13
  /** An event that is raised when selection changes. */
@@ -71,8 +73,19 @@ export interface SelectionStorage {
71
73
  }): void;
72
74
  }
73
75
  /**
74
- * Creates a selection storage. When an iModel is closed `SelectionStorage.clearSelection` function should be called.
76
+ * Creates a selection storage which stores and allows managing application-level selection.
77
+ *
78
+ * **Note:** `clearSelection` should be called upon iModel close to free-up memory:
79
+ * ```ts
80
+ * import { IModelConnection } from "@itwin/core-frontend";
81
+ * IModelConnection.onClose.addListener((iModel) => {
82
+ * storage.clearStorage(iModel.key);
83
+ * });
84
+ * ```
85
+ *
75
86
  * @beta
76
87
  */
77
88
  export declare function createStorage(): SelectionStorage;
89
+ /** @internal */
90
+ export declare const IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = "Unified selection storage: clear";
78
91
  //# sourceMappingURL=SelectionStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionStorage.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAyF,MAAM,wBAAwB,CAAC;AAErJ;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C,0EAA0E;IAC1E,kBAAkB,CAAC,KAAK,EAAE;QACxB,qDAAqD;QACrD,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,MAAM,EAAE,CAAC;IAEb,+CAA+C;IAC/C,YAAY,CAAC,KAAK,EAAE;QAClB,8CAA8C;QAC9C,SAAS,EAAE,MAAM,CAAC;QAClB,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,WAAW,CA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AW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;IAET,+BAA+B;IAC/B,cAAc,CAAC,KAAK,EAAE;QACpB,iDAAiD;QACjD,SAAS,EAAE,MAAM,CAAC;QAClB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI,CAAC;IAET,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE;QAClB,iDAAiD;QACjD,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,IAAI,CAAC;CACV;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD;AAED,gBAAgB;AAChB,eAAO,MAAM,mCAAmC,qCAAqC,CAAC"}
@@ -8,12 +8,23 @@
8
8
  import { Selectables } from "./Selectable";
9
9
  import { SelectionChangeEventImpl } from "./SelectionChangeEvent";
10
10
  /**
11
- * Creates a selection storage. When an iModel is closed `SelectionStorage.clearSelection` function should be called.
11
+ * Creates a selection storage which stores and allows managing application-level selection.
12
+ *
13
+ * **Note:** `clearSelection` should be called upon iModel close to free-up memory:
14
+ * ```ts
15
+ * import { IModelConnection } from "@itwin/core-frontend";
16
+ * IModelConnection.onClose.addListener((iModel) => {
17
+ * storage.clearStorage(iModel.key);
18
+ * });
19
+ * ```
20
+ *
12
21
  * @beta
13
22
  */
14
23
  export function createStorage() {
15
24
  return new SelectionStorageImpl();
16
25
  }
26
+ /** @internal */
27
+ export const IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = "Unified selection storage: clear";
17
28
  class SelectionStorageImpl {
18
29
  _storage = new Map();
19
30
  selectionChangeEvent;
@@ -40,7 +51,7 @@ class SelectionStorageImpl {
40
51
  this.handleChange({ ...props, changeType: "clear", selectables: [] });
41
52
  }
42
53
  clearStorage({ iModelKey }) {
43
- this.clearSelection({ source: "Clear iModel storage", iModelKey });
54
+ this.clearSelection({ source: IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, iModelKey });
44
55
  this._storage.delete(iModelKey);
45
56
  }
46
57
  getContainer(iModelKey) {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionStorage.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;GAEG;AAEH,OAAO,EAAc,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAwB,wBAAwB,EAA+D,MAAM,wBAAwB,CAAC;AA6ErJ;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACpC,CAAC;AAED,MAAM,oBAAoB;IAChB,QAAQ,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9D,oBAAoB,CAA2B;IAEtD;QACE,IAAI,CAAC,oBAAoB,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC7D,CAAC;IAEM,kBAAkB,CAAC,EAAE,SAAS,EAAyB;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAC3D,CAAC;IAEM,YAAY,CAAC,KAA4C;QAC9D,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;QACnC,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IAEM,cAAc,CAAC,KAAuF;QAC3G,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,mBAAmB,CAAC,KAAuF;QAChH,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;IACxD,CAAC;IAEM,gBAAgB,CAA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,CAAC;YACrC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;SACrD;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAEM,kBAAkB;QACvB,MAAM,MAAM,GAAG,IAAI,KAAK,EAAU,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,EAAE;YACzD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBAClC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aACvB;SACF;QACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,KAAa;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACxD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;YACtC,IAAI,WAAW,IAAI,KAAK,EAAE;gBACxB,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;gBAClE,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;aAChC;SACF;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { Selectable, Selectables } from \"./Selectable\";\nimport { SelectionChangeEvent, SelectionChangeEventImpl, StorageSelectionChangeEventArgs, StorageSelectionChangeType } from \"./SelectionChangeEvent\";\n\n/**\n * Selection storage interface which provides main selection and sub-selection.\n * @beta\n */\nexport interface SelectionStorage {\n /** An event that is raised when selection changes. */\n selectionChangeEvent: SelectionChangeEvent;\n\n /** Get the selection levels currently stored for the specified iModel. */\n getSelectionLevels(props: {\n /** Key of the iModel to get selection levels for. */\n iModelKey: string;\n }): number[];\n\n /** Get the selection stored in the storage. */\n getSelection(props: {\n /** Key of the iModel to get selection for. */\n iModelKey: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): Selectables;\n\n /** Add keys to the selection. */\n addToSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Remove keys from current selection. */\n removeFromSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to remove from selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Replace current selection. */\n replaceSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Clear current selection. */\n clearSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Clear storage for an iModel. This function should be called when iModel is closed. */\n clearStorage(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n }): void;\n}\n\n/**\n * Creates a selection storage. When an iModel is closed `SelectionStorage.clearSelection` function should be called.\n * @beta\n */\nexport function createStorage(): SelectionStorage {\n return new SelectionStorageImpl();\n}\n\nclass SelectionStorageImpl implements SelectionStorage {\n private _storage = new Map<string, MultiLevelSelectablesContainer>();\n public selectionChangeEvent: SelectionChangeEventImpl;\n\n constructor() {\n this.selectionChangeEvent = new SelectionChangeEventImpl();\n }\n\n public getSelectionLevels({ iModelKey }: { iModelKey: string }): number[] {\n return this.getContainer(iModelKey).getSelectionLevels();\n }\n\n public getSelection(props: { iModelKey: string; level?: number }): Selectables {\n const { iModelKey, level } = props;\n return this.getContainer(iModelKey).getSelection(level ?? 0);\n }\n\n public addToSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"add\" });\n }\n\n public removeFromSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"remove\" });\n }\n\n public replaceSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"replace\" });\n }\n\n public clearSelection(props: { source: string; iModelKey: string; level?: number }): void {\n this.handleChange({ ...props, changeType: \"clear\", selectables: [] });\n }\n\n public clearStorage({ iModelKey }: { iModelKey: string }): void {\n this.clearSelection({ source: \"Clear iModel storage\", iModelKey });\n this._storage.delete(iModelKey);\n }\n\n private getContainer(iModelKey: string): MultiLevelSelectablesContainer {\n let selectionContainer = this._storage.get(iModelKey);\n if (!selectionContainer) {\n selectionContainer = new MultiLevelSelectablesContainer();\n this._storage.set(iModelKey, selectionContainer);\n }\n return selectionContainer;\n }\n\n private handleChange(props: { source: string; iModelKey: string; level?: number; changeType: StorageSelectionChangeType; selectables: Selectable[] }) {\n const { iModelKey, source, level: inLevel, changeType, selectables: change } = props;\n const container = this.getContainer(iModelKey);\n const level = inLevel ?? 0;\n const selectables = container.getSelection(level);\n const selected = Selectables.create(change);\n switch (changeType) {\n case \"add\":\n if (!Selectables.add(selectables, change)) {\n return;\n }\n break;\n case \"remove\":\n if (!Selectables.remove(selectables, change)) {\n return;\n }\n break;\n case \"replace\":\n if (Selectables.size(selectables) === Selectables.size(selected) && Selectables.hasAll(selectables, change)) {\n return;\n }\n Selectables.clear(selectables);\n Selectables.add(selectables, change);\n break;\n case \"clear\":\n if (!Selectables.clear(selectables)) {\n return;\n }\n break;\n }\n container.clear(level + 1);\n const event: StorageSelectionChangeEventArgs = {\n source,\n level,\n iModelKey,\n changeType,\n selectables: selected,\n timestamp: new Date(),\n };\n this.selectionChangeEvent.raiseEvent(event, this);\n }\n}\n\nclass MultiLevelSelectablesContainer {\n private readonly _selectablesContainers: Map<number, Selectables>;\n\n constructor() {\n this._selectablesContainers = new Map<number, Selectables>();\n }\n\n public getSelection(level: number): Selectables {\n let selectables = this._selectablesContainers.get(level);\n if (!selectables) {\n selectables = Selectables.create([]);\n this._selectablesContainers.set(level, selectables);\n }\n return selectables;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectablesContainers.entries()) {\n if (!Selectables.isEmpty(entry[1])) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const storedLevels = this._selectablesContainers.keys();\n for (const storedLevel of storedLevels) {\n if (storedLevel >= level) {\n const selectables = this._selectablesContainers.get(storedLevel)!;\n Selectables.clear(selectables);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"SelectionStorage.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;GAEG;AAEH,OAAO,EAAc,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAwB,wBAAwB,EAA+D,MAAM,wBAAwB,CAAC;AA+ErJ;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACpC,CAAC;AAED,gBAAgB;AAChB,MAAM,CAAC,MAAM,mCAAmC,GAAG,kCAAkC,CAAC;AAEtF,MAAM,oBAAoB;IAChB,QAAQ,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9D,oBAAoB,CAA2B;IAEtD;QACE,IAAI,CAAC,oBAAoB,GAAG,IAAI,wBAAwB,EAAE,CAAC;IAC7D,CAAC;IAEM,kBAAkB,CAAC,EAAE,SAAS,EAAyB;QAC5D,OAA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AAsB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;gBAClE,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;aAChC;SACF;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { Selectable, Selectables } from \"./Selectable\";\nimport { SelectionChangeEvent, SelectionChangeEventImpl, StorageSelectionChangeEventArgs, StorageSelectionChangeType } from \"./SelectionChangeEvent\";\n\n/**\n * Defines return value of `createStorage`.\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 SelectionStorage {\n /** An event that is raised when selection changes. */\n selectionChangeEvent: SelectionChangeEvent;\n\n /** Get the selection levels currently stored for the specified iModel. */\n getSelectionLevels(props: {\n /** Key of the iModel to get selection levels for. */\n iModelKey: string;\n }): number[];\n\n /** Get the selection stored in the storage. */\n getSelection(props: {\n /** Key of the iModel to get selection for. */\n iModelKey: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): Selectables;\n\n /** Add keys to the selection. */\n addToSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Remove keys from current selection. */\n removeFromSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to remove from selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Replace current selection. */\n replaceSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Clear current selection. */\n clearSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Clear storage for an iModel. This function should be called when iModel is closed. */\n clearStorage(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n }): void;\n}\n\n/**\n * Creates a selection storage which stores and allows managing application-level selection.\n *\n * **Note:** `clearSelection` should be called upon iModel close to free-up memory:\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * IModelConnection.onClose.addListener((iModel) => {\n * storage.clearStorage(iModel.key);\n * });\n * ```\n *\n * @beta\n */\nexport function createStorage(): SelectionStorage {\n return new SelectionStorageImpl();\n}\n\n/** @internal */\nexport const IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = \"Unified selection storage: clear\";\n\nclass SelectionStorageImpl implements SelectionStorage {\n private _storage = new Map<string, MultiLevelSelectablesContainer>();\n public selectionChangeEvent: SelectionChangeEventImpl;\n\n constructor() {\n this.selectionChangeEvent = new SelectionChangeEventImpl();\n }\n\n public getSelectionLevels({ iModelKey }: { iModelKey: string }): number[] {\n return this.getContainer(iModelKey).getSelectionLevels();\n }\n\n public getSelection(props: { iModelKey: string; level?: number }): Selectables {\n const { iModelKey, level } = props;\n return this.getContainer(iModelKey).getSelection(level ?? 0);\n }\n\n public addToSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"add\" });\n }\n\n public removeFromSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"remove\" });\n }\n\n public replaceSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"replace\" });\n }\n\n public clearSelection(props: { source: string; iModelKey: string; level?: number }): void {\n this.handleChange({ ...props, changeType: \"clear\", selectables: [] });\n }\n\n public clearStorage({ iModelKey }: { iModelKey: string }): void {\n this.clearSelection({ source: IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, iModelKey });\n this._storage.delete(iModelKey);\n }\n\n private getContainer(iModelKey: string): MultiLevelSelectablesContainer {\n let selectionContainer = this._storage.get(iModelKey);\n if (!selectionContainer) {\n selectionContainer = new MultiLevelSelectablesContainer();\n this._storage.set(iModelKey, selectionContainer);\n }\n return selectionContainer;\n }\n\n private handleChange(props: { source: string; iModelKey: string; level?: number; changeType: StorageSelectionChangeType; selectables: Selectable[] }) {\n const { iModelKey, source, level: inLevel, changeType, selectables: change } = props;\n const container = this.getContainer(iModelKey);\n const level = inLevel ?? 0;\n const selectables = container.getSelection(level);\n const selected = Selectables.create(change);\n switch (changeType) {\n case \"add\":\n if (!Selectables.add(selectables, change)) {\n return;\n }\n break;\n case \"remove\":\n if (!Selectables.remove(selectables, change)) {\n return;\n }\n break;\n case \"replace\":\n if (Selectables.size(selectables) === Selectables.size(selected) && Selectables.hasAll(selectables, change)) {\n return;\n }\n Selectables.clear(selectables);\n Selectables.add(selectables, change);\n break;\n case \"clear\":\n if (!Selectables.clear(selectables)) {\n return;\n }\n break;\n }\n container.clear(level + 1);\n const event: StorageSelectionChangeEventArgs = {\n source,\n level,\n iModelKey,\n changeType,\n selectables: selected,\n timestamp: new Date(),\n };\n this.selectionChangeEvent.raiseEvent(event, this);\n }\n}\n\nclass MultiLevelSelectablesContainer {\n private readonly _selectablesContainers: Map<number, Selectables>;\n\n constructor() {\n this._selectablesContainers = new Map<number, Selectables>();\n }\n\n public getSelection(level: number): Selectables {\n let selectables = this._selectablesContainers.get(level);\n if (!selectables) {\n selectables = Selectables.create([]);\n this._selectablesContainers.set(level, selectables);\n }\n return selectables;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectablesContainers.entries()) {\n if (!Selectables.isEmpty(entry[1])) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const storedLevels = this._selectablesContainers.keys();\n for (const storedLevel of storedLevels) {\n if (storedLevel >= level) {\n const selectables = this._selectablesContainers.get(storedLevel)!;\n Selectables.clear(selectables);\n }\n }\n }\n}\n"]}
@@ -0,0 +1,44 @@
1
+ /** @packageDocumentation
2
+ * @module UnifiedSelection
3
+ */
4
+ /**
5
+ * An interface of an iModel metadata provider used to retrieve information about ECSchemas,
6
+ * ECClasses, ECProperties, etc.
7
+ */
8
+ export interface IMetadataProvider {
9
+ getSchema(schemaName: string): Promise<ECSchema | undefined>;
10
+ }
11
+ /**
12
+ * Represents an ECSchema that contains classes, relationships, etc.
13
+ * @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/schema/
14
+ */
15
+ export interface ECSchema {
16
+ name: string;
17
+ getClass(name: string): Promise<ECClass | undefined>;
18
+ }
19
+ /**
20
+ * Represents an ECSchema item - a class, relationship, etc.
21
+ * @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/schemaitem/
22
+ */
23
+ export interface ECSchemaItem {
24
+ schema: ECSchema;
25
+ fullName: string;
26
+ name: string;
27
+ label?: string;
28
+ }
29
+ /**
30
+ * Represents an ECClass.
31
+ * @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/ecclass/
32
+ */
33
+ export interface ECClass extends ECSchemaItem {
34
+ is(className: string, schemaName: string): Promise<boolean>;
35
+ }
36
+ /**
37
+ * An utility to parse schema and class names from full class name, where
38
+ * schema and class names are separated by either `:` or `.`
39
+ */
40
+ export declare function parseFullClassName(fullClassName: string): {
41
+ schemaName: string;
42
+ className: string;
43
+ };
44
+ //# sourceMappingURL=ECMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ECMetadata.d.ts","sourceRoot":"","sources":["../../../../src/unified-selection/queries/ECMetadata.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;CAC9D;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,OAAQ,SAAQ,YAAY;IAC3C,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM;;;EAGvD"}
@@ -0,0 +1,13 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * An utility to parse schema and class names from full class name, where
7
+ * schema and class names are separated by either `:` or `.`
8
+ */
9
+ export function parseFullClassName(fullClassName) {
10
+ const [schemaName, className] = fullClassName.split(/[\.:]/);
11
+ return { schemaName, className };
12
+ }
13
+ //# sourceMappingURL=ECMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ECMetadata.js","sourceRoot":"","sources":["../../../../src/unified-selection/queries/ECMetadata.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AA0ChG;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,aAAqB;IACtD,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AACnC,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\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\n/**\n * An interface of an iModel metadata provider used to retrieve information about ECSchemas,\n * ECClasses, ECProperties, etc.\n */\nexport interface IMetadataProvider {\n getSchema(schemaName: string): Promise<ECSchema | undefined>;\n}\n\n/**\n * Represents an ECSchema that contains classes, relationships, etc.\n * @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/schema/\n */\nexport interface ECSchema {\n name: string;\n getClass(name: string): Promise<ECClass | undefined>;\n}\n\n/**\n * Represents an ECSchema item - a class, relationship, etc.\n * @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/schemaitem/\n */\nexport interface ECSchemaItem {\n schema: ECSchema;\n fullName: string;\n name: string;\n label?: string;\n}\n\n/**\n * Represents an ECClass.\n * @see https://www.itwinjs.org/reference/ecschema-metadata/metadata/ecclass/\n */\nexport interface ECClass extends ECSchemaItem {\n is(className: string, schemaName: string): Promise<boolean>;\n}\n\n/**\n * An utility to parse schema and class names from full class name, where\n * schema and class names are separated by either `:` or `.`\n */\nexport function parseFullClassName(fullClassName: string) {\n const [schemaName, className] = fullClassName.split(/[\\.:]/);\n return { schemaName, className };\n}\n"]}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Types of values that can be bound to an ECSql query.
3
+ */
4
+ export type ECSqlBindingType = "boolean" | "double" | "id" | "idset" | "int" | "long" | "string" | "point2d" | "point3d";
5
+ /**
6
+ * Defines an ECSql binding consisting of a value and its type. Necessary to differentiate between numeric
7
+ * types and `Id64String` vs `string`.
8
+ */
9
+ export type ECSqlBinding = {
10
+ type: "boolean";
11
+ value?: boolean;
12
+ } | {
13
+ type: "double" | "int" | "long";
14
+ value?: number;
15
+ } | {
16
+ type: "id";
17
+ value?: string;
18
+ } | {
19
+ type: "idset";
20
+ value?: string[];
21
+ } | {
22
+ type: "string";
23
+ value?: string;
24
+ } | {
25
+ type: "point2d";
26
+ value?: {
27
+ x: number;
28
+ y: number;
29
+ };
30
+ } | {
31
+ type: "point3d";
32
+ value?: {
33
+ x: number;
34
+ y: number;
35
+ z: number;
36
+ };
37
+ };
38
+ /**
39
+ * Defines requested ECSQL result row format.
40
+ */
41
+ export type ECSqlQueryRowFormat = "ECSqlPropertyNames" | "Indexes";
42
+ /**
43
+ * Defines options for ECSQL query reader.
44
+ */
45
+ export interface ECSqlQueryReaderOptions {
46
+ rowFormat?: ECSqlQueryRowFormat;
47
+ }
48
+ /**
49
+ * Represents a single row of an ECSQL query result.
50
+ */
51
+ export interface ECSqlQueryRow {
52
+ [propertyName: string]: any;
53
+ [propertyIndex: number]: any;
54
+ }
55
+ /**
56
+ * Represents ECSQL query results reader.
57
+ */
58
+ export type ECSqlQueryReader = AsyncIterableIterator<ECSqlQueryRow>;
59
+ /**
60
+ * An interface for something that knows how to create an ECSQL query reader.
61
+ */
62
+ export interface IECSqlQueryExecutor {
63
+ createQueryReader(ecsql: string, bindings?: ECSqlBinding[], config?: ECSqlQueryReaderOptions): ECSqlQueryReader;
64
+ }
65
+ /**
66
+ * Forms ECSql bindings from given ID's.
67
+ */
68
+ export declare function formIdBindings(property: string, ids: string[], bindings: ECSqlBinding[]): string;
69
+ //# sourceMappingURL=ECSqlCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ECSqlCore.d.ts","sourceRoot":"","sources":["../../../../src/unified-selection/queries/ECSqlCore.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE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Y,EAAE,EAAE,MAAM,CAAC,EAAE,uBAAuB,GAAG,gBAAgB,CAAC;CACjH;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAYhG"}
@@ -0,0 +1,19 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * Forms ECSql bindings from given ID's.
7
+ */
8
+ export function formIdBindings(property, ids, bindings) {
9
+ if (ids.length > 1000) {
10
+ bindings.push({ type: "idset", value: ids });
11
+ return `InVirtualSet(?, ${property})`;
12
+ }
13
+ if (ids.length === 0) {
14
+ return `FALSE`;
15
+ }
16
+ ids.forEach((id) => bindings.push({ type: "id", value: id }));
17
+ return `${property} IN (${ids.map(() => "?").join(",")})`;
18
+ }
19
+ //# sourceMappingURL=ECSqlCore.js.map